UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

1 lines 4.5 kB
{"version":3,"file":"c8y-ngx-components-widgets-definitions-alarms-alarm-widget-controls.presets.mjs","sources":["../../widgets/definitions/alarms/alarm-widget-controls.presets/alarm-widget-controls.presets.ts","../../widgets/definitions/alarms/alarm-widget-controls.presets/c8y-ngx-components-widgets-definitions-alarms-alarm-widget-controls.presets.ts"],"sourcesContent":["import { merge } from 'lodash-es';\n\nimport {\n GLOBAL_CONTEXT_DISPLAY_MODE,\n REFRESH_OPTION,\n type WidgetControls,\n buildWidgetControlsFromPresets\n} from '@c8y/ngx-components/global-context';\nimport { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions';\n\nconst getBaselineControls = () => buildWidgetControlsFromPresets({ presets: ['default'] });\n\n/**\n * Produces the baseline alarm list controls preset mirroring the default\n * widget behaviour.\n *\n * @returns Fresh baseline controls instance for the alarm list widget.\n */\nexport function createAlarmListControls(): WidgetControls {\n return getBaselineControls();\n}\n\n/**\n * Produces the legacy alarm controls preset shared by the \"recent\" and\n * \"critical\" alarm widgets. It hides the refresh interval and exposes the\n * manual refresh button inline.\n *\n * @returns Alarm controls tailored for legacy alarm widgets.\n */\nexport function createLegacyAlarmControls(): WidgetControls {\n return mergeWithBaseline({\n configSettings: {\n [GLOBAL_CONTEXT_DISPLAY_MODE.CONFIG]: {\n [REFRESH_OPTION.HISTORY]: {\n showTimeContext: true,\n showAggregation: false\n }\n },\n [GLOBAL_CONTEXT_DISPLAY_MODE.VIEW_AND_CONFIG]: {\n [REFRESH_OPTION.HISTORY]: {\n showTimeContext: true,\n showAggregation: false\n }\n }\n },\n settings: {\n [GLOBAL_CONTEXT_DISPLAY_MODE.CONFIG]: {\n [REFRESH_OPTION.LIVE]: {\n showRefreshInterval: false,\n showRefresh: true\n },\n [REFRESH_OPTION.HISTORY]: {\n showTimeContext: true,\n showAggregation: false\n }\n },\n [GLOBAL_CONTEXT_DISPLAY_MODE.VIEW_AND_CONFIG]: {\n [REFRESH_OPTION.HISTORY]: {\n showTimeContext: true,\n showAggregation: false\n }\n }\n }\n });\n}\n\n/**\n * Helper that clones the baseline controls and applies the provided overrides.\n *\n * @param overrides Partial control information to merge into the baseline.\n * @returns Combined control definition.\n */\nfunction mergeWithBaseline(overrides: Partial<WidgetControls>): WidgetControls {\n return merge(getBaselineControls(), overrides);\n}\n\n/**\n * Resolves the appropriate controls preset based on the widget identifier.\n *\n * @param widgetId Optional widget id coming from the widget config/definition.\n * @returns Fully materialised controls for the widget.\n */\nexport function resolveAlarmControls(widgetId?: string): WidgetControls {\n switch (widgetId) {\n case defaultWidgetIds.ALL_CRITICAL_ALARMS:\n case defaultWidgetIds.RECENT_ALARMS:\n return createLegacyAlarmControls();\n default:\n return createAlarmListControls();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAUA,MAAM,mBAAmB,GAAG,MAAM,8BAA8B,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;AAE1F;;;;;AAKG;SACa,uBAAuB,GAAA;IACrC,OAAO,mBAAmB,EAAE;AAC9B;AAEA;;;;;;AAMG;SACa,yBAAyB,GAAA;AACvC,IAAA,OAAO,iBAAiB,CAAC;AACvB,QAAA,cAAc,EAAE;AACd,YAAA,CAAC,2BAA2B,CAAC,MAAM,GAAG;AACpC,gBAAA,CAAC,cAAc,CAAC,OAAO,GAAG;AACxB,oBAAA,eAAe,EAAE,IAAI;AACrB,oBAAA,eAAe,EAAE;AAClB;AACF,aAAA;AACD,YAAA,CAAC,2BAA2B,CAAC,eAAe,GAAG;AAC7C,gBAAA,CAAC,cAAc,CAAC,OAAO,GAAG;AACxB,oBAAA,eAAe,EAAE,IAAI;AACrB,oBAAA,eAAe,EAAE;AAClB;AACF;AACF,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,CAAC,2BAA2B,CAAC,MAAM,GAAG;AACpC,gBAAA,CAAC,cAAc,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