From de443bb5de0c91a81f0b4520c2e5a4c7235701b5 Mon Sep 17 00:00:00 2001 From: Patrick Gebhardt Date: Fri, 19 Jun 2020 17:50:15 +0200 Subject: [PATCH] Update interfaces --- frontend/src/app/containers/home/home.component.ts | 4 +++- frontend/src/app/interfaces/search-request.interface.ts | 3 +++ frontend/src/app/services/data.service.ts | 9 ++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/containers/home/home.component.ts b/frontend/src/app/containers/home/home.component.ts index 934d0e3..4a5bd16 100644 --- a/frontend/src/app/containers/home/home.component.ts +++ b/frontend/src/app/containers/home/home.component.ts @@ -10,13 +10,15 @@ import {Router} from '@angular/router'; }) export class HomeComponent implements OnInit { + private readonly MAX_REGIONS = 10; + regions: Region[]; constructor(private ds: DataService, private router: Router) { } async ngOnInit() { - this.regions = await this.ds.getAllRegions(); + this.regions = await this.ds.getAllRegions(this.MAX_REGIONS); } onRegionClick(region: Region) { diff --git a/frontend/src/app/interfaces/search-request.interface.ts b/frontend/src/app/interfaces/search-request.interface.ts index 576db17..5b511cb 100644 --- a/frontend/src/app/interfaces/search-request.interface.ts +++ b/frontend/src/app/interfaces/search-request.interface.ts @@ -12,6 +12,9 @@ export interface Query { entertainment_costs?: number[]; accommodation_costs?: number[]; average_per_day_costs?: number[]; + fulltext?: boolean; + textfilter?: string; + showRegionsWithNullScore?: boolean; } export enum SearchParameter { diff --git a/frontend/src/app/services/data.service.ts b/frontend/src/app/services/data.service.ts index e0636c4..88875dc 100644 --- a/frontend/src/app/services/data.service.ts +++ b/frontend/src/app/services/data.service.ts @@ -36,8 +36,12 @@ export class DataService { // }); } - public async getAllRegions(): Promise { - const regions = await this.http.get(this.API_URL + '/regions').toPromise(); + public async getAllRegions(max?: number): Promise { + let params = new HttpParams(); + if (max) { + params = params.set('randomize', max.toString(10)); + } + const regions = await this.http.get(this.API_URL + '/regions', {params}).toPromise(); regions.forEach(region => this.regionCache.set(region.region_id, region)); @@ -51,7 +55,6 @@ export class DataService { public async getRegion(id: number): Promise { if (this.regionCache.has(id)) { - console.log(`Served region ${id} from cache`); return this.regionCache.get(id); }