@geogirafe/lib-geoportal 1.2.0-dev.2872463389 → 1.2.0-dev.2889263072
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/GirafeDraggableElement.js +2 -2
- package/base/GirafeResizableElement.js +4 -4
- package/base/GirafeSingleton.d.ts +1 -1
- package/base/GirafeSingleton.js +1 -1
- package/components/basemap/component.js +1 -1
- package/components/cross-section/cross-section-settings/component.js +1 -1
- package/components/cross-section/scatterplot.js +1 -1
- package/components/drawing/component-mobile.js +1 -1
- package/components/drawing/component.js +4 -4
- package/components/drawing/fixed-dimension/component.js +1 -1
- package/components/edit/component.js +1 -1
- package/components/edit/editform/component.js +1 -1
- package/components/extlayers/component.js +1 -1
- package/components/map-2d/component.js +1 -1
- package/components/map-2d/tools/swipemanager.js +2 -2
- package/components/modals/component.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/print/component.js +7 -7
- package/components/print/tools/MFPLegendEncoder.js +1 -1
- package/components/querybuilder/component.js +2 -2
- package/components/scale/component.js +1 -1
- package/components/selectionwindow/component.js +1 -1
- package/components/share/component.js +1 -1
- package/components/themes/component.d.ts +1 -1
- package/components/themes/component.js +4 -4
- package/components/themes-mobile/layer-selected/component.js +1 -1
- package/components/timerestriction/timepicker/component.js +1 -1
- package/components/timerestriction/timeslider/component.js +4 -4
- package/components/treeview/treeviewroot/component.js +1 -1
- package/components/userpreferences/component.d.ts +1 -1
- package/components/userpreferences/component.js +7 -7
- package/models/xmlTypes.js +1 -1
- 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 +6 -5
- package/tools/configuration/girafeconfig.js +3 -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/resizewindow.js +6 -6
- 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/time/layertimeformatter.js +1 -1
- 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
|
@@ -272,12 +272,12 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
272
272
|
/**
|
|
273
273
|
Update state and local storage with new value
|
|
274
274
|
*/
|
|
275
|
-
changePreference(preferenceKey, newValue) {
|
|
275
|
+
async changePreference(preferenceKey, newValue) {
|
|
276
276
|
if (this.preferences[preferenceKey]) {
|
|
277
277
|
this.preferences[preferenceKey].currentValue = newValue;
|
|
278
278
|
this.updatePreferenceInConfig(preferenceKey);
|
|
279
279
|
this.updatePreferenceInState(preferenceKey);
|
|
280
|
-
this.updatePreferenceInStorage(preferenceKey);
|
|
280
|
+
await this.updatePreferenceInStorage(preferenceKey);
|
|
281
281
|
this.refreshRender();
|
|
282
282
|
}
|
|
283
283
|
}
|
|
@@ -300,10 +300,10 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
300
300
|
/**
|
|
301
301
|
Save the user preference as a config override in user data storage
|
|
302
302
|
*/
|
|
303
|
-
updatePreferenceInStorage(preferenceKey) {
|
|
303
|
+
async updatePreferenceInStorage(preferenceKey) {
|
|
304
304
|
const preference = this.preferences[preferenceKey];
|
|
305
305
|
// Values are saved under 'configOverrides' in the same structure as in the config
|
|
306
|
-
this.context.userDataManager.saveUserData(`${this.storagePath}.${preference.configPath}`, preference.currentValue);
|
|
306
|
+
await this.context.userDataManager.saveUserData(`${this.storagePath}.${preference.configPath}`, preference.currentValue);
|
|
307
307
|
}
|
|
308
308
|
/**
|
|
309
309
|
* Reset user preferences back to defaults. This will delete the configOverrides object in storage and set the
|
|
@@ -312,11 +312,11 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
312
312
|
async onResetAll() {
|
|
313
313
|
const confirm = await window.gConfirm('Reset user preferences back to default values?', 'Reset preferences');
|
|
314
314
|
if (confirm) {
|
|
315
|
-
this.resetAll();
|
|
315
|
+
await this.resetAll();
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
resetAll() {
|
|
319
|
-
this.context.userDataManager.deleteUserData(this.storagePath);
|
|
318
|
+
async resetAll() {
|
|
319
|
+
await this.context.userDataManager.deleteUserData(this.storagePath);
|
|
320
320
|
for (const preferenceKey in this.preferences) {
|
|
321
321
|
this.preferences[preferenceKey].currentValue = this.context.configManager.getDefaultConfigValue(this.preferences[preferenceKey].configPath);
|
|
322
322
|
this.updatePreferenceInState(preferenceKey);
|
package/models/xmlTypes.js
CHANGED
|
@@ -40,7 +40,7 @@ export const xmlTypesStrList = [
|
|
|
40
40
|
...xmlGeometryTypesStrList
|
|
41
41
|
];
|
|
42
42
|
export function isStringNumeric(str) {
|
|
43
|
-
return str.trim().length > 0 && !isNaN(Number(str)); // ensure strings of whitespace fail or mixed chars and numbers like '2n'
|
|
43
|
+
return str.trim().length > 0 && !Number.isNaN(Number(str)); // ensure strings of whitespace fail or mixed chars and numbers like '2n'
|
|
44
44
|
}
|
|
45
45
|
export function isString(attributeType) {
|
|
46
46
|
return xmlStringTypesStrList.includes(attributeType);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.2.0-dev.
|
|
1
|
+
{"version":"1.2.0-dev.2889263072", "build":"2889263072", "date":"28/09/2026"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GirafeSingleton from '../../base/GirafeSingleton.js';
|
|
2
2
|
export default class ApplicationLifeCycleManager extends GirafeSingleton {
|
|
3
3
|
private get state();
|
|
4
|
-
initializeSingleton(): void
|
|
4
|
+
initializeSingleton(): Promise<void>;
|
|
5
5
|
private log;
|
|
6
6
|
/**
|
|
7
7
|
* For the application to be ready to load the themes and to deserialize the shared state or the session,
|
|
@@ -4,7 +4,7 @@ export default class ApplicationLifeCycleManager extends GirafeSingleton {
|
|
|
4
4
|
get state() {
|
|
5
5
|
return this.context.stateManager.state;
|
|
6
6
|
}
|
|
7
|
-
initializeSingleton() {
|
|
7
|
+
async initializeSingleton() {
|
|
8
8
|
this.context.stateManager.subscribe('themes.isLoaded', (_, isThemesLoaded) => {
|
|
9
9
|
this.log(isThemesLoaded, 'Themes are loaded');
|
|
10
10
|
this.checkApplicationReady();
|
|
@@ -60,10 +60,10 @@ export default class AbstractConnectManager {
|
|
|
60
60
|
return url.toString();
|
|
61
61
|
}
|
|
62
62
|
loadFromLocalStorage(path) {
|
|
63
|
-
return this.context.userDataManager.
|
|
63
|
+
return this.context.userDataManager.getFromLocalStorage(`${this.storagePath}.${path}`) ?? '';
|
|
64
64
|
}
|
|
65
65
|
saveToLocalStorage(path, value) {
|
|
66
|
-
|
|
66
|
+
this.context.userDataManager.saveToLocalStorage(`${this.storagePath}.${path}`, value);
|
|
67
67
|
}
|
|
68
68
|
resetUrl() {
|
|
69
69
|
const url = new URL(this.context.urlManager.getBaseUrlPath());
|
|
@@ -6,7 +6,7 @@ export default class AuthManager extends GirafeSingleton {
|
|
|
6
6
|
private readonly gmfManager;
|
|
7
7
|
private get state();
|
|
8
8
|
constructor(context: IGirafeContext);
|
|
9
|
-
initializeSingleton(): void
|
|
9
|
+
initializeSingleton(): Promise<void>;
|
|
10
10
|
initialize(sw: ServiceWorker | null): Promise<void>;
|
|
11
11
|
private initializeOAuth;
|
|
12
12
|
private initializeGmfAuth;
|
|
@@ -15,7 +15,7 @@ export default class AuthManager extends GirafeSingleton {
|
|
|
15
15
|
super(context);
|
|
16
16
|
this.gmfManager = new GMFManager(this.context);
|
|
17
17
|
}
|
|
18
|
-
initializeSingleton() {
|
|
18
|
+
async initializeSingleton() {
|
|
19
19
|
this.context.stateManager.subscribe('oauth.status', () => this.loginStateChanged());
|
|
20
20
|
this.context.stateManager.subscribe('oauth.tokens', () => this.tokensChanged());
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import GirafeSingleton from '../../base/GirafeSingleton.js';
|
|
2
2
|
declare class PluginManager extends GirafeSingleton {
|
|
3
|
-
initializeSingleton(): void
|
|
3
|
+
initializeSingleton(): Promise<void>;
|
|
4
4
|
filterPlugins(dom: DocumentFragment | Document): void;
|
|
5
5
|
private filterPluginFromConfig;
|
|
6
6
|
private filterPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import GirafeSingleton from '../../base/GirafeSingleton.js';
|
|
3
3
|
class PluginManager extends GirafeSingleton {
|
|
4
|
-
initializeSingleton() {
|
|
4
|
+
async initializeSingleton() {
|
|
5
5
|
this.context.stateManager.subscribe('oauth.userInfo', () => this.filterPlugins(document));
|
|
6
6
|
this.filterPlugins(document);
|
|
7
7
|
}
|
|
@@ -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 {
|
|
@@ -243,11 +248,7 @@ declare class GirafeConfig {
|
|
|
243
248
|
refererPolicy: ReferrerPolicy;
|
|
244
249
|
};
|
|
245
250
|
};
|
|
246
|
-
userdata:
|
|
247
|
-
source: 'localStorage' | 'server';
|
|
248
|
-
getUrl: string | undefined;
|
|
249
|
-
postUrl: string | undefined;
|
|
250
|
-
};
|
|
251
|
+
userdata: UserDataConfig;
|
|
251
252
|
contact?: {
|
|
252
253
|
url: string;
|
|
253
254
|
reasons: string[];
|
|
@@ -466,6 +466,9 @@ class GirafeConfig {
|
|
|
466
466
|
const defaultConfig = {
|
|
467
467
|
source: 'localStorage'
|
|
468
468
|
};
|
|
469
|
+
if (config.userdata?.source === 'server' && (!config.userdata?.getUrl || !config.userdata?.postUrl)) {
|
|
470
|
+
throw new Error(`Configuration userdata.getUrl or userdata.postUrl is missing. See https://doc.geogirafe.org/docs/configuration.`);
|
|
471
|
+
}
|
|
469
472
|
return {
|
|
470
473
|
...defaultConfig,
|
|
471
474
|
...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));
|