@c8y/ngx-components 1024.18.1 → 1024.18.9
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/fesm2022/c8y-ngx-components-actility-device-registration.mjs +1 -1
- package/fesm2022/c8y-ngx-components-actility-device-registration.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-asset-properties.mjs +67 -20
- package/fesm2022/c8y-ngx-components-asset-properties.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-assets-navigator.mjs +75 -13
- package/fesm2022/c8y-ngx-components-assets-navigator.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-branding-shared-lazy-add-branding-modal.mjs +2 -4
- package/fesm2022/c8y-ngx-components-branding-shared-lazy-add-branding-modal.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-branding-shared-lazy.mjs +6 -8
- package/fesm2022/c8y-ngx-components-branding-shared-lazy.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-context-dashboard.mjs +98 -19
- package/fesm2022/c8y-ngx-components-context-dashboard.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-dashboard-manager.mjs +4 -4
- package/fesm2022/c8y-ngx-components-dashboard-manager.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-datapoint-explorer-view.mjs +7 -7
- package/fesm2022/c8y-ngx-components-datapoint-explorer-view.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-datapoints-export-selector.mjs +5 -3
- package/fesm2022/c8y-ngx-components-datapoints-export-selector.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-echart-models.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-echart.mjs +52 -7
- package/fesm2022/c8y-ngx-components-echart.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-ecosystem.mjs +1 -1
- package/fesm2022/c8y-ngx-components-ecosystem.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-file-preview.mjs +2 -2
- package/fesm2022/c8y-ngx-components-file-preview.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-icon-selector.mjs +6 -6
- package/fesm2022/c8y-ngx-components-icon-selector.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-loriot-device-registration.mjs +1 -1
- package/fesm2022/c8y-ngx-components-loriot-device-registration.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-operation-picker.mjs +2 -2
- package/fesm2022/c8y-ngx-components-operation-picker.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-register-device.mjs +4 -4
- package/fesm2022/c8y-ngx-components-register-device.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-remote-access-configurations.mjs +2 -3
- package/fesm2022/c8y-ngx-components-remote-access-configurations.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-remote-access-shared.mjs +2 -2
- package/fesm2022/c8y-ngx-components-remote-access-shared.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-remote-access-ssh-remote-access-ssh-endpoint-modal.mjs +2 -2
- package/fesm2022/c8y-ngx-components-remote-access-ssh-remote-access-ssh-endpoint-modal.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-remote-access-vnc-remote-access-vnc-endpoint-modal.mjs +2 -4
- package/fesm2022/c8y-ngx-components-remote-access-vnc-remote-access-vnc-endpoint-modal.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-remote-access-vnc-vnc-viewer.mjs +2 -3
- package/fesm2022/c8y-ngx-components-remote-access-vnc-vnc-viewer.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-sigfox-device-registration.mjs +1 -1
- package/fesm2022/c8y-ngx-components-sigfox-device-registration.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-static-assets-modal.mjs +2 -2
- package/fesm2022/c8y-ngx-components-static-assets-modal.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-translation-editor-lazy.mjs +3 -4
- package/fesm2022/c8y-ngx-components-translation-editor-lazy.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-scada.mjs +10 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-scada.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-asset-table.mjs +4 -4
- package/fesm2022/c8y-ngx-components-widgets-implementations-asset-table.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-graph.mjs +18 -3
- package/fesm2022/c8y-ngx-components-widgets-implementations-datapoints-graph.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-scada.mjs +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-scada.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components.mjs +59 -19
- package/fesm2022/c8y-ngx-components.mjs.map +1 -1
- package/locales/de.po +3 -2
- package/locales/es.po +3 -3
- package/locales/fr.po +3 -3
- package/locales/ja_JP.po +2 -2
- package/locales/ko.po +3 -3
- package/locales/locales.pot +1 -1
- package/locales/nl.po +3 -3
- package/locales/pl.po +2 -3
- package/locales/pt_BR.po +2 -3
- package/locales/zh_CN.po +2 -2
- package/locales/zh_TW.po +3 -3
- package/package.json +1 -1
- package/types/c8y-ngx-components-asset-properties.d.ts +9 -1
- package/types/c8y-ngx-components-asset-properties.d.ts.map +1 -1
- package/types/c8y-ngx-components-assets-navigator.d.ts +30 -3
- package/types/c8y-ngx-components-assets-navigator.d.ts.map +1 -1
- package/types/c8y-ngx-components-branding-shared-lazy-add-branding-modal.d.ts.map +1 -1
- package/types/c8y-ngx-components-context-dashboard.d.ts +44 -1
- package/types/c8y-ngx-components-context-dashboard.d.ts.map +1 -1
- package/types/c8y-ngx-components-echart-models.d.ts +9 -0
- package/types/c8y-ngx-components-echart-models.d.ts.map +1 -1
- package/types/c8y-ngx-components-echart.d.ts +32 -5
- package/types/c8y-ngx-components-echart.d.ts.map +1 -1
- package/types/c8y-ngx-components-remote-access-vnc-remote-access-vnc-endpoint-modal.d.ts.map +1 -1
- package/types/c8y-ngx-components-widgets-implementations-datapoints-graph.d.ts +6 -0
- package/types/c8y-ngx-components-widgets-implementations-datapoints-graph.d.ts.map +1 -1
- package/types/c8y-ngx-components.d.ts +50 -2
- package/types/c8y-ngx-components.d.ts.map +1 -1
|
@@ -12,7 +12,7 @@ import { NgTemplateOutlet, CommonModule, NgClass, AsyncPipe, NgIf, NgForOf, NgFo
|
|
|
12
12
|
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
|
13
13
|
import * as i6 from '@c8y/ngx-components/context-dashboard-state';
|
|
14
14
|
import * as i2$1 from '@ngx-translate/core';
|
|
15
|
-
import { assign, pick, isEmpty, cloneDeep, some, keys, keyBy, has, set,
|
|
15
|
+
import { assign, pick, isEmpty, cloneDeep, some, keys, keyBy, has, set, forEach, get, isEqual, clone, merge as merge$1, omit, sortBy, isNull, escapeRegExp, findIndex, kebabCase, every, words, camelCase } from 'lodash-es';
|
|
16
16
|
import * as i2$2 from 'ngx-bootstrap/popover';
|
|
17
17
|
import { PopoverModule, PopoverDirective } from 'ngx-bootstrap/popover';
|
|
18
18
|
import * as i1$1 from '@c8y/client';
|
|
@@ -647,7 +647,7 @@ class ContextDashboardService {
|
|
|
647
647
|
async pasteDashboard(newContext) {
|
|
648
648
|
if (this.copyClipboard) {
|
|
649
649
|
try {
|
|
650
|
-
const dashboardToPaste = this.createContextDashboardCopy(this.copyClipboard.dashboard, newContext.contextData, this.copyClipboard.context.contextData);
|
|
650
|
+
const dashboardToPaste = await this.createContextDashboardCopy(this.copyClipboard.dashboard, newContext.contextData, this.copyClipboard.context.contextData);
|
|
651
651
|
const dashboard = await this.create(this.clean(dashboardToPaste), newContext);
|
|
652
652
|
// linking childAdditions for e.g. to grant access to the images uploaded by the image widget for users with only inventory roles.
|
|
653
653
|
const { data: childAdditions } = await this.inventory.childAdditionsList(this.copyClipboard.dashboardId, { pageSize: 2000 });
|
|
@@ -935,28 +935,44 @@ class ContextDashboardService {
|
|
|
935
935
|
});
|
|
936
936
|
dashboard.c8y_Dashboard.children = children;
|
|
937
937
|
}
|
|
938
|
-
createContextDashboardCopy(dash, newContext, oldContext) {
|
|
939
|
-
const
|
|
938
|
+
async createContextDashboardCopy(dash, newContext, oldContext) {
|
|
939
|
+
const _children = {};
|
|
940
|
+
const propertiesToCopy = {
|
|
941
|
+
device: device => this.replaceContextInObj(device, newContext, oldContext),
|
|
942
|
+
deviceIds: deviceIds => this.replaceContextInIdsObj(deviceIds, newContext, oldContext),
|
|
943
|
+
datapoints: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
944
|
+
dataPoints: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
945
|
+
datapointsGauge: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
946
|
+
datapointsLabels: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext)
|
|
947
|
+
};
|
|
948
|
+
for (const child of Object.values(dash.children || {})) {
|
|
940
949
|
const { id } = child;
|
|
941
950
|
const cfg = child.config;
|
|
942
|
-
const propertiesToCopy = {
|
|
943
|
-
device: device => this.replaceContextInObj(device, newContext, oldContext),
|
|
944
|
-
deviceIds: deviceIds => this.replaceContextInIdsObj(deviceIds, newContext, oldContext),
|
|
945
|
-
datapoints: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
946
|
-
dataPoints: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
947
|
-
datapointsGauge: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext),
|
|
948
|
-
datapointsLabels: dataPoints => this.replaceContextInDataPoints(dataPoints, newContext, oldContext)
|
|
949
|
-
};
|
|
950
951
|
if (cfg) {
|
|
951
|
-
this.
|
|
952
|
-
|
|
953
|
-
|
|
952
|
+
const definition = await this.dynamicComponent.getById(child.componentId);
|
|
953
|
+
const pasteHook = definition?.data?.paste;
|
|
954
|
+
let pasteHookApplied = false;
|
|
955
|
+
if (typeof pasteHook === 'function') {
|
|
956
|
+
try {
|
|
957
|
+
// A hook that returns nothing is treated as "config left as is", so that a missing
|
|
958
|
+
// return value cannot wipe the widget's configuration.
|
|
959
|
+
child.config = (await pasteHook(cfg, newContext, oldContext)) ?? cfg;
|
|
960
|
+
pasteHookApplied = true;
|
|
961
|
+
}
|
|
962
|
+
catch (error) {
|
|
963
|
+
console.error(`The paste hook of widget "${child.componentId}" failed. Falling back to the default context replacement.`, error);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (!pasteHookApplied) {
|
|
967
|
+
this.copyProperties(cfg, propertiesToCopy);
|
|
968
|
+
if (cfg.options) {
|
|
969
|
+
this.copyProperties(cfg.options, propertiesToCopy);
|
|
970
|
+
}
|
|
954
971
|
}
|
|
955
972
|
}
|
|
956
973
|
_children[id] = cloneDeep(child);
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
dash.children = children;
|
|
974
|
+
}
|
|
975
|
+
dash.children = _children;
|
|
960
976
|
const isTypeDashboard = dash.deviceType && !!dash.deviceTypeValue;
|
|
961
977
|
if (isTypeDashboard) {
|
|
962
978
|
dash.deviceTypeValue = newContext.type;
|
|
@@ -4922,7 +4938,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
|
|
|
4922
4938
|
args: [{ providedIn: 'root' }]
|
|
4923
4939
|
}] });
|
|
4924
4940
|
|
|
4941
|
+
/**
|
|
4942
|
+
* Checks whether the given managed object ID refers to the old context.
|
|
4943
|
+
*
|
|
4944
|
+
* IDs are compared as strings, because a configuration can hold them either as a string or as a
|
|
4945
|
+
* number depending on how it was created (e.g. seeded through the API), while the context always
|
|
4946
|
+
* carries the platform's string ID.
|
|
4947
|
+
*
|
|
4948
|
+
* @param id - The ID stored in the widget configuration
|
|
4949
|
+
* @param oldContext - The old context managed object containing the ID to compare against
|
|
4950
|
+
*/
|
|
4951
|
+
function referencesOldContext(id, oldContext) {
|
|
4952
|
+
return id !== undefined && id !== null && String(id) === String(oldContext.id);
|
|
4953
|
+
}
|
|
4954
|
+
/**
|
|
4955
|
+
* Rebinds a single asset reference of a widget configuration to the new context.
|
|
4956
|
+
*
|
|
4957
|
+
* Use this from a widget's `paste` hook for every asset, device or group reference the widget
|
|
4958
|
+
* stores, so that a widget pasted onto a different context object stops reading from the object
|
|
4959
|
+
* it was originally bound to. References pointing at anything other than the old context are
|
|
4960
|
+
* left untouched, as they were deliberately bound to a different asset.
|
|
4961
|
+
*
|
|
4962
|
+
* @param reference - The asset reference to rebind, modified in place
|
|
4963
|
+
* @param newContext - The new context managed object to bind to
|
|
4964
|
+
* @param oldContext - The old context managed object to replace
|
|
4965
|
+
* @returns The same reference, rebound when it matched the old context
|
|
4966
|
+
*/
|
|
4967
|
+
function replaceContextInAssetReference(reference, newContext, oldContext) {
|
|
4968
|
+
if (reference && referencesOldContext(reference.id, oldContext)) {
|
|
4969
|
+
Object.assign(reference, pick(newContext, ['id', 'name']));
|
|
4970
|
+
}
|
|
4971
|
+
return reference;
|
|
4972
|
+
}
|
|
4973
|
+
|
|
4925
4974
|
const IDENTIFIER_REGEX = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
4975
|
+
/**
|
|
4976
|
+
* Replaces context IDs in per-placeholder asset property mappings (see `AssetPropertyMappings`).
|
|
4977
|
+
*
|
|
4978
|
+
* Each mapping's `assetProperty.asset` identifies the asset/device/group that placeholder is
|
|
4979
|
+
* bound to, which can differ from the widget's primary `device`. Computed properties
|
|
4980
|
+
* additionally carry a `contextAssetId` that mirrors `asset.id`, and reference the source of
|
|
4981
|
+
* their measurements through `config.dp[].__target`. All of them need to be replaced when a
|
|
4982
|
+
* widget's config is reused in a new context, otherwise the pasted placeholder keeps reading
|
|
4983
|
+
* from the asset it was originally bound to. Mappings with a `null` `assetProperty` (unmapped
|
|
4984
|
+
* placeholders) are left untouched.
|
|
4985
|
+
*
|
|
4986
|
+
* @param mappings - Map of placeholder name to asset property mapping
|
|
4987
|
+
* @param newContext - The new context managed object containing the ID to replace with
|
|
4988
|
+
* @param oldContext - The old context managed object containing the ID to replace
|
|
4989
|
+
* @returns The same mappings object, with matching asset references replaced in place
|
|
4990
|
+
*/
|
|
4991
|
+
function replaceContextInAssetPropertyMappings(mappings, newContext, oldContext) {
|
|
4992
|
+
forEach(mappings, mapping => {
|
|
4993
|
+
const assetProperty = mapping?.assetProperty;
|
|
4994
|
+
if (!assetProperty) {
|
|
4995
|
+
return;
|
|
4996
|
+
}
|
|
4997
|
+
replaceContextInAssetReference(assetProperty.asset, newContext, oldContext);
|
|
4998
|
+
if (referencesOldContext(assetProperty.contextAssetId, oldContext)) {
|
|
4999
|
+
assetProperty.contextAssetId = newContext.id;
|
|
5000
|
+
}
|
|
5001
|
+
forEach(assetProperty.config?.dp, dataPoint => replaceContextInAssetReference(dataPoint?.__target, newContext, oldContext));
|
|
5002
|
+
});
|
|
5003
|
+
return mappings;
|
|
5004
|
+
}
|
|
4926
5005
|
function stripC8yPrefix(s) {
|
|
4927
5006
|
return s.startsWith('c8y_') ? s.slice(4) : s;
|
|
4928
5007
|
}
|
|
@@ -5317,5 +5396,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
|
|
|
5317
5396
|
* Generated bundle index. Do not edit.
|
|
5318
5397
|
*/
|
|
5319
5398
|
|
|
5320
|
-
export { ALL_GLOBAL_ROLES_SELECTED, APPLIED_TO_APPLICATIONS_FRAGMENT, AddDashboardComponent, AddDashboardFactory, AppearanceSettingsComponent, AssetPropertyMappingsComponent, AssetPropertyMappingsService, CONTEXT_DASHBOARD_CONFIG, ContextDashboardComponent, ContextDashboardModule, ContextDashboardService, ContextDashboardType, DASHBOARD_CHILDREN_STATE_NAME, DASHBOARD_DETAILS_OUTLET, DASHBOARD_DETAILS_TABS_OUTLET_NAME, DASHBOARD_FOUNDATION_MAP, DASHBOARD_SETTINGS_CHANGES, DASHBOARD_THEME_CLASSES, DashboardActionBarFactory, DashboardDetailComponent, DashboardDetailService, DashboardDetailsTabId, DeviceInfoDashboardComponent, DeviceInfoDashboardModule, DeviceManagementHomeDashboardComponent, DeviceManagementHomeDashboardModule, FOUNDATION_CLASSES, GlobalContextSectionComponent, HOOK_WIDGET_CONFIG, NewDashboardGuard, PRODUCT_EXPERIENCE, PasteDashboardActionComponent, REPORT_DEFAULT_NAVIGATION_NODE_PRIORITY, STYLING_CLASS_PREFIXES, THEME_FOUNDATION_MAP, TypeDashboardInfoComponent, WIDGET_CONTENT_CLASSES, WIDGET_FOUNDATION_MAP, WIDGET_HEADER_CLASSES, WidgetAssetSelectorComponent, WidgetConfigAppearanceComponent, WidgetConfigChangeMode, WidgetConfigComponent, WidgetConfigFeedbackComponent, WidgetConfigGeneralComponent, WidgetConfigSectionComponent, WidgetConfigSectionService, WidgetConfigService, WidgetPreviewComponent, WidgetPreviewWrapperComponent, WidgetService, applyEntitySharing, escapeForRegExp, getPropertyBaseKey, getSharedApplicationKeys, hookWidgetConfig, newDashboardTab, quoteAndEscape, renamePropertyKeyInCode };
|
|
5399
|
+
export { ALL_GLOBAL_ROLES_SELECTED, APPLIED_TO_APPLICATIONS_FRAGMENT, AddDashboardComponent, AddDashboardFactory, AppearanceSettingsComponent, AssetPropertyMappingsComponent, AssetPropertyMappingsService, CONTEXT_DASHBOARD_CONFIG, ContextDashboardComponent, ContextDashboardModule, ContextDashboardService, ContextDashboardType, DASHBOARD_CHILDREN_STATE_NAME, DASHBOARD_DETAILS_OUTLET, DASHBOARD_DETAILS_TABS_OUTLET_NAME, DASHBOARD_FOUNDATION_MAP, DASHBOARD_SETTINGS_CHANGES, DASHBOARD_THEME_CLASSES, DashboardActionBarFactory, DashboardDetailComponent, DashboardDetailService, DashboardDetailsTabId, DeviceInfoDashboardComponent, DeviceInfoDashboardModule, DeviceManagementHomeDashboardComponent, DeviceManagementHomeDashboardModule, FOUNDATION_CLASSES, GlobalContextSectionComponent, HOOK_WIDGET_CONFIG, NewDashboardGuard, PRODUCT_EXPERIENCE, PasteDashboardActionComponent, REPORT_DEFAULT_NAVIGATION_NODE_PRIORITY, STYLING_CLASS_PREFIXES, THEME_FOUNDATION_MAP, TypeDashboardInfoComponent, WIDGET_CONTENT_CLASSES, WIDGET_FOUNDATION_MAP, WIDGET_HEADER_CLASSES, WidgetAssetSelectorComponent, WidgetConfigAppearanceComponent, WidgetConfigChangeMode, WidgetConfigComponent, WidgetConfigFeedbackComponent, WidgetConfigGeneralComponent, WidgetConfigSectionComponent, WidgetConfigSectionService, WidgetConfigService, WidgetPreviewComponent, WidgetPreviewWrapperComponent, WidgetService, applyEntitySharing, escapeForRegExp, getPropertyBaseKey, getSharedApplicationKeys, hookWidgetConfig, newDashboardTab, quoteAndEscape, referencesOldContext, renamePropertyKeyInCode, replaceContextInAssetPropertyMappings, replaceContextInAssetReference };
|
|
5321
5400
|
//# sourceMappingURL=c8y-ngx-components-context-dashboard.mjs.map
|