2018-11-11 12:00:45 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { ActivatedRouteSnapshot, Resolve } from "@angular/router";
|
|
|
|
|
import { HttpClient } from "@angular/common/http";
|
2018-11-12 07:08:57 +01:00
|
|
|
import { Observable } from "rxjs";
|
2018-11-11 12:00:45 +01:00
|
|
|
|
|
|
|
|
import { environment } from "../../../environments/environment";
|
|
|
|
|
import { FacilityLocation } from "../shared";
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
2018-11-11 13:50:37 +01:00
|
|
|
export class FacilityLocationService implements Resolve<false|Array<FacilityLocation>> {
|
2018-11-11 12:00:45 +01:00
|
|
|
|
|
|
|
|
private url = environment.apiUrl + '/api/facility-location';
|
|
|
|
|
|
|
|
|
|
constructor(private httpService: HttpClient) {
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-11 13:50:37 +01:00
|
|
|
public resolve(route: ActivatedRouteSnapshot): Promise<false|Array<FacilityLocation>> {
|
2018-11-11 12:00:45 +01:00
|
|
|
return this.getList().toPromise().then(result => result ? result : false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getList(): Observable<Array<FacilityLocation>> {
|
|
|
|
|
return this.httpService.get<FacilityLocation[]>(this.url);
|
|
|
|
|
}
|
|
|
|
|
}
|