Environnement "dev"
This commit is contained in:
@@ -1,31 +1,33 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { IAppSettings } from '../models/app-settings';
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { IAppSettings } from "../models/app-settings";
|
||||
|
||||
@Injectable({ providedIn: "root" })
|
||||
export class ConfigurationHelper {
|
||||
private static settingsSource = new BehaviorSubject<IAppSettings>(null);
|
||||
public static settings = ConfigurationHelper.settingsSource.asObservable();
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
private static settingsSource = new BehaviorSubject<IAppSettings>(null);
|
||||
public static settings = ConfigurationHelper.settingsSource.asObservable();
|
||||
|
||||
load(env: string) {
|
||||
const jsonFile = `/config/config.${env}.json`;
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.http.get(jsonFile)
|
||||
.toPromise()
|
||||
.then((response : IAppSettings) => {
|
||||
ConfigurationHelper.settingsSource.next(<IAppSettings>response);
|
||||
resolve();
|
||||
})
|
||||
.catch((response: any) => {
|
||||
reject(`Could not load file '${jsonFile}': ${JSON.stringify(response)}`);
|
||||
});
|
||||
load(env: string) {
|
||||
const jsonFile = `/config/config.${env}.json`;
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.http
|
||||
.get(jsonFile)
|
||||
.toPromise()
|
||||
.then((response: IAppSettings) => {
|
||||
ConfigurationHelper.settingsSource.next(<IAppSettings>response);
|
||||
resolve();
|
||||
})
|
||||
.catch((response: any) => {
|
||||
reject(
|
||||
`Could not load file '${jsonFile}': ${JSON.stringify(response)}`
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user