Add basic interface and data service
This commit is contained in:
parent
316cb4f663
commit
53cd7c6245
7
frontend/src/app/interfaces/preset.interface.ts
Normal file
7
frontend/src/app/interfaces/preset.interface.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/** Represents the structure of a search preset. */
|
||||
export interface Preset {
|
||||
preset_id: number;
|
||||
parameter: string;
|
||||
tag_label: string;
|
||||
value: number[];
|
||||
}
|
||||
6
frontend/src/app/interfaces/region.interface.ts
Normal file
6
frontend/src/app/interfaces/region.interface.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/** Represents the structure of a region. */
|
||||
export interface Region {
|
||||
region_id: number;
|
||||
name: string;
|
||||
country: string;
|
||||
}
|
||||
7
frontend/src/app/interfaces/result.interface.ts
Normal file
7
frontend/src/app/interfaces/result.interface.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/** Represents the structure of one search result. */
|
||||
export interface Result {
|
||||
region_id: string;
|
||||
region_name: string;
|
||||
score: number;
|
||||
scores: any[];
|
||||
}
|
||||
12
frontend/src/app/services/data.service.spec.ts
Normal file
12
frontend/src/app/services/data.service.spec.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DataService } from './data.service';
|
||||
|
||||
describe('DataService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: DataService = TestBed.get(DataService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
18
frontend/src/app/services/data.service.ts
Normal file
18
frontend/src/app/services/data.service.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Preset} from '../interfaces/preset.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DataService {
|
||||
|
||||
private readonly API_URL = 'https://example.com/api/v1/';
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
public getPresets(): Promise<Preset[]> {
|
||||
return this.http.get<Preset[]>(this.API_URL + 'presets').toPromise();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user