wip
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -82,7 +82,7 @@
|
||||
},
|
||||
"dist/common": {
|
||||
"name": "@farmmaps/common",
|
||||
"version": "2.1.0",
|
||||
"version": "4.22.0",
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
@@ -106,7 +106,7 @@
|
||||
},
|
||||
"dist/common-map": {
|
||||
"name": "@farmmaps/common-map",
|
||||
"version": "2.0.0",
|
||||
"version": "4.22.0",
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.0"
|
||||
},
|
||||
|
||||
@@ -20,7 +20,6 @@ import { DownloadService } from './services/download.service';
|
||||
import { GeolocatorService } from './services/geolocator.service';
|
||||
import { WeatherService} from './services/weather.service';
|
||||
import { AppConfig } from './shared/app.config';
|
||||
import { appConfigFactory } from "./shared/app.config.factory";
|
||||
import { AuthGuard } from './services/auth-guard.service';
|
||||
import { NavBarGuard } from './services/nav-bar-guard.service';
|
||||
import { PackageGuard } from './services/package-guard.service';
|
||||
@@ -85,10 +84,6 @@ export class AppCommonServiceModule {
|
||||
providers: [
|
||||
AppConfig,
|
||||
ItemTypeService,
|
||||
provideAppInitializer(() => {
|
||||
const initializerFn = (appConfigFactory)(inject(Injector), inject(AppConfig), inject(ItemTypeService));
|
||||
return initializerFn();
|
||||
}),
|
||||
DatePipe
|
||||
]
|
||||
};
|
||||
|
||||
@@ -9,9 +9,8 @@ export class ItemTypeService {
|
||||
public itemTypes: IItemTypes;
|
||||
private httpClient: HttpClient;
|
||||
|
||||
constructor(xhrBackend: HttpXhrBackend,appConfig:AppConfig) {
|
||||
constructor(xhrBackend: HttpXhrBackend) {
|
||||
this.httpClient = new HttpClient(xhrBackend);
|
||||
this.load(appConfig)
|
||||
}
|
||||
|
||||
getIcon(itemType: string) {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Injector } from '@angular/core';
|
||||
import { AppConfig } from "./app.config";
|
||||
import {ItemTypeService} from '../services/itemtype.service';
|
||||
|
||||
|
||||
|
||||
export function appConfigFactory(injector:Injector, appConfig: AppConfig, itemtypeService:ItemTypeService): () => Promise<any> {
|
||||
return (): Promise<any> => {
|
||||
return new Promise<void>((resolve,reject) => {
|
||||
appConfig.load().then(() => {
|
||||
itemtypeService.load(appConfig);
|
||||
}).then(() => resolve()).catch(() => reject());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,8 @@ import {Observable} from 'rxjs';
|
||||
export class AppConfig {
|
||||
|
||||
private config: Object = null;
|
||||
private httpClient: HttpClient;
|
||||
|
||||
constructor(xhrBackend: HttpXhrBackend,private location:Location) {
|
||||
this.httpClient = new HttpClient(xhrBackend);
|
||||
this.config = null;
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public getConfig(key: any) {
|
||||
@@ -21,9 +18,10 @@ export class AppConfig {
|
||||
return this.config[key];
|
||||
}
|
||||
|
||||
public load(): Promise<any> {
|
||||
const url = this.location.prepareExternalUrl('/configuration.json');
|
||||
return this.httpClient.get(url)
|
||||
public load(xhrBackend: HttpXhrBackend,location:Location): Promise<any> {
|
||||
const httpClient = new HttpClient(xhrBackend);
|
||||
const url = location.prepareExternalUrl('/configuration.json');
|
||||
return httpClient.get(url)
|
||||
.toPromise()
|
||||
.then(data => {
|
||||
this.config = data;
|
||||
|
||||
Reference in New Issue
Block a user