33 lines
907 B
TypeScript
33 lines
907 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { AbstractPageService } from '../utils';
|
|
import { DefaultService, WeatherStation, WeatherStationPage } from '../api';
|
|
import { Observable } from 'rxjs';
|
|
import { HttpResponse } from '@angular/common/http';
|
|
|
|
/**
|
|
* A service that retrieves a page of weather stations.
|
|
*/
|
|
@Injectable()
|
|
export class StationsService extends AbstractPageService<WeatherStation, WeatherStationPage> {
|
|
|
|
term = '';
|
|
|
|
constructor(apiClientService: DefaultService) {
|
|
super(apiClientService);
|
|
}
|
|
|
|
protected loadPage(offset: number, size: number): Observable<HttpResponse<WeatherStationPage>> {
|
|
return this.apiClientService.getStations(this.term, offset, size, 'response');
|
|
}
|
|
|
|
setTerm(term: string) {
|
|
this.term = term;
|
|
this.getPage(0, this.page.getValue().size);
|
|
}
|
|
|
|
getTerm(): string {
|
|
return this.term;
|
|
}
|
|
|
|
}
|