@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
|
@@ -10,110 +10,146 @@ import { createObjectFromPath, deletePropertyByPath, getPropertyByPath, setPrope
|
|
|
10
10
|
class UserDataManager extends GirafeSingleton {
|
|
11
11
|
// Using the full URL as storage key allows having separate user data for apps under the same base URL (e.g. demo apps)
|
|
12
12
|
storageKey = window.location.origin + window.location.pathname;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (source === 'localStorage' || source === 'server') {
|
|
18
|
-
this.source = source;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
console.warn(`User data source "${source}" not known`);
|
|
22
|
-
}
|
|
13
|
+
config;
|
|
14
|
+
allowSaveUserPreferences = true;
|
|
15
|
+
initializeFromConfig(config) {
|
|
16
|
+
this.config = config;
|
|
23
17
|
}
|
|
18
|
+
userData;
|
|
19
|
+
userDataPromise;
|
|
24
20
|
/**
|
|
25
21
|
* Retrieves a specific part of the user data defined by the storage path.
|
|
26
22
|
* @param storagePath path in the user data object to the requested value.
|
|
27
|
-
* @param forceLocalStorage if true, reads user data from the local storage, ignoring the source.
|
|
28
23
|
* @returns the partial user data object.
|
|
29
24
|
*/
|
|
30
|
-
getUserData(storagePath
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
async getUserData(storagePath) {
|
|
26
|
+
if (this.userData) {
|
|
27
|
+
// User Data were already loaded
|
|
28
|
+
return this.extractValue(this.userData, storagePath);
|
|
29
|
+
}
|
|
30
|
+
this.userDataPromise = this.load().catch((error) => {
|
|
31
|
+
this.userDataPromise = undefined;
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
this.userData = await this.userDataPromise;
|
|
35
|
+
return this.extractValue(this.userData, storagePath);
|
|
36
|
+
}
|
|
37
|
+
getFromLocalStorage(storagePath) {
|
|
38
|
+
const storedUserData = localStorage.getItem(this.storageKey);
|
|
39
|
+
const userData = storedUserData ? JSON.parse(storedUserData) : {};
|
|
40
|
+
return this.extractValue(userData, storagePath);
|
|
41
|
+
}
|
|
42
|
+
extractValue(data, storagePath) {
|
|
43
|
+
const { found, parentObject, lastKey } = getPropertyByPath(data, storagePath);
|
|
33
44
|
return found && parentObject && lastKey ? parentObject[lastKey] : undefined;
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
async load() {
|
|
47
|
+
if (this.config.source === 'localStorage') {
|
|
48
|
+
return this.loadFromLocalStorage();
|
|
49
|
+
}
|
|
50
|
+
else if (this.config.source === 'server') {
|
|
51
|
+
const userdata = await this.loadFromServer();
|
|
52
|
+
return userdata;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Unknown source for user preferences: ${this.config.source}`);
|
|
55
|
+
}
|
|
56
|
+
loadFromLocalStorage() {
|
|
57
|
+
const storedUserData = localStorage.getItem(this.storageKey);
|
|
58
|
+
return storedUserData ? JSON.parse(storedUserData) : {};
|
|
59
|
+
}
|
|
60
|
+
async loadFromServer() {
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(this.config.getUrl);
|
|
63
|
+
const storedUserData = await response.json();
|
|
64
|
+
return storedUserData;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Cannot load user preference from server.
|
|
68
|
+
// In this case, we deactivate the save process for user preferences
|
|
69
|
+
// (because we do not want to override the existing user-preferences if they could not be loaded for some reason)
|
|
70
|
+
// And we return empty preferences, because we want to be able to start the application
|
|
71
|
+
// even if the user preferences could not be retrieved.
|
|
72
|
+
this.allowSaveUserPreferences = false;
|
|
73
|
+
this.context.errorManager.pushMessage('loadUserPreferencesError', 'User Preferences could not be loaded. Try refreshing the page or contact your administrator.', 'error');
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async saveUserData(storagePath, newValue) {
|
|
78
|
+
if (!getPropertyByPath(this.userData, storagePath).found) {
|
|
79
|
+
// Object does not exist in user data yet, create it
|
|
80
|
+
const newUserData = createObjectFromPath(storagePath);
|
|
81
|
+
this.userData = mergeObjects(this.userData ?? {}, newUserData);
|
|
82
|
+
}
|
|
83
|
+
if (setPropertyByPath(this.userData, storagePath, newValue)) {
|
|
84
|
+
await this.save(this.userData ?? {});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
saveToLocalStorage(storagePath, newValue) {
|
|
88
|
+
let fullUserDataObject = this.loadFromLocalStorage();
|
|
43
89
|
if (!getPropertyByPath(fullUserDataObject, storagePath).found) {
|
|
44
90
|
// Object does not exist in user data yet, create it
|
|
45
91
|
const newUserData = createObjectFromPath(storagePath);
|
|
46
92
|
fullUserDataObject = mergeObjects(fullUserDataObject, newUserData);
|
|
47
93
|
}
|
|
48
94
|
if (setPropertyByPath(fullUserDataObject, storagePath, newValue)) {
|
|
49
|
-
this.
|
|
95
|
+
this.writeToLocalStorage(fullUserDataObject);
|
|
50
96
|
}
|
|
51
97
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* @param forceLocalStorage if true, deletes user data in the local storage, ignoring the source.
|
|
56
|
-
*/
|
|
57
|
-
deleteUserData(storagePath, forceLocalStorage = false) {
|
|
58
|
-
const currentUserData = this.load(forceLocalStorage);
|
|
59
|
-
deletePropertyByPath(currentUserData, storagePath);
|
|
60
|
-
this.save(currentUserData, forceLocalStorage);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Deletes all user data in storage.
|
|
64
|
-
* @param forceLocalStorage Force deletion from local storage regardless of the currently set data source.
|
|
65
|
-
*/
|
|
66
|
-
deleteAllUserData(forceLocalStorage = false) {
|
|
67
|
-
if (this.isInLocalStorage(forceLocalStorage)) {
|
|
68
|
-
localStorage.removeItem(this.storageKey);
|
|
98
|
+
async save(fullUserDataObject) {
|
|
99
|
+
if (this.config.source === 'localStorage') {
|
|
100
|
+
this.writeToLocalStorage(fullUserDataObject);
|
|
69
101
|
}
|
|
70
|
-
else if (this.source === 'server') {
|
|
71
|
-
|
|
102
|
+
else if (this.config.source === 'server') {
|
|
103
|
+
await this.writeToServer(fullUserDataObject);
|
|
72
104
|
}
|
|
73
105
|
else {
|
|
74
|
-
|
|
106
|
+
throw new Error(`Unknown source for user preferences: ${this.config.source}`);
|
|
75
107
|
}
|
|
76
108
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (this.isInLocalStorage(forceLocalStorage)) {
|
|
84
|
-
const storedUserData = localStorage.getItem(this.storageKey);
|
|
85
|
-
return storedUserData ? JSON.parse(storedUserData) : {};
|
|
109
|
+
writeToLocalStorage(fullUserDataObject) {
|
|
110
|
+
localStorage.setItem(this.storageKey, JSON.stringify(fullUserDataObject));
|
|
111
|
+
}
|
|
112
|
+
async writeToServer(fullUserDataObject) {
|
|
113
|
+
if (!this.allowSaveUserPreferences) {
|
|
114
|
+
return;
|
|
86
115
|
}
|
|
87
|
-
|
|
88
|
-
|
|
116
|
+
const response = await fetch(this.config.postUrl, {
|
|
117
|
+
method: 'POST',
|
|
118
|
+
headers: { 'Content-Type': 'application/json' },
|
|
119
|
+
body: JSON.stringify(fullUserDataObject)
|
|
120
|
+
});
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
console.error(response.text);
|
|
123
|
+
throw new Error(`Error while saving user preferences: ${response.status}`);
|
|
89
124
|
}
|
|
90
|
-
else {
|
|
91
|
-
console.warn(this.WARNING_UNKNOWN_SOURCE);
|
|
92
|
-
}
|
|
93
|
-
return {};
|
|
94
125
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
localStorage.setItem(this.storageKey, JSON.stringify(fullUserDataObject));
|
|
126
|
+
async deleteUserData(storagePath) {
|
|
127
|
+
deletePropertyByPath(this.userData, storagePath);
|
|
128
|
+
await this.save(this.userData);
|
|
129
|
+
}
|
|
130
|
+
async deleteAllUserData() {
|
|
131
|
+
this.userData = undefined;
|
|
132
|
+
if (this.config.source === 'localStorage') {
|
|
133
|
+
localStorage.removeItem(this.storageKey);
|
|
104
134
|
}
|
|
105
|
-
else if (this.source === 'server') {
|
|
106
|
-
|
|
135
|
+
else if (this.config.source === 'server') {
|
|
136
|
+
await this.deleteFromServer();
|
|
107
137
|
}
|
|
108
138
|
else {
|
|
109
|
-
|
|
139
|
+
throw new Error(`Unknown source for user preferences: ${this.config.source}`);
|
|
110
140
|
}
|
|
111
141
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
142
|
+
async deleteFromServer() {
|
|
143
|
+
if (!this.allowSaveUserPreferences) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const response = await fetch(this.config.postUrl, {
|
|
147
|
+
method: 'DELETE'
|
|
148
|
+
});
|
|
149
|
+
if (!response.ok) {
|
|
150
|
+
console.error(response.text);
|
|
151
|
+
throw new Error(`Error while deleting user preferences: ${response.status}`);
|
|
152
|
+
}
|
|
117
153
|
}
|
|
118
154
|
}
|
|
119
155
|
export default UserDataManager;
|
|
@@ -8,7 +8,7 @@ export default class WfsManager extends VendorSpecificOgcServerManager<WfsClient
|
|
|
8
8
|
private get state();
|
|
9
9
|
getClientId(ogcServer: ServerOgc): string;
|
|
10
10
|
static readonly UnknownFeatureType: string;
|
|
11
|
-
initializeSingleton(): void
|
|
11
|
+
initializeSingleton(): Promise<void>;
|
|
12
12
|
private onSelectedFeaturesFilterChange;
|
|
13
13
|
/**
|
|
14
14
|
* Determines whether the specified layer is the first active child layer of a time-aware group layer,
|
package/tools/wfs/wfsmanager.js
CHANGED
|
@@ -10,7 +10,7 @@ export default class WfsManager extends VendorSpecificOgcServerManager {
|
|
|
10
10
|
return ogcServer.urlWfs ?? '';
|
|
11
11
|
}
|
|
12
12
|
static UnknownFeatureType = 'UNKNOWN';
|
|
13
|
-
initializeSingleton() {
|
|
13
|
+
async initializeSingleton() {
|
|
14
14
|
this.context.stateManager.subscribe(/layers\.layersList\..*\.filter/, (_oldFilter, newFilter) => {
|
|
15
15
|
void this.onSelectedFeaturesFilterChange(newFilter);
|
|
16
16
|
});
|
|
@@ -8,7 +8,7 @@ import IGirafeContext from '../context/icontext.js';
|
|
|
8
8
|
export default class WmsManager extends VendorSpecificOgcServerManager<WmsClient, OlMap> {
|
|
9
9
|
private readonly map;
|
|
10
10
|
constructor(context: IGirafeContext);
|
|
11
|
-
initializeSingleton(): void
|
|
11
|
+
initializeSingleton(): Promise<void>;
|
|
12
12
|
getClientId(ogcServer: ServerOgc): string;
|
|
13
13
|
createClient(clientClass: new (os: ServerOgc, map: OlMap, context: IGirafeContext) => WmsClient, ogcServer: ServerOgc): WmsClient;
|
|
14
14
|
selectFeatures(extent: number[]): void;
|
package/tools/wms/wmsmanager.js
CHANGED
|
@@ -6,7 +6,7 @@ export default class WmsManager extends VendorSpecificOgcServerManager {
|
|
|
6
6
|
super(context);
|
|
7
7
|
this.map = this.context.mapManager.getMap();
|
|
8
8
|
}
|
|
9
|
-
initializeSingleton() {
|
|
9
|
+
async initializeSingleton() {
|
|
10
10
|
// Register the default client
|
|
11
11
|
this.registerClientClass('default', WmsClientDefault);
|
|
12
12
|
this.registerClientClass('geoserver', WmsClientGeoServer);
|