Environnement "dev"
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
"with": "src/environments/environment.dev.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@ import { inject, provideAppInitializer } from "@angular/core";
|
||||
import { ApplicationConfig, provideZoneChangeDetection } from "@angular/core";
|
||||
import { provideRouter } from "@angular/router";
|
||||
import { DatePipe } from "@angular/common";
|
||||
import {
|
||||
HttpClient,
|
||||
HTTP_INTERCEPTORS,
|
||||
provideHttpClient,
|
||||
} from "@angular/common/http";
|
||||
import { HTTP_INTERCEPTORS, provideHttpClient } from "@angular/common/http";
|
||||
|
||||
import { DateService } from "../services/date.service";
|
||||
import { AircraftService } from "../services/aircraft.service";
|
||||
@@ -31,17 +27,9 @@ import { environment } from "../environments/environment";
|
||||
|
||||
import { routes } from "./app.routes";
|
||||
|
||||
import {
|
||||
provideTranslateService,
|
||||
provideTranslateLoader,
|
||||
} from "@ngx-translate/core";
|
||||
import { provideTranslateService } from "@ngx-translate/core";
|
||||
import { provideTranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||
|
||||
// AOT compilation support
|
||||
// export function httpTranslateLoader(http: HttpClient) {
|
||||
// return new TranslateHttpLoader(http);
|
||||
// }
|
||||
|
||||
// Déclaration de la fonction d'initialisation de la configuration
|
||||
export function initConfig(configService: ConfigurationHelper) {
|
||||
return () => configService.load(environment.env);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"apiUrl": "http://localhost:5000",
|
||||
"version": "0.28.0"
|
||||
}
|
||||
"apiUrl": "http://localhost:5000",
|
||||
"version": "0.28.0 DEV"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"apiUrl": "https://test-divelog.sebastienandre.com",
|
||||
"version": "0.28.0"
|
||||
}
|
||||
"apiUrl": "https://test-divelog.sebastienandre.com",
|
||||
"version": "0.28.0 PROD"
|
||||
}
|
||||
|
||||
10
Front/skydivelogs-app/src/environments/environment.dev.ts
Normal file
10
Front/skydivelogs-app/src/environments/environment.dev.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// The file contents for the current environment will overwrite these during build.
|
||||
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
debugMode: true,
|
||||
env: "dev"
|
||||
};
|
||||
@@ -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