Add base64 encoding for search request
This commit is contained in:
parent
53cd7c6245
commit
db5c7fbbe7
@ -1,7 +1,15 @@
|
|||||||
|
import {SearchParam} from './search-request.interface';
|
||||||
|
|
||||||
/** Represents the structure of one search result. */
|
/** Represents the structure of one search result. */
|
||||||
export interface Result {
|
export interface Result {
|
||||||
region_id: string;
|
region_id: string;
|
||||||
region_name: string;
|
region_name: string;
|
||||||
score: number;
|
score: number;
|
||||||
scores: any[];
|
scores: Score[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Score {
|
||||||
|
type: SearchParam;
|
||||||
|
value: number;
|
||||||
|
score: number;
|
||||||
}
|
}
|
||||||
|
|||||||
25
frontend/src/app/interfaces/search-request.interface.ts
Normal file
25
frontend/src/app/interfaces/search-request.interface.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export enum SearchParam {
|
||||||
|
FROM = 'from',
|
||||||
|
TO = 'to',
|
||||||
|
TEMPERATURE = 'temperature',
|
||||||
|
PRECIPITATION = 'precipitation',
|
||||||
|
RAINDAYS = 'raindays',
|
||||||
|
HUMIDITY = 'humidity',
|
||||||
|
SUNHOURS = 'sunhours',
|
||||||
|
ALCOHOL = 'alcohol',
|
||||||
|
FOOD = 'food'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchParams {
|
||||||
|
from: number;
|
||||||
|
to: number;
|
||||||
|
price?: number[];
|
||||||
|
exclude_region_ids?: number[];
|
||||||
|
temperature?: number[];
|
||||||
|
precipitation?: number[];
|
||||||
|
raindays?: number[];
|
||||||
|
humidity?: number[];
|
||||||
|
sunhours?: number[];
|
||||||
|
alcohol?: number[];
|
||||||
|
food?: number[];
|
||||||
|
}
|
||||||
@ -1,6 +1,9 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||||
import {Preset} from '../interfaces/preset.interface';
|
import {Preset} from '../interfaces/preset.interface';
|
||||||
|
import {Result} from '../interfaces/result.interface';
|
||||||
|
import {SearchParams} from '../interfaces/search-request.interface';
|
||||||
|
import {Region} from '../interfaces/region.interface';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -12,7 +15,22 @@ export class DataService {
|
|||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPresets(): Promise<Preset[]> {
|
public searchRegions(searchParams: SearchParams): Promise<Result[]> {
|
||||||
return this.http.get<Preset[]>(this.API_URL + 'presets').toPromise();
|
const params = new HttpParams();
|
||||||
|
params.append('q', btoa(JSON.stringify(searchParams)));
|
||||||
|
|
||||||
|
return this.http.get<Result[]>(this.API_URL + 'search', {params}).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAllPresets(): Promise<Preset[]> {
|
||||||
|
return this.http.get<Preset[]>(this.API_URL + 'preset').toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAllRegions(): Promise<Region[]> {
|
||||||
|
return this.http.get<Region[]>(this.API_URL + 'region').toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public toMinMaxArray(min: number, max: number): number[] {
|
||||||
|
return [min, max];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user