This commit is contained in:
Willem Dantuma
2026-03-26 17:27:22 +01:00
parent 9d743eddea
commit 2192797a35
5 changed files with 8 additions and 31 deletions

4
package-lock.json generated
View File

@@ -82,7 +82,7 @@
}, },
"dist/common": { "dist/common": {
"name": "@farmmaps/common", "name": "@farmmaps/common",
"version": "2.1.0", "version": "4.22.0",
"dependencies": { "dependencies": {
"tslib": "^2.3.0" "tslib": "^2.3.0"
}, },
@@ -106,7 +106,7 @@
}, },
"dist/common-map": { "dist/common-map": {
"name": "@farmmaps/common-map", "name": "@farmmaps/common-map",
"version": "2.0.0", "version": "4.22.0",
"dependencies": { "dependencies": {
"tslib": "^2.0.0" "tslib": "^2.0.0"
}, },

View File

@@ -20,7 +20,6 @@ import { DownloadService } from './services/download.service';
import { GeolocatorService } from './services/geolocator.service'; import { GeolocatorService } from './services/geolocator.service';
import { WeatherService} from './services/weather.service'; import { WeatherService} from './services/weather.service';
import { AppConfig } from './shared/app.config'; import { AppConfig } from './shared/app.config';
import { appConfigFactory } from "./shared/app.config.factory";
import { AuthGuard } from './services/auth-guard.service'; import { AuthGuard } from './services/auth-guard.service';
import { NavBarGuard } from './services/nav-bar-guard.service'; import { NavBarGuard } from './services/nav-bar-guard.service';
import { PackageGuard } from './services/package-guard.service'; import { PackageGuard } from './services/package-guard.service';
@@ -85,10 +84,6 @@ export class AppCommonServiceModule {
providers: [ providers: [
AppConfig, AppConfig,
ItemTypeService, ItemTypeService,
provideAppInitializer(() => {
const initializerFn = (appConfigFactory)(inject(Injector), inject(AppConfig), inject(ItemTypeService));
return initializerFn();
}),
DatePipe DatePipe
] ]
}; };

View File

@@ -9,9 +9,8 @@ export class ItemTypeService {
public itemTypes: IItemTypes; public itemTypes: IItemTypes;
private httpClient: HttpClient; private httpClient: HttpClient;
constructor(xhrBackend: HttpXhrBackend,appConfig:AppConfig) { constructor(xhrBackend: HttpXhrBackend) {
this.httpClient = new HttpClient(xhrBackend); this.httpClient = new HttpClient(xhrBackend);
this.load(appConfig)
} }
getIcon(itemType: string) { getIcon(itemType: string) {

View File

@@ -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());
});
}
}

View File

@@ -7,11 +7,8 @@ import {Observable} from 'rxjs';
export class AppConfig { export class AppConfig {
private config: Object = null; private config: Object = null;
private httpClient: HttpClient;
constructor(xhrBackend: HttpXhrBackend,private location:Location) { constructor() {
this.httpClient = new HttpClient(xhrBackend);
this.config = null;
} }
public getConfig(key: any) { public getConfig(key: any) {
@@ -21,9 +18,10 @@ export class AppConfig {
return this.config[key]; return this.config[key];
} }
public load(): Promise<any> { public load(xhrBackend: HttpXhrBackend,location:Location): Promise<any> {
const url = this.location.prepareExternalUrl('/configuration.json'); const httpClient = new HttpClient(xhrBackend);
return this.httpClient.get(url) const url = location.prepareExternalUrl('/configuration.json');
return httpClient.get(url)
.toPromise() .toPromise()
.then(data => { .then(data => {
this.config = data; this.config = data;