Explorar el Código

HTTP request for mall by ID

master
kj1352 hace 6 años
padre
commit
a5a26a1cfe
Se han modificado 7 ficheros con 3226 adiciones y 482 borrados
  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
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 1
- 1
package.json Ver fichero

@@ -41,7 +41,7 @@
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/architect": "~0.801.2", "@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/core": "~8.1.2",
"@angular-devkit/schematics": "~8.1.2", "@angular-devkit/schematics": "~8.1.2",
"@angular/cli": "~8.1.2", "@angular/cli": "~8.1.2",


+ 2
- 0
src/app/app.module.ts Ver fichero

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


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


+ 6
- 6
src/app/malls/malls.page.html Ver fichero

@@ -32,7 +32,7 @@
<ion-button color="default" fill="clear" (click)="togglePopup()"> SORT / FILTER </ion-button> <ion-button color="default" fill="clear" (click)="togglePopup()"> SORT / FILTER </ion-button>
</div> </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)"> <ion-item *ngFor="let mall of malls" (click)="showMallDetails(mall)">
<img src="{{ mall.image_url }}" slot="start"> <img src="{{ mall.image_url }}" slot="start">
<ion-label> <ion-label>
@@ -70,11 +70,11 @@
</div> </div>
</ion-label> </ion-label>
</ion-item> </ion-item>
</ion-list>
</ion-list> -->


<!-- Ad in between results --> <!-- Ad in between results -->


<section class="advertisement">
<!-- <section class="advertisement">
<div class="heading-holder"> <div class="heading-holder">
<img src="assets/custom/logo.svg"> <img src="assets/custom/logo.svg">
<header> <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. 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> </p>
<a> Know More </a> <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> <header>
Sort / Filter <button (click)="togglePopup()"> Done </button> Sort / Filter <button (click)="togglePopup()"> Done </button>
</header> </header>
@@ -109,6 +109,6 @@
<span> TIME </span> <span> TIME </span>
</button> </button>
</div> </div>
</div>
</div> -->


</ion-content> </ion-content>

+ 6
- 3
src/app/malls/malls.page.ts Ver fichero

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


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


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

} }


showMallDetails(mall: IMall) { showMallDetails(mall: IMall) {


+ 3
- 0
src/app/mocks/url.ts Ver fichero

@@ -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 Ver fichero

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



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


constructor( constructor(
private offerService: OfferService, private offerService: OfferService,
private outletService: OutletService
private outletService: OutletService,
private http: HttpClient
) { ) {
this.fetchMalls(); 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) => { private getDenormalizedMall = async (mall: Mall) => {
const offers = await Promise.all(mall.offers.map(offer_id => this.offerService.getOfferByID(offer_id))); 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))); const outlets = await Promise.all(mall.outlets.map(outlet_id => this.outletService.getOutletByID(outlet_id)));


Cargando…
Cancelar
Guardar