Browse Source

HTTP request for mall by ID

master
kj1352 6 years ago
parent
commit
a5a26a1cfe
7 changed files with 3226 additions and 482 deletions
  1. +3192
    -471
      package-lock.json
  2. +1
    -1
      package.json
  3. +2
    -0
      src/app/app.module.ts
  4. +6
    -6
      src/app/malls/malls.page.html
  5. +6
    -3
      src/app/malls/malls.page.ts
  6. +3
    -0
      src/app/mocks/url.ts
  7. +16
    -1
      src/app/services/mall.service.ts

+ 3192
- 471
package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@@ -41,7 +41,7 @@
},
"devDependencies": {
"@angular-devkit/architect": "~0.801.2",
"@angular-devkit/build-angular": "~0.801.2",
"@angular-devkit/build-angular": "^0.803.22",
"@angular-devkit/core": "~8.1.2",
"@angular-devkit/schematics": "~8.1.2",
"@angular/cli": "~8.1.2",


+ 2
- 0
src/app/app.module.ts View File

@@ -6,6 +6,7 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { IonicStorageModule } from '@ionic/storage';
import { HttpClientModule } from '@angular/common/http';

// Services import
import { MallService } from './services/mall.service';
@@ -32,6 +33,7 @@ import { Geolocation } from '@ionic-native/geolocation/ngx';
IonicModule.forRoot(),
AppRoutingModule,
IonicStorageModule.forRoot(),
HttpClientModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })],
providers: [
StatusBar,


+ 6
- 6
src/app/malls/malls.page.html View File

@@ -32,7 +32,7 @@
<ion-button color="default" fill="clear" (click)="togglePopup()"> SORT / FILTER </ion-button>
</div>

<ion-list lines="none" class="result-list">
<!-- <ion-list lines="none" class="result-list">
<ion-item *ngFor="let mall of malls" (click)="showMallDetails(mall)">
<img src="{{ mall.image_url }}" slot="start">
<ion-label>
@@ -70,11 +70,11 @@
</div>
</ion-label>
</ion-item>
</ion-list>
</ion-list> -->

<!-- Ad in between results -->

<section class="advertisement">
<!-- <section class="advertisement">
<div class="heading-holder">
<img src="assets/custom/logo.svg">
<header>
@@ -85,9 +85,9 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dicta eius molestiae ipsum fugit velit voluptatem vel ad ut debitis earum, nostrum numquam odio maxime eaque corporis! Non et cumque, dignissimos.
</p>
<a> Know More </a>
</section>
</section> -->

<div class="common-semi-modal sort-holder" [ngClass]="{'active' : show_sort_popup }">
<!-- <div class="common-semi-modal sort-holder" [ngClass]="{'active' : show_sort_popup }">
<header>
Sort / Filter <button (click)="togglePopup()"> Done </button>
</header>
@@ -109,6 +109,6 @@
<span> TIME </span>
</button>
</div>
</div>
</div> -->

</ion-content>

+ 6
- 3
src/app/malls/malls.page.ts View File

@@ -20,12 +20,15 @@ export class MallsPage implements OnInit {
) { }

ngOnInit() {
this.mallService.mallsByLocation(10.998264, 77.032465).then((response) => {
console.log(response);
}, (error) => {
console.log(error);
});
}

ionViewDidEnter() {
this.mallService.getAllMalls().then((data: Array<IMall>) => {
this.malls = data;
});

}

showMallDetails(mall: IMall) {


+ 3
- 0
src/app/mocks/url.ts View File

@@ -0,0 +1,3 @@
export const URL: string = 'http://13.126.110.70:8080/mall-aggregator/';

export const TOKEN: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';

+ 16
- 1
src/app/services/mall.service.ts View File

@@ -3,6 +3,9 @@ import { MALLS } from '../mocks/malls';
import Mall, { IMall } from '../models/mall';
import { OfferService } from './offer.service';
import { OutletService } from './outlet.service';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { TOKEN, URL } from '../mocks/url';


@Injectable({
providedIn: 'root'
@@ -12,11 +15,23 @@ export class MallService {

constructor(
private offerService: OfferService,
private outletService: OutletService
private outletService: OutletService,
private http: HttpClient
) {
this.fetchMalls();
}

async mallsByLocation(latitude: number, longitude: number) {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Token ' + TOKEN
})
};

return await this.http.get(URL + '/api/maioraservice/mall/v1/latitude/' + latitude + '/longitude/' + longitude + '/', httpOptions).toPromise();
}

private getDenormalizedMall = async (mall: Mall) => {
const offers = await Promise.all(mall.offers.map(offer_id => this.offerService.getOfferByID(offer_id)));
const outlets = await Promise.all(mall.outlets.map(outlet_id => this.outletService.getOutletByID(outlet_id)));


Loading…
Cancel
Save