UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

183 lines (177 loc) • 6.35 kB
import { gettext } from '@c8y/ngx-components/gettext'; import { DynamicComponentErrorStrategy, DynamicManagedObjectResolver, hookWidget } from '@c8y/ngx-components'; import { hookWidgetConfig } from '@c8y/ngx-components/context-dashboard'; import { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions'; import { importConfigWithDevice, exportConfigWithDevice } from '@c8y/ngx-components/widgets/import-export-config'; import { defineWidgetControls, GLOBAL_CONTEXT_DISPLAY_MODE, REFRESH_OPTION } from '@c8y/ngx-components/global-context'; const mapWidgetControls = defineWidgetControls({ name: 'map-widget', supports: ['liveRefresh', 'displayMode', 'refreshInterval', 'refreshOption'], supportedModes: [REFRESH_OPTION.LIVE], settings: { dashboard: { live: { inline: { showAutoRefresh: true } }, history: { inline: { showRefresh: true } } }, config: { live: { inline: { showAutoRefresh: false, showRefresh: true, showRefreshInterval: false }, configuration: { showAutoRefresh: true, showRefreshInterval: true, showTimeContext: false } }, history: { inline: { showTimeContext: true }, configuration: { showTimeContext: true } } }, viewAndConfig: { live: { inline: { showAutoRefresh: true, showRefreshInterval: false, showTimeContext: false }, configuration: { showAutoRefresh: true, showRefreshInterval: true, showTimeContext: false } }, history: { inline: { showRefresh: true }, configuration: {} } }, defaultLinks: { config: {}, dashboard: { live: { isAutoRefreshEnabled: true }, history: {} }, viewAndConfig: {} } }, handlers: { startFollow: { handler: () => ({ inlineControlSettings: { showAutoRefresh: false }, dashboardControlSettings: { showAutoRefresh: false }, links: {}, options: undefined }) }, stopFollow: { handler: state => { const { config } = state; const displayMode = config.displayMode || GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD; const refreshOption = config.refreshOption || REFRESH_OPTION.LIVE; const isDashboardMode = displayMode === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD; if (isDashboardMode) { return { inlineControlSettings: refreshOption === REFRESH_OPTION.LIVE ? { showAutoRefresh: false } : { showAutoRefresh: true }, dashboardControlSettings: { showAutoRefresh: false }, links: refreshOption === REFRESH_OPTION.LIVE ? { isAutoRefreshEnabled: true } : { isAutoRefreshEnabled: false }, options: undefined }; } return { inlineControlSettings: {}, dashboardControlSettings: {}, links: {}, options: undefined }; } }, disableCounter: { handler: () => ({ inlineControlSettings: {}, dashboardControlSettings: {}, links: {}, options: { noAutoRefreshCounter: true } }) } } }); const mapWidgetDefinition = { id: defaultWidgetIds.MAP, label: gettext('Map'), description: gettext('Shows the position of a device or all devices in a group.'), loadComponent: () => import('@c8y/ngx-components/widgets/implementations/map').then(m => m.MapWidgetComponent), loadConfigComponent: () => import('@c8y/ngx-components/widgets/implementations/map').then(m => m.MapWidgetConfigComponent), /*providers: [ ],*/ resolve: { device: DynamicManagedObjectResolver }, previewImage: 'c8y-style-assets/map-widget-pr.png', errorStrategy: DynamicComponentErrorStrategy.OVERLAY_ERROR, data: { schema: () => import('c8y-schema-loader?interfaceName=MapWidgetConfig&type=widget-config!@c8y/ngx-components/widgets/implementations/map'), export: exportConfigWithDevice, import: importConfigWithDevice, widgetControls: mapWidgetControls, settings: { noNewWidgets: false, widgetDefaults: { _width: 8, _height: 4 }, ng1: { options: { noDeviceTarget: false, groupsSelectable: true, deviceTargetNotRequired: true } } }, displaySettings: { globalTimeContext: false, globalAutoRefreshContext: true, globalRealtimeContext: true } } }; const mapWidgetProviders = [ hookWidget(mapWidgetDefinition), hookWidgetConfig({ widgetId: defaultWidgetIds.MAP, priority: 10, label: gettext('Time context'), initialState: { widgetControls: mapWidgetControls }, loadComponent: () => import('@c8y/ngx-components/context-dashboard').then(m => m.GlobalContextSectionComponent) }) ]; /** * Generated bundle index. Do not edit. */ export { mapWidgetDefinition, mapWidgetProviders }; //# sourceMappingURL=c8y-ngx-components-widgets-definitions-map.mjs.map