@geogirafe/lib-geoportal 1.2.0-dev.2873796427 → 1.2.0-dev.2889467567
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/apicontext.d.ts +12 -1
- package/api/apicontext.js +19 -111
- package/api/apisessionmanager.d.ts +1 -1
- package/api/apisessionmanager.js +1 -1
- package/base/GirafeSingleton.d.ts +1 -1
- package/base/GirafeSingleton.js +1 -1
- package/components/navigation/component.d.ts +2 -2
- package/components/navigation/component.js +6 -6
- package/components/news/news-button/component.d.ts +0 -1
- package/components/news/news-button/component.js +0 -6
- package/components/news/news-panel/component.d.ts +2 -2
- package/components/news/news-panel/component.js +5 -5
- package/components/search-filter/component.d.ts +2 -0
- package/components/search-filter/component.js +6 -3
- package/components/search-filter/style.css +4 -0
- package/components/themes/component.d.ts +1 -1
- package/components/themes/component.js +4 -4
- package/components/userpreferences/component.d.ts +1 -1
- package/components/userpreferences/component.js +7 -7
- package/package.json +1 -1
- package/templates/public/about.json +1 -1
- package/tools/app/lifecyclemanager.d.ts +1 -1
- package/tools/app/lifecyclemanager.js +1 -1
- package/tools/auth/abstractconnectmanager.js +2 -2
- package/tools/auth/authmanager.d.ts +1 -1
- package/tools/auth/authmanager.js +1 -1
- package/tools/auth/pluginmanager.d.ts +1 -1
- package/tools/auth/pluginmanager.js +1 -1
- package/tools/configuration/configmanager.d.ts +3 -2
- package/tools/configuration/configmanager.js +9 -5
- package/tools/configuration/girafeconfig.d.ts +7 -5
- package/tools/configuration/girafeconfig.js +4 -0
- package/tools/context/context.d.ts +1 -0
- package/tools/context/context.js +4 -112
- package/tools/context/contexthelper.d.ts +6 -0
- package/tools/context/contexthelper.js +102 -0
- package/tools/error/errormanager.d.ts +1 -1
- package/tools/error/errormanager.js +1 -1
- package/tools/feedback/feedbackmanager.d.ts +1 -2
- package/tools/feedback/feedbackmanager.js +6 -8
- package/tools/i18n/i18nmanager.d.ts +1 -1
- package/tools/i18n/i18nmanager.js +22 -20
- package/tools/layers/layermanager.d.ts +1 -1
- package/tools/layers/layermanager.js +1 -1
- package/tools/layers/snapmanager.d.ts +1 -1
- package/tools/layers/snapmanager.js +1 -1
- package/tools/localfile/localfilemanager.d.ts +1 -1
- package/tools/localfile/localfilemanager.js +1 -1
- package/tools/logging/defaultconsole.d.ts +8 -0
- package/tools/logging/defaultconsole.js +9 -0
- package/tools/logging/logmanager.d.ts +1 -7
- package/tools/logging/logmanager.js +8 -13
- package/tools/main.d.ts +3 -1
- package/tools/main.js +2 -0
- package/tools/offline/offlinemanager.d.ts +3 -3
- package/tools/offline/offlinemanager.js +6 -6
- package/tools/ogcapi/ogcapifeaturesmanager.d.ts +1 -1
- package/tools/ogcapi/ogcapifeaturesmanager.js +1 -1
- package/tools/onboarding/onboardingmanager.js +4 -4
- package/tools/ordering/orderingmanager.d.ts +1 -1
- package/tools/ordering/orderingmanager.js +1 -1
- package/tools/search/abstractsearchclient.d.ts +1 -1
- package/tools/search/abstractsearchclient.js +2 -2
- package/tools/search/searchmanager.d.ts +1 -1
- package/tools/search/searchmanager.js +2 -2
- package/tools/selection/selectionmanager.d.ts +1 -1
- package/tools/selection/selectionmanager.js +1 -1
- package/tools/share/sessionmanager.d.ts +1 -1
- package/tools/share/sessionmanager.js +1 -1
- package/tools/share/sharemanager.d.ts +1 -1
- package/tools/share/sharemanager.js +1 -1
- package/tools/share/stateserializer.d.ts +1 -1
- package/tools/share/stateserializer.js +1 -1
- package/tools/state/statemanager.d.ts +1 -1
- package/tools/state/statemanager.js +1 -1
- package/tools/tests/mockconfig.d.ts +2 -3
- package/tools/tests/mockconfig.js +0 -1
- package/tools/tests/mockcontext.d.ts +13 -1
- package/tools/tests/mockcontext.js +27 -112
- package/tools/tests/mockhelper.d.ts +2 -2
- package/tools/tests/mockhelper.js +4 -5
- package/tools/themes/customthemesmanager.d.ts +3 -3
- package/tools/themes/customthemesmanager.js +9 -9
- package/tools/themes/themefavoritesmanager.d.ts +5 -5
- package/tools/themes/themefavoritesmanager.js +16 -16
- package/tools/themes/themeshelper.d.ts +1 -1
- package/tools/themes/themeshelper.js +1 -1
- package/tools/themes/themesmanager.d.ts +1 -1
- package/tools/themes/themesmanager.js +2 -2
- package/tools/url/permalinkmanager.d.ts +1 -1
- package/tools/url/permalinkmanager.js +1 -1
- package/tools/userdata/userdatamanager.d.ts +18 -39
- package/tools/userdata/userdatamanager.js +111 -75
- package/tools/wfs/wfsmanager.d.ts +1 -1
- package/tools/wfs/wfsmanager.js +1 -1
- package/tools/wms/wmsmanager.d.ts +1 -1
- package/tools/wms/wmsmanager.js +1 -1
|
@@ -10,7 +10,8 @@ declare class ConfigManager extends GirafeSingleton {
|
|
|
10
10
|
constructor(context: IGirafeContext);
|
|
11
11
|
get Config(): GirafeConfig;
|
|
12
12
|
private getConfigUrls;
|
|
13
|
-
|
|
13
|
+
initializeSingleton(): Promise<void>;
|
|
14
|
+
private loadConfig;
|
|
14
15
|
private doLoadConfig;
|
|
15
16
|
/**
|
|
16
17
|
* Merges two configuration objects recursively.
|
|
@@ -20,7 +21,7 @@ declare class ConfigManager extends GirafeSingleton {
|
|
|
20
21
|
* Retrieves saved configuration overrides based on the user data source.
|
|
21
22
|
* @param userDataSource The source of user data.
|
|
22
23
|
*/
|
|
23
|
-
private
|
|
24
|
+
private loadConfigOverrides;
|
|
24
25
|
/**
|
|
25
26
|
* Retrieves the original (default) configuration value before applying overrides.
|
|
26
27
|
* @param path The path to the configuration property.
|
|
@@ -42,6 +42,9 @@ class ConfigManager extends GirafeSingleton {
|
|
|
42
42
|
}
|
|
43
43
|
return configUrls;
|
|
44
44
|
}
|
|
45
|
+
async initializeSingleton() {
|
|
46
|
+
await this.loadConfig();
|
|
47
|
+
}
|
|
45
48
|
async loadConfig() {
|
|
46
49
|
if (this.loadingPromise) {
|
|
47
50
|
// There's already a promise for loading the configuration
|
|
@@ -50,7 +53,7 @@ class ConfigManager extends GirafeSingleton {
|
|
|
50
53
|
}
|
|
51
54
|
if (this.config) {
|
|
52
55
|
// Config was already loaded.
|
|
53
|
-
return
|
|
56
|
+
return this.config;
|
|
54
57
|
}
|
|
55
58
|
this.loadingPromise = this.doLoadConfig();
|
|
56
59
|
return this.loadingPromise;
|
|
@@ -77,7 +80,7 @@ class ConfigManager extends GirafeSingleton {
|
|
|
77
80
|
// Create a backup of the default config before applying overrides
|
|
78
81
|
this.defaultConfig = new GirafeConfig(structuredClone(jsonConfig));
|
|
79
82
|
// Load config overrides and merge them with the default config
|
|
80
|
-
const configOverrides = this.
|
|
83
|
+
const configOverrides = await this.loadConfigOverrides(this.defaultConfig);
|
|
81
84
|
jsonConfig = this.mergeConfigs(jsonConfig, configOverrides);
|
|
82
85
|
this.config = new GirafeConfig(jsonConfig);
|
|
83
86
|
console.log('Application Configuration loaded.');
|
|
@@ -93,10 +96,11 @@ class ConfigManager extends GirafeSingleton {
|
|
|
93
96
|
* Retrieves saved configuration overrides based on the user data source.
|
|
94
97
|
* @param userDataSource The source of user data.
|
|
95
98
|
*/
|
|
96
|
-
|
|
99
|
+
async loadConfigOverrides(config) {
|
|
97
100
|
// Set the user data source first before requesting config overrides from the userDataManager
|
|
98
|
-
this.context.userDataManager.
|
|
99
|
-
|
|
101
|
+
this.context.userDataManager.initializeFromConfig(config.userdata);
|
|
102
|
+
const configOverrides = await this.context.userDataManager.getUserData(this.storagePathForOverrides);
|
|
103
|
+
return configOverrides;
|
|
100
104
|
}
|
|
101
105
|
/**
|
|
102
106
|
* Retrieves the original (default) configuration value before applying overrides.
|
|
@@ -2,6 +2,11 @@ export declare enum HighlightMode {
|
|
|
2
2
|
HighlightAll = "highlight-all",
|
|
3
3
|
HighlightPerLayer = "highlight-per-layer"
|
|
4
4
|
}
|
|
5
|
+
export type UserDataConfig = {
|
|
6
|
+
source: 'localStorage' | 'server';
|
|
7
|
+
getUrl?: string;
|
|
8
|
+
postUrl?: string;
|
|
9
|
+
};
|
|
5
10
|
import { Config as SanitizeConfig } from 'dompurify';
|
|
6
11
|
import { LayoutType } from '../state/layout.js';
|
|
7
12
|
declare class GirafeConfig {
|
|
@@ -68,6 +73,7 @@ declare class GirafeConfig {
|
|
|
68
73
|
filterEnabled?: boolean;
|
|
69
74
|
filterShortcuts?: Record<string, string[]>;
|
|
70
75
|
filterShortcutPrefix?: string[];
|
|
76
|
+
filterExamples?: Record<string, string>;
|
|
71
77
|
};
|
|
72
78
|
print?: {
|
|
73
79
|
url: string;
|
|
@@ -243,11 +249,7 @@ declare class GirafeConfig {
|
|
|
243
249
|
refererPolicy: ReferrerPolicy;
|
|
244
250
|
};
|
|
245
251
|
};
|
|
246
|
-
userdata:
|
|
247
|
-
source: 'localStorage' | 'server';
|
|
248
|
-
getUrl: string | undefined;
|
|
249
|
-
postUrl: string | undefined;
|
|
250
|
-
};
|
|
252
|
+
userdata: UserDataConfig;
|
|
251
253
|
contact?: {
|
|
252
254
|
url: string;
|
|
253
255
|
reasons: string[];
|
|
@@ -253,6 +253,7 @@ class GirafeConfig {
|
|
|
253
253
|
filterEnabled: config.search.filterEnabled ?? true,
|
|
254
254
|
filterShortcutPrefix: config.search.filterShortcutPrefix ?? ['#'],
|
|
255
255
|
filterShortcuts: config.search.filterShortcuts ?? undefined,
|
|
256
|
+
filterExamples: config.search.filterExamples ?? undefined,
|
|
256
257
|
objectPreview: config.search.objectPreview ?? false,
|
|
257
258
|
layerPreview: config.search.layerPreview ?? false,
|
|
258
259
|
minResolution: config.search.minResolution ?? 0.5,
|
|
@@ -466,6 +467,9 @@ class GirafeConfig {
|
|
|
466
467
|
const defaultConfig = {
|
|
467
468
|
source: 'localStorage'
|
|
468
469
|
};
|
|
470
|
+
if (config.userdata?.source === 'server' && (!config.userdata?.getUrl || !config.userdata?.postUrl)) {
|
|
471
|
+
throw new Error(`Configuration userdata.getUrl or userdata.postUrl is missing. See https://doc.geogirafe.org/docs/configuration.`);
|
|
472
|
+
}
|
|
469
473
|
return {
|
|
470
474
|
...defaultConfig,
|
|
471
475
|
...config.userdata
|
|
@@ -72,6 +72,7 @@ export default class GirafeContext implements IGirafeContext {
|
|
|
72
72
|
readonly themeFavoritesManager: ThemeFavoritesManager;
|
|
73
73
|
readonly searchManager: SearchManager;
|
|
74
74
|
readonly feedbackManager: FeedbackManager;
|
|
75
|
+
private readonly contextHelper;
|
|
75
76
|
constructor();
|
|
76
77
|
initialize(): Promise<void>;
|
|
77
78
|
}
|
package/tools/context/context.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import DragManager from '../../components/treeview/tools/dragmanager.js';
|
|
3
|
-
import ApplicationLifeCycleManager from '../app/lifecyclemanager.js';
|
|
4
|
-
import AuthManager from '../auth/authmanager.js';
|
|
5
|
-
import PluginManager from '../auth/pluginmanager.js';
|
|
6
|
-
import ConfigManager from '../configuration/configmanager.js';
|
|
7
|
-
import ErrorManager from '../error/errormanager.js';
|
|
8
|
-
import I18nManager from '../i18n/i18nmanager.js';
|
|
9
|
-
import LayerManager from '../layers/layermanager.js';
|
|
10
|
-
import SnapManager from '../layers/snapmanager.js';
|
|
11
|
-
import LocalFileManager from '../localfile/localfilemanager.js';
|
|
12
|
-
import LogManager from '../logging/logmanager.js';
|
|
13
|
-
import OfflineManager from '../offline/offlinemanager.js';
|
|
14
|
-
import OgcApiFeaturesManager from '../ogcapi/ogcapifeaturesmanager.js';
|
|
15
|
-
import OnBoardingManager from '../onboarding/onboardingmanager.js';
|
|
16
|
-
import OrderingManager from '../ordering/orderingmanager.js';
|
|
17
|
-
import SessionManager from '../share/sessionmanager.js';
|
|
18
|
-
import ShareManager from '../share/sharemanager.js';
|
|
19
|
-
import StateSerializer from '../share/stateserializer.js';
|
|
20
|
-
import ComponentManager from '../state/componentManager.js';
|
|
21
|
-
import MapManager from '../state/mapManager.js';
|
|
22
|
-
import StateManager from '../state/statemanager.js';
|
|
23
|
-
import UserInteractionManager from '../state/userInteractionManager.js';
|
|
24
|
-
import CustomThemesManager from '../themes/customthemesmanager.js';
|
|
25
|
-
import ThemesHelper from '../themes/themeshelper.js';
|
|
26
|
-
import ThemesManager from '../themes/themesmanager.js';
|
|
27
|
-
import UserLayerManager from '../themes/userlayermanager.js';
|
|
28
|
-
import PermalinkManager from '../url/permalinkmanager.js';
|
|
29
|
-
import UrlManager from '../url/urlmanager.js';
|
|
30
|
-
import UserDataManager from '../userdata/userdatamanager.js';
|
|
31
|
-
import WfsManager from '../wfs/wfsmanager.js';
|
|
32
|
-
import WmsManager from '../wms/wmsmanager.js';
|
|
33
|
-
import WmtsManager from '../wmts/wmtsmanager.js';
|
|
34
|
-
import SelectionManager from '../selection/selectionmanager.js';
|
|
35
|
-
import ThemeFavoritesManager from '../themes/themefavoritesmanager.js';
|
|
36
|
-
import SearchManager from '../search/searchmanager.js';
|
|
37
|
-
import FeedbackManager from '../feedback/feedbackmanager.js';
|
|
1
|
+
import ContextInitializationHelper from './contexthelper.js';
|
|
38
2
|
export default class GirafeContext {
|
|
39
3
|
userDataManager;
|
|
40
4
|
configManager;
|
|
@@ -72,83 +36,11 @@ export default class GirafeContext {
|
|
|
72
36
|
themeFavoritesManager;
|
|
73
37
|
searchManager;
|
|
74
38
|
feedbackManager;
|
|
39
|
+
contextHelper = new ContextInitializationHelper();
|
|
75
40
|
constructor() {
|
|
76
|
-
this.
|
|
77
|
-
this.userDataManager = new UserDataManager(this);
|
|
78
|
-
this.configManager = new ConfigManager(this);
|
|
79
|
-
this.logManager = new LogManager(this);
|
|
80
|
-
this.stateManager = new StateManager(this);
|
|
81
|
-
this.orderingManager = new OrderingManager(this);
|
|
82
|
-
this.applicationLifeCycleManager = new ApplicationLifeCycleManager(this);
|
|
83
|
-
this.mapManager = new MapManager(this);
|
|
84
|
-
this.offlineManager = new OfflineManager(this);
|
|
85
|
-
this.snapManager = new SnapManager(this);
|
|
86
|
-
this.authManager = new AuthManager(this);
|
|
87
|
-
this.pluginManager = new PluginManager(this);
|
|
88
|
-
this.i18nManager = new I18nManager(this);
|
|
89
|
-
this.userInteractionManager = new UserInteractionManager(this);
|
|
90
|
-
this.urlManager = new UrlManager(this);
|
|
91
|
-
this.dragManager = new DragManager(this);
|
|
92
|
-
this.permalinkManager = new PermalinkManager(this);
|
|
93
|
-
this.layerManager = new LayerManager(this);
|
|
94
|
-
this.userLayerManager = new UserLayerManager(this);
|
|
95
|
-
this.themesHelper = new ThemesHelper(this);
|
|
96
|
-
this.stateSerializer = new StateSerializer(this);
|
|
97
|
-
this.sessionManager = new SessionManager(this);
|
|
98
|
-
this.shareManager = new ShareManager(this);
|
|
99
|
-
this.wfsManager = new WfsManager(this);
|
|
100
|
-
this.errorManager = new ErrorManager(this);
|
|
101
|
-
this.customThemesManager = new CustomThemesManager(this);
|
|
102
|
-
this.themesManager = new ThemesManager(this);
|
|
103
|
-
this.wmsManager = new WmsManager(this);
|
|
104
|
-
this.wmtsManager = new WmtsManager(this);
|
|
105
|
-
this.selectionManager = new SelectionManager(this);
|
|
106
|
-
this.localFileManager = new LocalFileManager(this);
|
|
107
|
-
this.ogcApiFeaturesManager = new OgcApiFeaturesManager(this);
|
|
108
|
-
this.onBoardingManager = new OnBoardingManager(this);
|
|
109
|
-
this.themeFavoritesManager = new ThemeFavoritesManager(this);
|
|
110
|
-
this.searchManager = new SearchManager(this);
|
|
111
|
-
this.feedbackManager = new FeedbackManager(this);
|
|
41
|
+
this.contextHelper.constructContext(this);
|
|
112
42
|
}
|
|
113
43
|
async initialize() {
|
|
114
|
-
|
|
115
|
-
this.componentManager.initializeSingleton();
|
|
116
|
-
this.userDataManager.initializeSingleton();
|
|
117
|
-
this.configManager.initializeSingleton();
|
|
118
|
-
await this.configManager.loadConfig();
|
|
119
|
-
this.logManager.initializeSingleton();
|
|
120
|
-
this.logManager.initLogging();
|
|
121
|
-
this.stateManager.initializeSingleton();
|
|
122
|
-
this.orderingManager.initializeSingleton();
|
|
123
|
-
this.applicationLifeCycleManager.initializeSingleton();
|
|
124
|
-
this.mapManager.initializeSingleton();
|
|
125
|
-
this.offlineManager.initializeSingleton();
|
|
126
|
-
this.snapManager.initializeSingleton();
|
|
127
|
-
this.authManager.initializeSingleton();
|
|
128
|
-
this.pluginManager.initializeSingleton();
|
|
129
|
-
this.i18nManager.initializeSingleton();
|
|
130
|
-
this.userInteractionManager.initializeSingleton();
|
|
131
|
-
this.dragManager.initializeSingleton();
|
|
132
|
-
this.urlManager.initializeSingleton();
|
|
133
|
-
this.permalinkManager.initializeSingleton();
|
|
134
|
-
this.layerManager.initializeSingleton();
|
|
135
|
-
this.userLayerManager.initializeSingleton();
|
|
136
|
-
this.themesHelper.initializeSingleton();
|
|
137
|
-
this.stateSerializer.initializeSingleton();
|
|
138
|
-
this.sessionManager.initializeSingleton();
|
|
139
|
-
this.shareManager.initializeSingleton();
|
|
140
|
-
this.wfsManager.initializeSingleton();
|
|
141
|
-
this.errorManager.initializeSingleton();
|
|
142
|
-
this.customThemesManager.initializeSingleton();
|
|
143
|
-
this.themesManager.initializeSingleton();
|
|
144
|
-
this.wmsManager.initializeSingleton();
|
|
145
|
-
this.wmtsManager.initializeSingleton();
|
|
146
|
-
this.localFileManager.initializeSingleton();
|
|
147
|
-
this.selectionManager.initializeSingleton();
|
|
148
|
-
this.ogcApiFeaturesManager.initializeSingleton();
|
|
149
|
-
this.onBoardingManager.initializeSingleton();
|
|
150
|
-
this.themeFavoritesManager.initializeSingleton();
|
|
151
|
-
this.searchManager.initializeSingleton();
|
|
152
|
-
this.feedbackManager.initializeSingleton();
|
|
44
|
+
await this.contextHelper.initializeContext(this);
|
|
153
45
|
}
|
|
154
46
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import IGirafeContext from './icontext.js';
|
|
2
|
+
export default class ContextInitializationHelper {
|
|
3
|
+
private readonly Managers;
|
|
4
|
+
constructContext(context: IGirafeContext, ignoreProperties?: string[]): void;
|
|
5
|
+
initializeContext(context: IGirafeContext): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import DragManager from '../../components/treeview/tools/dragmanager.js';
|
|
3
|
+
import ApplicationLifeCycleManager from '../app/lifecyclemanager.js';
|
|
4
|
+
import AuthManager from '../auth/authmanager.js';
|
|
5
|
+
import PluginManager from '../auth/pluginmanager.js';
|
|
6
|
+
import ConfigManager from '../configuration/configmanager.js';
|
|
7
|
+
import ErrorManager from '../error/errormanager.js';
|
|
8
|
+
import I18nManager from '../i18n/i18nmanager.js';
|
|
9
|
+
import LayerManager from '../layers/layermanager.js';
|
|
10
|
+
import SnapManager from '../layers/snapmanager.js';
|
|
11
|
+
import LocalFileManager from '../localfile/localfilemanager.js';
|
|
12
|
+
import LogManager from '../logging/logmanager.js';
|
|
13
|
+
import OfflineManager from '../offline/offlinemanager.js';
|
|
14
|
+
import OgcApiFeaturesManager from '../ogcapi/ogcapifeaturesmanager.js';
|
|
15
|
+
import OnBoardingManager from '../onboarding/onboardingmanager.js';
|
|
16
|
+
import OrderingManager from '../ordering/orderingmanager.js';
|
|
17
|
+
import SessionManager from '../share/sessionmanager.js';
|
|
18
|
+
import ShareManager from '../share/sharemanager.js';
|
|
19
|
+
import StateSerializer from '../share/stateserializer.js';
|
|
20
|
+
import ComponentManager from '../state/componentManager.js';
|
|
21
|
+
import MapManager from '../state/mapManager.js';
|
|
22
|
+
import StateManager from '../state/statemanager.js';
|
|
23
|
+
import UserInteractionManager from '../state/userInteractionManager.js';
|
|
24
|
+
import CustomThemesManager from '../themes/customthemesmanager.js';
|
|
25
|
+
import ThemesHelper from '../themes/themeshelper.js';
|
|
26
|
+
import ThemesManager from '../themes/themesmanager.js';
|
|
27
|
+
import UserLayerManager from '../themes/userlayermanager.js';
|
|
28
|
+
import PermalinkManager from '../url/permalinkmanager.js';
|
|
29
|
+
import UrlManager from '../url/urlmanager.js';
|
|
30
|
+
import UserDataManager from '../userdata/userdatamanager.js';
|
|
31
|
+
import WfsManager from '../wfs/wfsmanager.js';
|
|
32
|
+
import WmsManager from '../wms/wmsmanager.js';
|
|
33
|
+
import WmtsManager from '../wmts/wmtsmanager.js';
|
|
34
|
+
import SelectionManager from '../selection/selectionmanager.js';
|
|
35
|
+
import ThemeFavoritesManager from '../themes/themefavoritesmanager.js';
|
|
36
|
+
import SearchManager from '../search/searchmanager.js';
|
|
37
|
+
import FeedbackManager from '../feedback/feedbackmanager.js';
|
|
38
|
+
export default class ContextInitializationHelper {
|
|
39
|
+
// NOTE: This order is important, because the singletons will be initialized in this order
|
|
40
|
+
// And some singletons need other ones !
|
|
41
|
+
Managers = [
|
|
42
|
+
['componentManager', ComponentManager],
|
|
43
|
+
['userDataManager', UserDataManager],
|
|
44
|
+
['configManager', ConfigManager],
|
|
45
|
+
['logManager', LogManager],
|
|
46
|
+
['stateManager', StateManager],
|
|
47
|
+
['orderingManager', OrderingManager],
|
|
48
|
+
['applicationLifeCycleManager', ApplicationLifeCycleManager],
|
|
49
|
+
['mapManager', MapManager],
|
|
50
|
+
['offlineManager', OfflineManager],
|
|
51
|
+
['snapManager', SnapManager],
|
|
52
|
+
['authManager', AuthManager],
|
|
53
|
+
['pluginManager', PluginManager],
|
|
54
|
+
['i18nManager', I18nManager],
|
|
55
|
+
['userInteractionManager', UserInteractionManager],
|
|
56
|
+
['urlManager', UrlManager],
|
|
57
|
+
['dragManager', DragManager],
|
|
58
|
+
['permalinkManager', PermalinkManager],
|
|
59
|
+
['layerManager', LayerManager],
|
|
60
|
+
['userLayerManager', UserLayerManager],
|
|
61
|
+
['themesHelper', ThemesHelper],
|
|
62
|
+
['stateSerializer', StateSerializer],
|
|
63
|
+
['sessionManager', SessionManager],
|
|
64
|
+
['shareManager', ShareManager],
|
|
65
|
+
['wfsManager', WfsManager],
|
|
66
|
+
['errorManager', ErrorManager],
|
|
67
|
+
['customThemesManager', CustomThemesManager],
|
|
68
|
+
['themesManager', ThemesManager],
|
|
69
|
+
['wmsManager', WmsManager],
|
|
70
|
+
['wmtsManager', WmtsManager],
|
|
71
|
+
['selectionManager', SelectionManager],
|
|
72
|
+
['localFileManager', LocalFileManager],
|
|
73
|
+
['ogcApiFeaturesManager', OgcApiFeaturesManager],
|
|
74
|
+
['onBoardingManager', OnBoardingManager],
|
|
75
|
+
['themeFavoritesManager', ThemeFavoritesManager],
|
|
76
|
+
['searchManager', SearchManager],
|
|
77
|
+
['feedbackManager', FeedbackManager]
|
|
78
|
+
];
|
|
79
|
+
constructContext(context, ignoreProperties) {
|
|
80
|
+
// Create all singletons
|
|
81
|
+
for (const [name, ctor] of this.Managers) {
|
|
82
|
+
if (!ignoreProperties?.includes(name)) {
|
|
83
|
+
context[name] = new ctor(context);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async initializeContext(context) {
|
|
88
|
+
// Initialize all singletons
|
|
89
|
+
for (const [name] of this.Managers) {
|
|
90
|
+
// If there are some local Hook method that was defined,
|
|
91
|
+
// we call it instead of the default initializeSingleton() method.
|
|
92
|
+
const hook = context[`${name}Hook`];
|
|
93
|
+
if (hook) {
|
|
94
|
+
await hook.call(context);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Call the standard initializeSingleton() method.
|
|
98
|
+
await context[name].initializeSingleton();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GirafeSingleton from '../../base/GirafeSingleton.js';
|
|
2
2
|
declare class ErrorManager extends GirafeSingleton {
|
|
3
3
|
private sourceMaps;
|
|
4
|
-
initializeSingleton(): void
|
|
4
|
+
initializeSingleton(): Promise<void>;
|
|
5
5
|
private getErrorMessage;
|
|
6
6
|
pushMessage(id: string, text: string, level: 'info' | 'warning' | 'error'): void;
|
|
7
7
|
private listenToAllErrors;
|
|
@@ -5,7 +5,7 @@ import ErrorStackParser from 'error-stack-parser';
|
|
|
5
5
|
import { SourceMapConsumer } from 'source-map-js';
|
|
6
6
|
class ErrorManager extends GirafeSingleton {
|
|
7
7
|
sourceMaps = {};
|
|
8
|
-
initializeSingleton() {
|
|
8
|
+
async initializeSingleton() {
|
|
9
9
|
this.listenToAllErrors();
|
|
10
10
|
}
|
|
11
11
|
getErrorMessage(title, stack, contextUrl) {
|
|
@@ -8,8 +8,7 @@ declare class FeedbackManager extends GirafeSingleton {
|
|
|
8
8
|
private get config();
|
|
9
9
|
private readonly STORAGE_PATH;
|
|
10
10
|
private gaveFeedbackFor;
|
|
11
|
-
initializeSingleton(): void
|
|
12
|
-
resetGivenFeedback(): void;
|
|
11
|
+
initializeSingleton(): Promise<void>;
|
|
13
12
|
giveFeedback(componentName: string, feedbackResult: FeedbackResult): Promise<void>;
|
|
14
13
|
private initializeFeedbackOnComponents;
|
|
15
14
|
}
|
|
@@ -14,17 +14,15 @@ class FeedbackManager extends GirafeSingleton {
|
|
|
14
14
|
}
|
|
15
15
|
STORAGE_PATH = 'alreadyGaveFeedbackFor';
|
|
16
16
|
gaveFeedbackFor = {};
|
|
17
|
-
initializeSingleton() {
|
|
18
|
-
super.initializeSingleton();
|
|
17
|
+
async initializeSingleton() {
|
|
18
|
+
await super.initializeSingleton();
|
|
19
19
|
this.context.componentManager.registerComponentCallback(TreeViewRootComponent, () => {
|
|
20
20
|
console.log('FeedbackManager: TreeViewRootComponent registered');
|
|
21
21
|
this.initializeFeedbackOnComponents();
|
|
22
22
|
});
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.gaveFeedbackFor = {};
|
|
27
|
-
this.context.userDataManager.saveUserData(this.STORAGE_PATH, this.gaveFeedbackFor);
|
|
23
|
+
this.context.userDataManager.getUserData(this.STORAGE_PATH).then((gaveFeedbackFor) => {
|
|
24
|
+
this.gaveFeedbackFor = gaveFeedbackFor || {};
|
|
25
|
+
});
|
|
28
26
|
}
|
|
29
27
|
async giveFeedback(componentName, feedbackResult) {
|
|
30
28
|
const url = this.config.feedback?.url;
|
|
@@ -49,7 +47,7 @@ class FeedbackManager extends GirafeSingleton {
|
|
|
49
47
|
const result = await response.json();
|
|
50
48
|
console.log('Success:', result);
|
|
51
49
|
this.gaveFeedbackFor[componentName] = true;
|
|
52
|
-
this.context.userDataManager.saveUserData(this.STORAGE_PATH, this.gaveFeedbackFor);
|
|
50
|
+
await this.context.userDataManager.saveUserData(this.STORAGE_PATH, this.gaveFeedbackFor);
|
|
53
51
|
}
|
|
54
52
|
catch (error) {
|
|
55
53
|
console.error('Error:', error);
|
|
@@ -15,7 +15,7 @@ declare class I18nManager extends GirafeSingleton {
|
|
|
15
15
|
private readonly translationAliases;
|
|
16
16
|
private loadingLanguagePromise;
|
|
17
17
|
constructor(context: IGirafeContext);
|
|
18
|
-
initializeSingleton(): void
|
|
18
|
+
initializeSingleton(): Promise<void>;
|
|
19
19
|
private formatNumber;
|
|
20
20
|
ensureTranslationLoaded(): Promise<boolean>;
|
|
21
21
|
private loadTranslations;
|
|
@@ -7,7 +7,7 @@ class I18nManager extends GirafeSingleton {
|
|
|
7
7
|
constructor(context) {
|
|
8
8
|
super(context);
|
|
9
9
|
}
|
|
10
|
-
initializeSingleton() {
|
|
10
|
+
async initializeSingleton() {
|
|
11
11
|
this.context.stateManager.subscribe('language', () => this.handleLanguageChange());
|
|
12
12
|
this.handleLanguageChange();
|
|
13
13
|
}
|
|
@@ -38,27 +38,29 @@ class I18nManager extends GirafeSingleton {
|
|
|
38
38
|
// => stop here
|
|
39
39
|
return this.translations[language];
|
|
40
40
|
}
|
|
41
|
+
const translationFiles = this.context.configManager.Config.languages.translations;
|
|
42
|
+
if (!translationFiles || !(language in translationFiles)) {
|
|
43
|
+
throw new Error('No languages found in config.json');
|
|
44
|
+
}
|
|
41
45
|
// Load translations
|
|
42
|
-
this.loadingLanguagePromise =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const content = await response.json();
|
|
51
|
-
mergedTranslations = { ...mergedTranslations, ...content[language] };
|
|
52
|
-
}
|
|
53
|
-
this.translations[language] = mergedTranslations;
|
|
54
|
-
this.loadingLanguagePromise = null;
|
|
55
|
-
return this.translations[language];
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw new Error('No languages found in config.json');
|
|
46
|
+
this.loadingLanguagePromise = (async () => {
|
|
47
|
+
let mergedTranslations = this.translations[language] ?? {};
|
|
48
|
+
// Translations are loaded in the order defined in the list of files
|
|
49
|
+
// If an element is present in both results, the last value overwrite all the others
|
|
50
|
+
for (const url of this.context.configManager.Config.languages.translations[language]) {
|
|
51
|
+
const response = await fetch(url);
|
|
52
|
+
const content = await response.json();
|
|
53
|
+
mergedTranslations = { ...mergedTranslations, ...content[language] };
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
this.translations[language] = mergedTranslations;
|
|
56
|
+
return this.translations[language];
|
|
57
|
+
})();
|
|
58
|
+
try {
|
|
59
|
+
return await this.loadingLanguagePromise;
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
this.loadingLanguagePromise = null;
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
getTranslation(key) {
|
|
64
66
|
const currentLanguage = this.context.stateManager?.state?.language ?? 'en';
|
|
@@ -9,7 +9,7 @@ declare class LayerManager extends GirafeSingleton {
|
|
|
9
9
|
private readonly layerClones;
|
|
10
10
|
private readonly layerIdToClone;
|
|
11
11
|
private get state();
|
|
12
|
-
initializeSingleton(): void
|
|
12
|
+
initializeSingleton(): Promise<void>;
|
|
13
13
|
private onLayersListChanged;
|
|
14
14
|
private fillLayerIdToClone;
|
|
15
15
|
protected onChildrenListChanged(oldChildren: BaseLayer[], newChildren: BaseLayer[]): void;
|
|
@@ -9,7 +9,7 @@ class LayerManager extends GirafeSingleton {
|
|
|
9
9
|
get state() {
|
|
10
10
|
return this.context.stateManager.state;
|
|
11
11
|
}
|
|
12
|
-
initializeSingleton() {
|
|
12
|
+
async initializeSingleton() {
|
|
13
13
|
this.context.stateManager.subscribe(/layers\.layersList\..*\.activeState/, (_oldActive, _newActive, layer) => this.onLayerToggled(layer));
|
|
14
14
|
this.context.stateManager.subscribe('layers.layersList', (oldLayers, newLayers) => this.onLayersListChanged(oldLayers, newLayers));
|
|
15
15
|
this.context.stateManager.subscribe(/layers\.layersList\..*\.children/, (oldChildren, newChildren) => this.onChildrenListChanged(oldChildren, newChildren));
|
|
@@ -4,7 +4,7 @@ declare class SnapManager extends GirafeSingleton {
|
|
|
4
4
|
private inactiveSnapLayers;
|
|
5
5
|
private get olMap();
|
|
6
6
|
private get state();
|
|
7
|
-
initializeSingleton(): void
|
|
7
|
+
initializeSingleton(): Promise<void>;
|
|
8
8
|
private mapInteractionsChanged;
|
|
9
9
|
private activateSnappingForAllLayers;
|
|
10
10
|
private deactivateSnappingForAllLayers;
|
|
@@ -13,7 +13,7 @@ class SnapManager extends GirafeSingleton {
|
|
|
13
13
|
get state() {
|
|
14
14
|
return this.context.stateManager.state;
|
|
15
15
|
}
|
|
16
|
-
initializeSingleton() {
|
|
16
|
+
async initializeSingleton() {
|
|
17
17
|
this.context.stateManager.subscribe(/layers\.layersList\..*\.activeState/, (_oldActive, _newActive, layer) => {
|
|
18
18
|
this.layerUpdated(layer);
|
|
19
19
|
});
|
|
@@ -13,7 +13,7 @@ declare class LocalFileManager extends GirafeSingleton {
|
|
|
13
13
|
private activeLayers;
|
|
14
14
|
private readonly featureLayerMap;
|
|
15
15
|
constructor(context: IGirafeContext);
|
|
16
|
-
initializeSingleton(): void
|
|
16
|
+
initializeSingleton(): Promise<void>;
|
|
17
17
|
private registerEvents;
|
|
18
18
|
private createInteraction;
|
|
19
19
|
loadLocalFile(localFile: File): Promise<void>;
|
|
@@ -25,7 +25,7 @@ class LocalFileManager extends GirafeSingleton {
|
|
|
25
25
|
this.map = this.context.mapManager.getMap();
|
|
26
26
|
this.name = `localFileManager`;
|
|
27
27
|
}
|
|
28
|
-
initializeSingleton() {
|
|
28
|
+
async initializeSingleton() {
|
|
29
29
|
this.registerEvents();
|
|
30
30
|
// Add drag n drop interaction to add local files
|
|
31
31
|
const dragAndDropInteraction = this.createInteraction();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class DefaultConsole {
|
|
2
|
+
static readonly debug: typeof console.debug;
|
|
3
|
+
static readonly log: typeof console.log;
|
|
4
|
+
static readonly info: typeof console.info;
|
|
5
|
+
static readonly warn: typeof console.warn;
|
|
6
|
+
static readonly error: typeof console.error;
|
|
7
|
+
static readonly assert: typeof console.assert;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
export default class DefaultConsole {
|
|
3
|
+
static debug = console.debug;
|
|
4
|
+
static log = console.log;
|
|
5
|
+
static info = console.info;
|
|
6
|
+
static warn = console.warn;
|
|
7
|
+
static error = console.error;
|
|
8
|
+
static assert = console.assert;
|
|
9
|
+
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import GirafeSingleton from '../../base/GirafeSingleton.js';
|
|
2
2
|
export default class LogManager extends GirafeSingleton {
|
|
3
|
-
|
|
4
|
-
private readonly defaultLog;
|
|
5
|
-
private readonly defaultInfo;
|
|
6
|
-
private readonly defaultWarn;
|
|
7
|
-
private readonly defaultError;
|
|
8
|
-
private readonly defaultAssert;
|
|
9
|
-
initLogging(): void;
|
|
3
|
+
initializeSingleton(): Promise<void>;
|
|
10
4
|
/**
|
|
11
5
|
* Write log to output if the current loglevel is debug, info, warn or error
|
|
12
6
|
* @returns true if the log was written, false instead
|