@itwin/map-layers 5.3.0 → 5.4.0
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/CHANGELOG.md +25 -2
- package/lib/cjs/BrowserStorage.d.ts +25 -0
- package/lib/cjs/BrowserStorage.d.ts.map +1 -0
- package/lib/cjs/BrowserStorage.js +80 -0
- package/lib/cjs/BrowserStorage.js.map +1 -0
- package/lib/cjs/CustomParamUtils.d.ts +5 -0
- package/lib/cjs/CustomParamUtils.d.ts.map +1 -0
- package/lib/cjs/CustomParamUtils.js +26 -0
- package/lib/cjs/CustomParamUtils.js.map +1 -0
- package/lib/cjs/CustomParamsMappingStorage.d.ts +6 -0
- package/lib/cjs/CustomParamsMappingStorage.d.ts.map +1 -0
- package/lib/cjs/CustomParamsMappingStorage.js +15 -0
- package/lib/cjs/CustomParamsMappingStorage.js.map +1 -0
- package/lib/cjs/CustomParamsStorage.d.ts +6 -0
- package/lib/cjs/CustomParamsStorage.d.ts.map +1 -0
- package/lib/cjs/CustomParamsStorage.js +15 -0
- package/lib/cjs/CustomParamsStorage.js.map +1 -0
- package/lib/cjs/MapLayerPreferences.d.ts.map +1 -1
- package/lib/cjs/MapLayerPreferences.js +2 -0
- package/lib/cjs/MapLayerPreferences.js.map +1 -1
- package/lib/cjs/PreferencesBrowserStorage.d.ts +9 -2
- package/lib/cjs/PreferencesBrowserStorage.d.ts.map +1 -1
- package/lib/cjs/PreferencesBrowserStorage.js +11 -51
- package/lib/cjs/PreferencesBrowserStorage.js.map +1 -1
- package/lib/cjs/public/locales/en/mapLayers.json +29 -3
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.d.ts +1 -1
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +1 -1
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/cjs/ui/Interfaces.d.ts +11 -0
- package/lib/cjs/ui/Interfaces.d.ts.map +1 -1
- package/lib/cjs/ui/Interfaces.js.map +1 -1
- package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js +20 -18
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/CustomParamEditDialog.d.ts +11 -0
- package/lib/cjs/ui/widget/CustomParamEditDialog.d.ts.map +1 -0
- package/lib/cjs/ui/widget/CustomParamEditDialog.js +57 -0
- package/lib/cjs/ui/widget/CustomParamEditDialog.js.map +1 -0
- package/lib/cjs/ui/widget/CustomParamEditDialog.scss +26 -0
- package/lib/cjs/ui/widget/CustomParamsSettings.d.ts +4 -0
- package/lib/cjs/ui/widget/CustomParamsSettings.d.ts.map +1 -0
- package/lib/cjs/ui/widget/CustomParamsSettings.js +116 -0
- package/lib/cjs/ui/widget/CustomParamsSettings.js.map +1 -0
- package/lib/cjs/ui/widget/CustomParamsSettings.scss +67 -0
- package/lib/cjs/ui/widget/MapLayerDroppable.d.ts +3 -3
- package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerDroppable.js +23 -10
- package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.d.ts +2 -2
- package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.js +19 -11
- package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.scss +4 -1
- package/lib/cjs/ui/widget/MapManagerSettings.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapManagerSettings.js +37 -29
- package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts +15 -5
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.js +129 -58
- package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.scss +12 -1
- package/lib/cjs/ui/widget/SelectApiKey.d.ts +10 -0
- package/lib/cjs/ui/widget/SelectApiKey.d.ts.map +1 -0
- package/lib/cjs/ui/widget/SelectApiKey.js +39 -0
- package/lib/cjs/ui/widget/SelectApiKey.js.map +1 -0
- package/lib/cjs/ui/widget/SelectCustomParam.d.ts +10 -0
- package/lib/cjs/ui/widget/SelectCustomParam.d.ts.map +1 -0
- package/lib/cjs/ui/widget/SelectCustomParam.js +49 -0
- package/lib/cjs/ui/widget/SelectCustomParam.js.map +1 -0
- package/lib/cjs/ui/widget/SelectMapFormat.d.ts +11 -2
- package/lib/cjs/ui/widget/SelectMapFormat.d.ts.map +1 -1
- package/lib/cjs/ui/widget/SelectMapFormat.js +5 -6
- package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
- package/lib/cjs/ui/widget/UserPreferencesStorageOptions.d.ts +10 -0
- package/lib/cjs/ui/widget/UserPreferencesStorageOptions.d.ts.map +1 -0
- package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js +17 -0
- package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js.map +1 -0
- package/lib/esm/BrowserStorage.d.ts +25 -0
- package/lib/esm/BrowserStorage.d.ts.map +1 -0
- package/lib/esm/BrowserStorage.js +76 -0
- package/lib/esm/BrowserStorage.js.map +1 -0
- package/lib/esm/CustomParamUtils.d.ts +5 -0
- package/lib/esm/CustomParamUtils.d.ts.map +1 -0
- package/lib/esm/CustomParamUtils.js +22 -0
- package/lib/esm/CustomParamUtils.js.map +1 -0
- package/lib/esm/CustomParamsMappingStorage.d.ts +6 -0
- package/lib/esm/CustomParamsMappingStorage.d.ts.map +1 -0
- package/lib/esm/CustomParamsMappingStorage.js +11 -0
- package/lib/esm/CustomParamsMappingStorage.js.map +1 -0
- package/lib/esm/CustomParamsStorage.d.ts +6 -0
- package/lib/esm/CustomParamsStorage.d.ts.map +1 -0
- package/lib/esm/CustomParamsStorage.js +11 -0
- package/lib/esm/CustomParamsStorage.js.map +1 -0
- package/lib/esm/MapLayerPreferences.d.ts.map +1 -1
- package/lib/esm/MapLayerPreferences.js +2 -0
- package/lib/esm/MapLayerPreferences.js.map +1 -1
- package/lib/esm/PreferencesBrowserStorage.d.ts +9 -2
- package/lib/esm/PreferencesBrowserStorage.d.ts.map +1 -1
- package/lib/esm/PreferencesBrowserStorage.js +11 -51
- package/lib/esm/PreferencesBrowserStorage.js.map +1 -1
- package/lib/esm/public/locales/en/mapLayers.json +29 -3
- package/lib/esm/ui/FeatureInfoUiItemsProvider.d.ts +1 -1
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js +1 -1
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/esm/ui/Interfaces.d.ts +11 -0
- package/lib/esm/ui/Interfaces.d.ts.map +1 -1
- package/lib/esm/ui/Interfaces.js.map +1 -1
- package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
- package/lib/esm/ui/widget/AttachLayerPopupButton.js +20 -18
- package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/CustomParamEditDialog.d.ts +11 -0
- package/lib/esm/ui/widget/CustomParamEditDialog.d.ts.map +1 -0
- package/lib/esm/ui/widget/CustomParamEditDialog.js +53 -0
- package/lib/esm/ui/widget/CustomParamEditDialog.js.map +1 -0
- package/lib/esm/ui/widget/CustomParamEditDialog.scss +26 -0
- package/lib/esm/ui/widget/CustomParamsSettings.d.ts +4 -0
- package/lib/esm/ui/widget/CustomParamsSettings.d.ts.map +1 -0
- package/lib/esm/ui/widget/CustomParamsSettings.js +112 -0
- package/lib/esm/ui/widget/CustomParamsSettings.js.map +1 -0
- package/lib/esm/ui/widget/CustomParamsSettings.scss +67 -0
- package/lib/esm/ui/widget/MapLayerDroppable.d.ts +3 -3
- package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerDroppable.js +24 -11
- package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.d.ts +2 -2
- package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.js +20 -12
- package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.scss +4 -1
- package/lib/esm/ui/widget/MapManagerSettings.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapManagerSettings.js +38 -30
- package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.d.ts +15 -5
- package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.js +129 -58
- package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.scss +12 -1
- package/lib/esm/ui/widget/SelectApiKey.d.ts +10 -0
- package/lib/esm/ui/widget/SelectApiKey.d.ts.map +1 -0
- package/lib/esm/ui/widget/SelectApiKey.js +35 -0
- package/lib/esm/ui/widget/SelectApiKey.js.map +1 -0
- package/lib/esm/ui/widget/SelectCustomParam.d.ts +10 -0
- package/lib/esm/ui/widget/SelectCustomParam.d.ts.map +1 -0
- package/lib/esm/ui/widget/SelectCustomParam.js +45 -0
- package/lib/esm/ui/widget/SelectCustomParam.js.map +1 -0
- package/lib/esm/ui/widget/SelectMapFormat.d.ts +11 -2
- package/lib/esm/ui/widget/SelectMapFormat.d.ts.map +1 -1
- package/lib/esm/ui/widget/SelectMapFormat.js +5 -6
- package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
- package/lib/esm/ui/widget/UserPreferencesStorageOptions.d.ts +10 -0
- package/lib/esm/ui/widget/UserPreferencesStorageOptions.d.ts.map +1 -0
- package/lib/esm/ui/widget/UserPreferencesStorageOptions.js +13 -0
- package/lib/esm/ui/widget/UserPreferencesStorageOptions.js.map +1 -0
- package/lib/public/locales/en/mapLayers.json +29 -3
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
# Change Log - @itwin/map-layers
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 29 Feb 2024 19:46:03 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 5.4.0
|
|
8
|
+
|
|
9
|
+
Thu, 29 Feb 2024 19:46:03 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Support for custom query parameters. ([#705](https://github.com/iTwin/viewer-components-react/pull/705))
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Improved warning message when an incompatible map-layer type is provided. ([#760](https://github.com/iTwin/viewer-components-react/pull/760))
|
|
18
|
+
- Moved @itwin/itwinui-react to direct dependencies ([#772](https://github.com/iTwin/viewer-components-react/pull/772))
|
|
19
|
+
- Hide User Preferences Options to store at the iTwin/iModel scope. ([#756](https://github.com/iTwin/viewer-components-react/pull/756))
|
|
20
|
+
- Added @itwin/itwinui-react to peer dependencies ([#767](https://github.com/iTwin/viewer-components-react/pull/767))
|
|
21
|
+
|
|
22
|
+
## 5.3.1
|
|
23
|
+
|
|
24
|
+
Wed, 07 Feb 2024 21:16:44 GMT
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- Fix map feature info widget tech preview badge ([#759](https://github.com/iTwin/viewer-components-react/pull/759))
|
|
29
|
+
|
|
7
30
|
## 5.3.0
|
|
8
31
|
|
|
9
|
-
Tue, 06 Feb 2024 13:45:
|
|
32
|
+
Tue, 06 Feb 2024 13:45:21 GMT
|
|
10
33
|
|
|
11
34
|
### Minor changes
|
|
12
35
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Index signature holding preferences content
|
|
2
|
+
*
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
interface KeyContentProps<Type> {
|
|
6
|
+
[preferenceKey: string]: Type;
|
|
7
|
+
}
|
|
8
|
+
export interface BrowserStorageOptions {
|
|
9
|
+
/** indicate whether or not delete function should throw an error if the provided key cannot be found. */
|
|
10
|
+
throwOnDeleteMissingKey?: boolean;
|
|
11
|
+
itemKeyName: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class BrowserStorage<Type> {
|
|
14
|
+
private readonly _itemKeyName;
|
|
15
|
+
private readonly _throwOnDeleteMissingKey;
|
|
16
|
+
constructor(opts: BrowserStorageOptions);
|
|
17
|
+
private loadFromStorage;
|
|
18
|
+
get(key: string | undefined): Type[] | undefined;
|
|
19
|
+
getContent(): KeyContentProps<Type> | undefined;
|
|
20
|
+
delete(key: string): void;
|
|
21
|
+
deleteMatchingContent(content: Type): void;
|
|
22
|
+
save(key: string, content: Type): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=BrowserStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserStorage.d.ts","sourceRoot":"","sources":["../../src/BrowserStorage.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,UAAU,eAAe,CAAC,IAAI;IAC5B,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,cAAc,CAAC,IAAI;IAE9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC;gBAE9B,IAAI,EAAE,qBAAqB;IAKvC,OAAO,CAAC,eAAe;IAehB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAC,SAAS;IAezB,UAAU;IAIV,MAAM,CAAC,GAAG,EAAE,MAAM;IAmBlB,qBAAqB,CAAC,OAAO,EAAE,IAAI;IAcnC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;CAUvC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.BrowserStorage = void 0;
|
|
8
|
+
class BrowserStorage {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this._itemKeyName = opts.itemKeyName;
|
|
11
|
+
this._throwOnDeleteMissingKey = opts.throwOnDeleteMissingKey ?? true;
|
|
12
|
+
}
|
|
13
|
+
loadFromStorage() {
|
|
14
|
+
const storage = window.localStorage;
|
|
15
|
+
let map = {};
|
|
16
|
+
const itemStr = storage.getItem(this._itemKeyName);
|
|
17
|
+
if (itemStr === null) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
if (!itemStr || itemStr === "{}")
|
|
21
|
+
return map;
|
|
22
|
+
map = JSON.parse(itemStr);
|
|
23
|
+
return map;
|
|
24
|
+
}
|
|
25
|
+
get(key) {
|
|
26
|
+
const map = this.loadFromStorage();
|
|
27
|
+
if (map === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (key) {
|
|
30
|
+
if (!Object.keys(map).includes(key))
|
|
31
|
+
return undefined;
|
|
32
|
+
return [map[key]];
|
|
33
|
+
}
|
|
34
|
+
else { // No key provided, return all objects
|
|
35
|
+
return Object.entries(map).map(([_key, value]) => value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
getContent() {
|
|
39
|
+
return this.loadFromStorage();
|
|
40
|
+
}
|
|
41
|
+
delete(key) {
|
|
42
|
+
const map = this.loadFromStorage();
|
|
43
|
+
if (map === undefined) {
|
|
44
|
+
if (this._throwOnDeleteMissingKey)
|
|
45
|
+
throw new Error("Could not find key from storage.");
|
|
46
|
+
else
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!Object.keys(map).includes(key)) {
|
|
50
|
+
if (this._throwOnDeleteMissingKey)
|
|
51
|
+
throw Error("Could not find key from storage.");
|
|
52
|
+
else
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
delete map[key];
|
|
56
|
+
window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));
|
|
57
|
+
}
|
|
58
|
+
deleteMatchingContent(content) {
|
|
59
|
+
const map = this.loadFromStorage();
|
|
60
|
+
if (map === undefined) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const contentJson = JSON.stringify(content);
|
|
64
|
+
for (const [key, value] of Object.entries(map)) {
|
|
65
|
+
if (JSON.stringify(value) === contentJson)
|
|
66
|
+
delete map[key];
|
|
67
|
+
}
|
|
68
|
+
window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));
|
|
69
|
+
}
|
|
70
|
+
save(key, content) {
|
|
71
|
+
let map = this.loadFromStorage();
|
|
72
|
+
if (map === undefined)
|
|
73
|
+
map = {};
|
|
74
|
+
map[key] = content;
|
|
75
|
+
const itemValue = JSON.stringify(map);
|
|
76
|
+
window.localStorage.setItem(this._itemKeyName, itemValue);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.BrowserStorage = BrowserStor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AW,EAAE,OAAa;QACpC,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS;YACnB,GAAG,GAAG,EAAE,CAAC;QAEX,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF;AAvFD,wCAuFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps<Type> {\n [preferenceKey: string]: Type;\n}\n\nexport interface BrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n itemKeyName: string;\n}\n\nexport class BrowserStorage<Type> {\n\n private readonly _itemKeyName;\n private readonly _throwOnDeleteMissingKey;\n\n constructor(opts: BrowserStorageOptions) {\n this._itemKeyName = opts.itemKeyName;\n this._throwOnDeleteMissingKey = opts.throwOnDeleteMissingKey ?? true;\n }\n\n private loadFromStorage() {\n const storage = window.localStorage;\n\n let map: KeyContentProps<Type> = {};\n const itemStr = storage.getItem(this._itemKeyName);\n if (itemStr === null) {\n return undefined;\n }\n if (!itemStr || itemStr === \"{}\")\n return map;\n\n map = JSON.parse(itemStr);\n return map;\n }\n\n public get(key: string|undefined) {\n const map = this.loadFromStorage();\n if (map === undefined)\n return undefined;\n\n if (key) {\n if (!Object.keys(map).includes(key))\n return undefined;\n\n return [map[key]];\n } else { // No key provided, return all objects\n return Object.entries(map).map(([_key, value]) => value);\n }\n }\n\n public getContent() {\n return this.loadFromStorage();\n }\n\n public delete(key: string) {\n const map = this.loadFromStorage();\n if (map === undefined) {\n if (this._throwOnDeleteMissingKey)\n throw new Error(\"Could not find key from storage.\");\n else\n return;\n }\n\n if (!Object.keys(map).includes(key)) {\n if (this._throwOnDeleteMissingKey)\n throw Error(\"Could not find key from storage.\");\n else\n return;\n }\n delete map[key];\n window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));\n }\n\n public deleteMatchingContent(content: Type) {\n const map = this.loadFromStorage();\n if (map === undefined) {\n return;\n }\n const contentJson = JSON.stringify(content);\n for (const [key, value] of Object.entries(map)) {\n if (JSON.stringify(value) === contentJson)\n delete map[key];\n }\n\n window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));\n }\n\n public save(key: string, content: Type) {\n let map = this.loadFromStorage();\n if (map === undefined)\n map = {};\n\n map[key] = content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this._itemKeyName, itemValue);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamUtils.d.ts","sourceRoot":"","sources":["../../src/CustomParamUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,qBAAa,gBAAgB;WACb,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE;CAiBvF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomParamUtils = void 0;
|
|
4
|
+
const CustomParamsStorage_1 = require("./CustomParamsStorage");
|
|
5
|
+
class CustomParamUtils {
|
|
6
|
+
static setSourceCustomParams(source, customParamNames) {
|
|
7
|
+
const cpStorage = new CustomParamsStorage_1.CustomParamsStorage();
|
|
8
|
+
customParamNames.forEach((paramName) => {
|
|
9
|
+
const customParam = cpStorage.get(paramName);
|
|
10
|
+
if (customParam && customParam.length > 0 && source) {
|
|
11
|
+
if (customParam[0].secret) {
|
|
12
|
+
if (!source.unsavedQueryParams)
|
|
13
|
+
source.unsavedQueryParams = {};
|
|
14
|
+
source.unsavedQueryParams[customParam[0].key] = customParam[0].value;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (!source.savedQueryParams)
|
|
18
|
+
source.savedQueryParams = {};
|
|
19
|
+
source.savedQueryParams[customParam[0].key] = customParam[0].value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CustomParamUtils = CustomParamUtils;
|
|
26
|
+
//# sourceMappingURL=CustomParamUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamUtils.js","sourceRoot":"","sources":["../../src/CustomParamUtils.ts"],"names":[],"mappings":";;;AAKA,+DAA4D;AAE5D,MAAa,gBAAgB;IACpB,MAAM,CAAC,qBAAqB,CAAC,MAAsB,EAAE,gBAA0B;QACpF,MAAM,SAAS,GAAG,IAAI,yCAAmB,EAAE,CAAC;QAC5C,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC7C,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;gBACnD,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;oBACzB,IAAI,CAAC,MAAM,CAAC,kBAAkB;wBAC5B,MAAM,CAAC,kBAAkB,GAAG,EAAE,CAAC;oBACjC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;iBACtE;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,gBAAgB;wBAC1B,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;oBAC/B,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;iBACpE;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlBD,4CAkBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { MapLayerSource } from \"@itwin/core-frontend\";\nimport { CustomParamsStorage } from \"./CustomParamsStorage\";\n\nexport class CustomParamUtils {\n public static setSourceCustomParams(source: MapLayerSource, customParamNames: string[]) {\n const cpStorage = new CustomParamsStorage();\n customParamNames.forEach((paramName) => {\n const customParam = cpStorage.get(paramName);\n if (customParam && customParam.length > 0 && source) {\n if (customParam[0].secret) {\n if (!source.unsavedQueryParams)\n source.unsavedQueryParams = {};\n source.unsavedQueryParams[customParam[0].key] = customParam[0].value;\n } else {\n if (!source.savedQueryParams)\n source.savedQueryParams = {};\n source.savedQueryParams[customParam[0].key] = customParam[0].value;\n }\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BrowserStorage } from "./BrowserStorage";
|
|
2
|
+
import { CustomParamsMappingItem } from "./ui/Interfaces";
|
|
3
|
+
export declare class CustomParamsMappingStorage extends BrowserStorage<CustomParamsMappingItem> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=CustomParamsMappingStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamsMappingStorage.d.ts","sourceRoot":"","sources":["../../src/CustomParamsMappingStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,uBAAuB,CAAC;;CAItF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomParamsMappingStorage = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const BrowserStorage_1 = require("./BrowserStorage");
|
|
9
|
+
class CustomParamsMappingStorage extends BrowserStorage_1.BrowserStorage {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ itemKeyName: "itwinjs.mapLayers.customParamsMapping" });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.CustomParamsMappingStorage = CustomParamsMappingStorage;
|
|
15
|
+
//# sourceMappingURL=CustomParamsMappingStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamsMappingStorage.js","sourceRoot":"","sources":["../../src/CustomParamsMappingStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,qDAAkD;AAGlD,MAAa,0BAA2B,SAAQ,+BAAuC;IACrF;QACE,KAAK,CAAC,EAAC,WAAW,EAAE,uCAAuC,EAAC,CAAC,CAAC;IAChE,CAAC;CACF;AAJD,gEAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BrowserStorage } from \"./BrowserStorage\";\nimport { CustomParamsMappingItem } from \"./ui/Interfaces\";\n\nexport class CustomParamsMappingStorage extends BrowserStorage<CustomParamsMappingItem> {\n constructor() {\n super({itemKeyName: \"itwinjs.mapLayers.customParamsMapping\"});\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamsStorage.d.ts","sourceRoot":"","sources":["../../src/CustomParamsStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,eAAe,CAAC;;CAIvE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomParamsStorage = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const BrowserStorage_1 = require("./BrowserStorage");
|
|
9
|
+
class CustomParamsStorage extends BrowserStorage_1.BrowserStorage {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ itemKeyName: "itwinjs.mapLayers.customParams" });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.CustomParamsStorage = CustomParamsStorage;
|
|
15
|
+
//# sourceMappingURL=CustomParamsStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParamsStorage.js","sourceRoot":"","sources":["../../src/CustomParamsStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,qDAAkD;AAGlD,MAAa,mBAAoB,SAAQ,+BAA+B;IACtE;QACE,KAAK,CAAC,EAAC,WAAW,EAAE,gCAAgC,EAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAJD,kDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BrowserStorage } from \"./BrowserStorage\";\nimport { CustomParamItem } from \"./ui/Interfaces\";\n\nexport class CustomParamsStorage extends BrowserStorage<CustomParamItem> {\n constructor() {\n super({itemKeyName: \"itwinjs.mapLayers.customParams\"});\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerPreferences.d.ts","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG1D,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5C;AAED,gBAAgB;AAChB,oBAAY,wBAAwB;IAClC,KAAK,IAAI;IACT,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED,gBAAgB;AAChB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;OAMG;IACH,gBAAuB,oBAAoB,uBAA4B,wBAAwB,qFAA6D,IAAI,EAAI;IAEpK;;;;;;OAMG;WACiB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MapLayerPreferences.d.ts","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAKA,OAAO,EAA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G,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC;IA0B9H;;;;OAIG;WACiB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA6CrG,OAAO,CAAC,MAAM,KAAK,oBAAoB,GAEtC;CACF"}
|
|
@@ -34,6 +34,8 @@ class MapLayerPreferences {
|
|
|
34
34
|
return false;
|
|
35
35
|
const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
|
|
36
36
|
const sourceJSON = source.toJSON();
|
|
37
|
+
if (!sourceJSON.formatId)
|
|
38
|
+
return false;
|
|
37
39
|
const mapLayerSetting = {
|
|
38
40
|
url: sourceJSON.url,
|
|
39
41
|
name: sourceJSON.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,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gBACP,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAjTH,kDAkTC;AAjTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAErI,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,QAAQ;YACtB,OAAO,KAAK,CAAC;QACf,MAAM,eAAe,GAA+B;YAClD,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,IAAI,EAAE,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,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAnTH,kDAoTC;AAnTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n if (!sourceJSON.formatId)\n return false;\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from "@itwin/core-frontend";
|
|
2
|
+
/** Index signature holding preferences content
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
interface KeyContentProps {
|
|
7
|
+
[preferenceKey: string]: any;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* @beta
|
|
4
11
|
*/
|
|
@@ -28,9 +35,9 @@ export declare class PreferencesBrowserStorage implements UserPreferencesAccess
|
|
|
28
35
|
constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions);
|
|
29
36
|
private getStorageItemKey;
|
|
30
37
|
private static getPreferenceKey;
|
|
31
|
-
|
|
32
|
-
get(arg: PreferenceKeyArg & ITwinIdArg): Promise<any[] | undefined>;
|
|
38
|
+
get(arg: PreferenceKeyArg & ITwinIdArg): Promise<KeyContentProps[] | undefined>;
|
|
33
39
|
delete(arg: PreferenceKeyArg & ITwinIdArg): Promise<void>;
|
|
34
40
|
save(arg: PreferenceArg & ITwinIdArg): Promise<void>;
|
|
35
41
|
}
|
|
42
|
+
export {};
|
|
36
43
|
//# sourceMappingURL=PreferencesBrowserStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PreferencesBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG1G;;;GAGG;AACH,UAAU,eAAe;IACvB,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC;CAC9B;AAED;;EAEE;AACF,MAAM,WAAW,gCAAgC;IAC/C,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;EAeE;AACF,qBAAa,yBAA0B,YAAW,qBAAqB;IAErE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+C;IACxE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gCAAgC;IAKjF,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IASlB,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAKtC,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAKzC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU;CAIlD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PreferencesBrowserStorage = void 0;
|
|
4
|
+
const BrowserStorage_1 = require("./BrowserStorage");
|
|
4
5
|
/** User preferences implementation using browser's local storage.
|
|
5
6
|
* It creates storage item key in the form of:
|
|
6
7
|
* <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>
|
|
@@ -28,64 +29,23 @@ class PreferencesBrowserStorage {
|
|
|
28
29
|
return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;
|
|
29
30
|
}
|
|
30
31
|
static getPreferenceKey(arg) {
|
|
31
|
-
const nsStr = arg.namespace ? `${arg.namespace}.` : "";
|
|
32
|
-
return `${nsStr}${arg.key}`;
|
|
33
|
-
}
|
|
34
|
-
loadFromStorage(arg) {
|
|
35
|
-
const storage = window.localStorage;
|
|
36
|
-
let map = {};
|
|
37
|
-
const itemStr = storage.getItem(this.getStorageItemKey(arg));
|
|
38
|
-
if (itemStr === null) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
if (!itemStr || itemStr === "{}")
|
|
42
|
-
return map;
|
|
43
|
-
map = JSON.parse(itemStr);
|
|
44
|
-
return map;
|
|
45
|
-
}
|
|
46
|
-
async get(arg) {
|
|
47
|
-
const map = this.loadFromStorage(arg);
|
|
48
|
-
if (map === undefined)
|
|
49
|
-
return undefined;
|
|
50
32
|
if (arg.key) {
|
|
51
|
-
if (!Object.keys(map).includes(arg.key))
|
|
52
|
-
return undefined;
|
|
53
33
|
const nsStr = arg.namespace ? `${arg.namespace}.` : "";
|
|
54
|
-
|
|
55
|
-
return [map[prefKey]];
|
|
56
|
-
}
|
|
57
|
-
else { // No key provided, return all objects
|
|
58
|
-
const values = [];
|
|
59
|
-
for (const [_key, value] of Object.entries(map))
|
|
60
|
-
values.push(value);
|
|
61
|
-
return values;
|
|
34
|
+
return `${nsStr}${arg.key}`;
|
|
62
35
|
}
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
async get(arg) {
|
|
39
|
+
const storage = new BrowserStorage_1.BrowserStorage({ itemKeyName: this.getStorageItemKey(arg) });
|
|
40
|
+
return storage.get(PreferencesBrowserStorage.getPreferenceKey(arg));
|
|
63
41
|
}
|
|
64
42
|
async delete(arg) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
if (this._options?.throwOnDeleteMissingKey)
|
|
68
|
-
throw new Error("Could not find key from storage.");
|
|
69
|
-
else
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const prefKey = PreferencesBrowserStorage.getPreferenceKey(arg);
|
|
73
|
-
if (!Object.keys(map).includes(prefKey)) {
|
|
74
|
-
if (this._options?.throwOnDeleteMissingKey)
|
|
75
|
-
throw Error("Could not find key from storage.");
|
|
76
|
-
else
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
delete map[prefKey];
|
|
80
|
-
window.localStorage.setItem(this.getStorageItemKey(arg), JSON.stringify(map));
|
|
43
|
+
const storage = new BrowserStorage_1.BrowserStorage({ itemKeyName: this.getStorageItemKey(arg) });
|
|
44
|
+
storage.delete(PreferencesBrowserStorage.getPreferenceKey(arg));
|
|
81
45
|
}
|
|
82
46
|
async save(arg) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
map = {};
|
|
86
|
-
map[PreferencesBrowserStorage.getPreferenceKey(arg)] = arg.content;
|
|
87
|
-
const itemValue = JSON.stringify(map);
|
|
88
|
-
window.localStorage.setItem(this.getStorageItemKey(arg), itemValue);
|
|
47
|
+
const storage = new BrowserStorage_1.BrowserStorage({ itemKeyName: this.getStorageItemKey(arg) });
|
|
48
|
+
storage.save(PreferencesBrowserStorage.getPreferenceKey(arg), arg.content);
|
|
89
49
|
}
|
|
90
50
|
}
|
|
91
51
|
exports.PreferencesBrowserStorage = PreferencesBrowserStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":";;;AAKA,qDAAkD;AAkBlD;;;;;;;;;;;;;;;EAeE;AACF,MAAa,yBAAyB;IAKpC,YAAY,oBAA4B,EAAE,IAAuC;QAC/E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IACpD,CAAC;IAEO,iBAAiB,CAAC,GAAe;QACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAA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AAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF;AAvCD,8DAuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from \"@itwin/core-frontend\";\nimport { BrowserStorage } from \"./BrowserStorage\";\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps {\n [preferenceKey: string]: any;\n}\n\n/**\n* @beta\n*/\nexport interface PreferencesBrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n}\n\n/** User preferences implementation using browser's local storage.\n * It creates storage item key in the form of:\n * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>\n *\n * <itwin_guid> and <imodel_guid> being optional.\n *\n * Each entry in the storage is a serialized JSON of the following index signature:\n * {\n * \"<preference_namespace?>.<preference_key>\": {\n * ...\n * <preferences_json_content>\n * },\n * ...\n * }\n * @beta\n*/\nexport class PreferencesBrowserStorage implements UserPreferencesAccess {\n\n private readonly _options: PreferencesBrowserStorageOptions | undefined;\n private readonly _storageItemKeyPrefix: string;\n\n constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions) {\n this._options = opts;\n this._storageItemKeyPrefix = storageItemKeyPrefix;\n }\n\n private getStorageItemKey(arg: ITwinIdArg) {\n const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : \"\";\n const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : \"\";\n return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;\n }\n\n private static getPreferenceKey(arg: PreferenceKeyArg) {\n if (arg.key) {\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n return `${nsStr}${arg.key}`;\n }\n\n return \"\";\n }\n\n public async get(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({itemKeyName: this.getStorageItemKey(arg)});\n return storage.get(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async delete(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({itemKeyName: this.getStorageItemKey(arg)});\n storage.delete(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async save(arg: PreferenceArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({itemKeyName: this.getStorageItemKey(arg)});\n storage.save(PreferencesBrowserStorage.getPreferenceKey(arg), arg.content);\n }\n}\n"]}
|
|
@@ -23,6 +23,28 @@
|
|
|
23
23
|
"AllOn": "Select All",
|
|
24
24
|
"AllOff": "Select None"
|
|
25
25
|
},
|
|
26
|
+
"CustomParamEditDialog":
|
|
27
|
+
{
|
|
28
|
+
"DialogTitleAdd": "Add custom query parameter",
|
|
29
|
+
"DialogTitleEdit": "Edit custom query parameter",
|
|
30
|
+
"NameExists": "Name already exists",
|
|
31
|
+
"ParamKeyLabel": "Key",
|
|
32
|
+
"ParamNameLabel": "Name",
|
|
33
|
+
"ParamValueLabel": "Value",
|
|
34
|
+
"ParamValueNonPrivateMessage": "Value should not contain sensitive data",
|
|
35
|
+
"PrivateToggleTooltip": "Private query parameters won't be saved part of the iTwin",
|
|
36
|
+
"PrivateToggleLabel": "Keep query parameter private"
|
|
37
|
+
},
|
|
38
|
+
"CustomParamSelect":
|
|
39
|
+
{
|
|
40
|
+
"DisabledTitle": "Custom query parameter can be configured in the advanced settings"
|
|
41
|
+
},
|
|
42
|
+
"CustomParamSettings":
|
|
43
|
+
{
|
|
44
|
+
"DeleteButtonTitle": "Delete custom parameter",
|
|
45
|
+
"EditButtonTitle": "Edit custom parameter",
|
|
46
|
+
"SectionLabel": "Custom parameters"
|
|
47
|
+
},
|
|
26
48
|
"MapLayerActionButtons": {
|
|
27
49
|
"ShowAllLabel": "Show all",
|
|
28
50
|
"HideAllLabel": "Hide all",
|
|
@@ -38,9 +60,10 @@
|
|
|
38
60
|
"AttachCustomLayer": "Add New Layer",
|
|
39
61
|
"AttacheInfo": "Map layer attached from URL:",
|
|
40
62
|
"Custom": "New",
|
|
63
|
+
"CustomParamsLabel": "Custom Query Parameters",
|
|
41
64
|
"LoadingMapSources": "Loading Map Sources",
|
|
42
65
|
"EditCustomLayer": "Edit Layer",
|
|
43
|
-
"EditLayerDefButtonTitle": "Edit
|
|
66
|
+
"EditLayerDefButtonTitle": "Edit layer definition",
|
|
44
67
|
"ErrorLoadingLayers": "Error retrieving map layers stored in the settings service",
|
|
45
68
|
"ErrorRetrieveUserModel": "Could not get saved Map Layers for user by model: {{errorMessage}}",
|
|
46
69
|
"ErrorRetrieveUserITwin": "Could not get saved Map Layers for user by iTwin: {{errorMessage}}",
|
|
@@ -53,6 +76,7 @@
|
|
|
53
76
|
"ExternalLoginWaiting": "Waiting for external login process to complete...",
|
|
54
77
|
"InvalidCredentials": "Invalid credentials provided",
|
|
55
78
|
"InvalidCoordinateSystem": "Map layer geographic coordinate system is not supported",
|
|
79
|
+
"InvalidType": "Invalid Type",
|
|
56
80
|
"MissingCredentials": "This layer requires credentials to be provided",
|
|
57
81
|
"Name": "Name",
|
|
58
82
|
"NameInputPlaceHolder": "Enter Map Name",
|
|
@@ -66,7 +90,6 @@
|
|
|
66
90
|
"SelectLayersToCreate": "Select Layers To Add",
|
|
67
91
|
"StoreOnModelSettings": "Store on Model Settings",
|
|
68
92
|
"StoreOnITwinSettings": "Store on iTwin Settings",
|
|
69
|
-
"TechPreviewBadgeTooltip": "Technology preview",
|
|
70
93
|
"TooManyLayersSelected": "{{layerCount}} layers selected; performance may be affected.",
|
|
71
94
|
"Type": "Type",
|
|
72
95
|
"URL": "URL",
|
|
@@ -80,6 +103,9 @@
|
|
|
80
103
|
"Username": "Username",
|
|
81
104
|
"UsernameRequired": "Username required"
|
|
82
105
|
},
|
|
106
|
+
"Labels" : {
|
|
107
|
+
"TechPreviewBadgeTooltip": "Technology preview"
|
|
108
|
+
},
|
|
83
109
|
"Messages": {
|
|
84
110
|
"NotSupported": "No active viewport or geo-located iModel available.",
|
|
85
111
|
"NoRangeDefined": "No range is defined for Map Layer",
|
|
@@ -155,4 +181,4 @@
|
|
|
155
181
|
"Street" : "Bing Maps: Streets"
|
|
156
182
|
}
|
|
157
183
|
}
|
|
158
|
-
}
|
|
184
|
+
}
|