@c8y/tutorial 1019.0.3
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/.browserslistrc +16 -0
- package/NOTICES +41743 -0
- package/cumulocity.config.ts +643 -0
- package/package.json +22 -0
- package/src/__mocks/README.md +73 -0
- package/src/__mocks/global-mocks/inventory.interceptor.ts +145 -0
- package/src/__mocks/global-mocks/measurements.interceptor.ts +58 -0
- package/src/__mocks/index.ts +5 -0
- package/src/__mocks/mock.model.ts +76 -0
- package/src/__mocks/mock.module.ts +121 -0
- package/src/__mocks/mock.realtime-subject.ts +68 -0
- package/src/__mocks/mock.realtime.ts +31 -0
- package/src/__mocks/mock.service.ts +113 -0
- package/src/__mocks/scoped-mocks/boilerplate.ts +54 -0
- package/src/__mocks/scoped-mocks/context-dashboard.ts +47 -0
- package/src/__mocks/scoped-mocks/device-data-grid.ts +44 -0
- package/src/__mocks/scoped-mocks/named-context-dashboard.ts +42 -0
- package/src/__mocks/scoped-mocks/server-side-data-grid.ts +47 -0
- package/src/__mocks/scoped-mocks/service-dashboard.ts +42 -0
- package/src/__mocks/utils/clean.realtime.ts +23 -0
- package/src/__mocks/utils/common.ts +114 -0
- package/src/__mocks/utils/generators/alarms.ts +30 -0
- package/src/__mocks/utils/generators/events.ts +14 -0
- package/src/__mocks/utils/generators/managedObjects.ts +208 -0
- package/src/__mocks/utils/generators/measurement.ts +22 -0
- package/src/__mocks/utils/generators/operations.ts +67 -0
- package/src/__mocks/utils/grid.ts +87 -0
- package/src/__mocks/utils/realtime.ts +59 -0
- package/src/alert/alert-example.components.html +110 -0
- package/src/alert/alert-example.components.ts +77 -0
- package/src/alert/alert-example.module.ts +21 -0
- package/src/app/app.module.ts +72 -0
- package/src/bootstrap.ts +19 -0
- package/src/branding/branding.less +78 -0
- package/src/client-interceptor/client-interceptor.module.ts +12 -0
- package/src/client-interceptor/client-interceptor.service.ts +61 -0
- package/src/client-interceptor/index.ts +1 -0
- package/src/component-styles/cascading-style-sheets-example/cascading-style-sheets-example.component.css +17 -0
- package/src/component-styles/cascading-style-sheets-example/cascading-style-sheets-example.component.ts +11 -0
- package/src/component-styles/cascading-style-sheets-example/cascading-style-sheets-example.module.ts +26 -0
- package/src/component-styles/leaner-style-sheets-example/leaner-style-sheets-example.component.less +14 -0
- package/src/component-styles/leaner-style-sheets-example/leaner-style-sheets-example.component.ts +11 -0
- package/src/component-styles/leaner-style-sheets-example/leaner-style-sheets-example.module.ts +26 -0
- package/src/component-styles/syntactically-awesome-style-sheets-example/syntactically-awesome-style-sheets-example.component.scss +13 -0
- package/src/component-styles/syntactically-awesome-style-sheets-example/syntactically-awesome-style-sheets-example.component.ts +11 -0
- package/src/component-styles/syntactically-awesome-style-sheets-example/syntactically-awesome-style-sheets-example.module.ts +26 -0
- package/src/dashboard/context-dashboard/context-dashboard.component.ts +32 -0
- package/src/dashboard/context-dashboard/context-dashboard.module.ts +22 -0
- package/src/dashboard/custom-dashboard/custom-dashboard.component.html +180 -0
- package/src/dashboard/custom-dashboard/custom-dashboard.component.ts +52 -0
- package/src/dashboard/custom-dashboard/custom-dashboard.module.ts +22 -0
- package/src/dashboard/index.ts +4 -0
- package/src/dashboard/named-context-dashboard/named-context-dashboard.component.ts +51 -0
- package/src/dashboard/named-context-dashboard/named-context-dashboard.module.ts +37 -0
- package/src/dashboard/service-dashboard/service-dashboard.component.ts +51 -0
- package/src/dashboard/service-dashboard/service-dashboard.module.ts +35 -0
- package/src/dashboard/widget-dashboard/widget-dashboard.component.ts +65 -0
- package/src/dashboard/widget-dashboard/widget-dashboard.module.ts +22 -0
- package/src/date-time-range/date-time-range-example.component.ts +109 -0
- package/src/date-time-range/date-time-range-example.module.ts +21 -0
- package/src/dynamic-forms/custom-element-example/custom-element-example.component.ts +70 -0
- package/src/dynamic-forms/custom-element-example/custom-element-example.module.ts +38 -0
- package/src/dynamic-forms/custom-element-example/types/checkbox/checkbox.type.component.html +26 -0
- package/src/dynamic-forms/custom-element-example/types/checkbox/checkbox.type.component.ts +21 -0
- package/src/dynamic-forms/dynamic-forms.module.ts +16 -0
- package/src/dynamic-forms/index.ts +2 -0
- package/src/dynamic-forms/introduction-example/introduction-example.component.ts +116 -0
- package/src/dynamic-forms/introduction-example/introduction-example.module.ts +24 -0
- package/src/dynamic-forms/json-schema-example/json-schema-example.component.html +33 -0
- package/src/dynamic-forms/json-schema-example/json-schema-example.component.ts +102 -0
- package/src/dynamic-forms/json-schema-example/json-schema-example.module.ts +24 -0
- package/src/for-of-directive/for-of-example.component.html +19 -0
- package/src/for-of-directive/for-of-example.component.ts +39 -0
- package/src/for-of-directive/for-of.module.ts +18 -0
- package/src/forms/form-validation/forms-validation.component.html +105 -0
- package/src/forms/form-validation/forms-validation.component.ts +52 -0
- package/src/forms/form-validation/forms.module.ts +22 -0
- package/src/forms/index.ts +1 -0
- package/src/grids/client-grid-example/client-grid-example.component.html +16 -0
- package/src/grids/client-grid-example/client-grid-example.component.ts +166 -0
- package/src/grids/client-grid-example/client-grid-example.module.ts +24 -0
- package/src/grids/client-grid-example/data.ts +427 -0
- package/src/grids/device-grid-example/device-grid-example.component.html +58 -0
- package/src/grids/device-grid-example/device-grid-example.component.ts +134 -0
- package/src/grids/device-grid-example/device-grid-example.module.ts +24 -0
- package/src/grids/grids-tabs.ts +37 -0
- package/src/grids/grids.module.ts +17 -0
- package/src/grids/index.ts +1 -0
- package/src/grids/server-grid-example/server-grid-example.component.html +26 -0
- package/src/grids/server-grid-example/server-grid-example.component.ts +121 -0
- package/src/grids/server-grid-example/server-grid-example.module.ts +24 -0
- package/src/grids/server-grid-example/server-grid-example.service.ts +266 -0
- package/src/grids/server-grid-example/type-data-grid-column/type.cell-renderer.component.ts +31 -0
- package/src/grids/server-grid-example/type-data-grid-column/type.data-grid-column.ts +47 -0
- package/src/grids/server-grid-example/type-data-grid-column/type.filtering-form-renderer.component.ts +107 -0
- package/src/grids/server-grid-example/type-data-grid-column/type.header-cell-renderer.component.ts +20 -0
- package/src/hello/hello.component.ts +55 -0
- package/src/hello/hello.module.ts +20 -0
- package/src/hello/index.ts +1 -0
- package/src/help/help-example.component.ts +23 -0
- package/src/help/help-example.module.ts +20 -0
- package/src/hooks/action/action.module.ts +34 -0
- package/src/hooks/action/action.ts +41 -0
- package/src/hooks/action/basic-view/basic-view.component.html +8 -0
- package/src/hooks/action/basic-view/basic-view.component.ts +18 -0
- package/src/hooks/action/index.ts +1 -0
- package/src/hooks/action/logout-action/logout-action.component.ts +18 -0
- package/src/hooks/action-bar/action-bar.module.ts +34 -0
- package/src/hooks/action-bar/action-bar.ts +28 -0
- package/src/hooks/action-bar/basic-view/basic-view.component.html +8 -0
- package/src/hooks/action-bar/basic-view/basic-view.component.ts +18 -0
- package/src/hooks/action-bar/index.ts +1 -0
- package/src/hooks/action-bar/refresh-element/refresh-element.component.html +15 -0
- package/src/hooks/action-bar/refresh-element/refresh-element.component.ts +21 -0
- package/src/hooks/breadcrumbs/basic-view/basic-view.component.html +7 -0
- package/src/hooks/breadcrumbs/basic-view/basic-view.component.ts +18 -0
- package/src/hooks/breadcrumbs/breadcrumbs.module.ts +34 -0
- package/src/hooks/breadcrumbs/breadcrumbs.ts +93 -0
- package/src/hooks/breadcrumbs/index.ts +1 -0
- package/src/hooks/component/basic-view/basic-view.component.html +11 -0
- package/src/hooks/component/basic-view/basic-view.component.ts +16 -0
- package/src/hooks/component/basic-view/simple.component.ts +8 -0
- package/src/hooks/component/component.module.ts +38 -0
- package/src/hooks/component/index.ts +1 -0
- package/src/hooks/drawer/index.ts +2 -0
- package/src/hooks/drawer/left-drawer-tutorial/left-drawer-tutorial.component.ts +8 -0
- package/src/hooks/drawer/left-drawer-tutorial/left-drawer.module.ts +10 -0
- package/src/hooks/drawer/right-drawer-tutorial/right-drawer-tutorial.component.ts +8 -0
- package/src/hooks/drawer/right-drawer-tutorial/right-drawer.module.ts +10 -0
- package/src/hooks/generic-wizard/index.ts +1 -0
- package/src/hooks/generic-wizard/minimal-setup/minimal-setup.component.ts +12 -0
- package/src/hooks/generic-wizard/minimal-setup/multiple-entries-one.component.ts +25 -0
- package/src/hooks/generic-wizard/minimal-setup/multiple-entries-two.component.ts +25 -0
- package/src/hooks/generic-wizard/minimal-setup/stepper-example.component.html +38 -0
- package/src/hooks/generic-wizard/minimal-setup/stepper-example.component.ts +33 -0
- package/src/hooks/generic-wizard/wizard-tabs.ts +22 -0
- package/src/hooks/generic-wizard/wizard.component.html +51 -0
- package/src/hooks/generic-wizard/wizard.component.ts +86 -0
- package/src/hooks/generic-wizard/wizard.module.ts +79 -0
- package/src/hooks/hooks.module.ts +19 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/navigator/index.ts +1 -0
- package/src/hooks/navigator/navigator.module.ts +21 -0
- package/src/hooks/navigator/navigator.ts +35 -0
- package/src/hooks/navigator/time-navigator-node/time-navigator-node.component.ts +19 -0
- package/src/hooks/navigator-route/basic-view/basic-view.component.html +7 -0
- package/src/hooks/navigator-route/basic-view/basic-view.component.ts +18 -0
- package/src/hooks/navigator-route/index.ts +1 -0
- package/src/hooks/navigator-route/navigator-route.module.ts +27 -0
- package/src/hooks/route/device/device-info.component.html +2 -0
- package/src/hooks/route/device/device-info.component.ts +13 -0
- package/src/hooks/route/device/device-tab-context.component.html +15 -0
- package/src/hooks/route/device/device-tab-context.component.ts +13 -0
- package/src/hooks/route/index.ts +1 -0
- package/src/hooks/route/random.guard.ts +12 -0
- package/src/hooks/route/route.module.ts +51 -0
- package/src/hooks/state/hook-state.module.ts +25 -0
- package/src/hooks/state/hook-with-service-example.component.html +29 -0
- package/src/hooks/state/hook-with-service-example.component.ts +36 -0
- package/src/hooks/stepper/basic-view/basic-view.component.html +17 -0
- package/src/hooks/stepper/basic-view/basic-view.component.ts +31 -0
- package/src/hooks/stepper/index.ts +4 -0
- package/src/hooks/stepper/stepper-hook.module.ts +53 -0
- package/src/hooks/stepper/steps/step1.component.html +24 -0
- package/src/hooks/stepper/steps/step1.component.ts +18 -0
- package/src/hooks/stepper/steps/step2.component.html +7 -0
- package/src/hooks/stepper/steps/step2.component.ts +11 -0
- package/src/hooks/tabs/awesome/awesome.component.html +7 -0
- package/src/hooks/tabs/awesome/awesome.component.ts +21 -0
- package/src/hooks/tabs/index.ts +1 -0
- package/src/hooks/tabs/outstanding/outstanding.component.html +22 -0
- package/src/hooks/tabs/outstanding/outstanding.component.ts +27 -0
- package/src/hooks/tabs/tab.ts +44 -0
- package/src/hooks/tabs/tabs.module.ts +37 -0
- package/src/hooks/version/custom-version-factory.service.ts +49 -0
- package/src/hooks/version/index.ts +1 -0
- package/src/hooks/version/version.module.ts +11 -0
- package/src/i18n.ts +18 -0
- package/src/input/range-input-example.component.ts +29 -0
- package/src/input/range-input-example.module.ts +19 -0
- package/src/lazy/component-one.component.ts +28 -0
- package/src/lazy/component-two.component.ts +17 -0
- package/src/lazy/index.ts +1 -0
- package/src/lazy/lazy-loaded.module.ts +21 -0
- package/src/lazy/lazy-routing.module.ts +21 -0
- package/src/lazy/lazy.hooks.ts +24 -0
- package/src/lazy-widget/index.ts +1 -0
- package/src/lazy-widget/lazy-widget-config/index.ts +1 -0
- package/src/lazy-widget/lazy-widget-config/lazy-widget-config.component.ts +10 -0
- package/src/lazy-widget/lazy-widget-view/index.ts +1 -0
- package/src/lazy-widget/lazy-widget-view/lazy-widget-view.component.ts +10 -0
- package/src/lazy-widget/lazy-widget.module.ts +27 -0
- package/src/list/index.ts +1 -0
- package/src/list/list/list-check/list-check.component.html +35 -0
- package/src/list/list/list-check/list-check.component.ts +47 -0
- package/src/list/list/list-check/list-check.module.ts +21 -0
- package/src/list/list/list-timeline/list-timeline.component.html +30 -0
- package/src/list/list/list-timeline/list-timeline.component.ts +46 -0
- package/src/list/list/list-timeline/list-timeline.module.ts +21 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-check/list-virtual-scroll-check.component.html +105 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-check/list-virtual-scroll-check.component.ts +70 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-check/list-virtual-scroll-check.module.ts +22 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-timeline/list-virtual-scroll-timeline.component.html +37 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-timeline/list-virtual-scroll-timeline.component.ts +69 -0
- package/src/list/list-virtual-scroll/list-virtual-scroll-timeline/list-virtual-scroll-timeline.module.ts +24 -0
- package/src/list/lists.module.ts +17 -0
- package/src/main.ts +23 -0
- package/src/maps/cluster-map/cluster-map-example.component.html +60 -0
- package/src/maps/cluster-map/cluster-map-example.component.ts +39 -0
- package/src/maps/cluster-map/cluster-map-example.module.ts +24 -0
- package/src/maps/cluster-map-root-node/cluster-map-root-node-example.component.html +54 -0
- package/src/maps/cluster-map-root-node/cluster-map-root-node-example.component.ts +54 -0
- package/src/maps/cluster-map-root-node/cluster-map-root-node-example.module.ts +26 -0
- package/src/maps/map-examples.module.ts +18 -0
- package/src/maps/map-popup/map-popup-example.component.html +34 -0
- package/src/maps/map-popup/map-popup-example.component.ts +43 -0
- package/src/maps/map-popup/map-popup-example.module.ts +24 -0
- package/src/maps/simple-map/simple-map-example.component.html +59 -0
- package/src/maps/simple-map/simple-map-example.component.ts +70 -0
- package/src/maps/simple-map/simple-map-example.module.ts +24 -0
- package/src/modal/confirm-modal/confirm-modal-example.component.ts +69 -0
- package/src/modal/confirm-modal/confirm-modal-example.module.ts +22 -0
- package/src/modal/ngx-modal/ngx-modal-example.component.ts +34 -0
- package/src/modal/ngx-modal/ngx-modal-example.module.ts +22 -0
- package/src/modal/simple-modal/modal-example.component.ts +34 -0
- package/src/modal/simple-modal/modal.example.module.ts +21 -0
- package/src/polyfills.ts +33 -0
- package/src/popconfirm/pop-confirm-example.component.ts +61 -0
- package/src/popconfirm/pop-confirm-example.module.ts +23 -0
- package/src/properties-list/properties-list-example.component.ts +49 -0
- package/src/properties-list/properties-list-example.module.ts +21 -0
- package/src/provider-configuration/index.ts +3 -0
- package/src/provider-configuration/introduction-example/introduction.component.ts +69 -0
- package/src/provider-configuration/introduction-example/introduction.module.ts +21 -0
- package/src/provider-configuration/provider-configuration-example/demo-provider.guard.ts +9 -0
- package/src/provider-configuration/provider-configuration-example/provider-configuration.module.ts +48 -0
- package/src/quick-link/quick-link-example.component.ts +39 -0
- package/src/quick-link/quick-link-example.module.ts +23 -0
- package/src/realtime/index.ts +1 -0
- package/src/realtime/realtime-tutorial.component.html +52 -0
- package/src/realtime/realtime-tutorial.component.ts +91 -0
- package/src/realtime/realtime-tutorial.module.ts +21 -0
- package/src/redirect-to-last-route/index.ts +1 -0
- package/src/redirect-to-last-route/redirect-to-last-route-guard.service.ts +16 -0
- package/src/redirect-to-last-route/redirect-to-last-route.module.ts +20 -0
- package/src/redirect-to-last-route/view-context-redirect.service.ts +53 -0
- package/src/selector/asset-selector-example/child-devices/asset-selector-child-devices.component.ts +49 -0
- package/src/selector/asset-selector-example/child-devices/asset-selector-child-devices.module.ts +24 -0
- package/src/selector/asset-selector-example/column-header/asset-selector-column-header.component.ts +46 -0
- package/src/selector/asset-selector-example/column-header/asset-selector-column-header.module.ts +24 -0
- package/src/selector/asset-selector-example/different-root/asset-selector-different-root.component.ts +87 -0
- package/src/selector/asset-selector-example/different-root/asset-selector-different-root.module.ts +24 -0
- package/src/selector/asset-selector-example/general-example/asset-selector-example.component.html +342 -0
- package/src/selector/asset-selector-example/general-example/asset-selector-example.component.ts +34 -0
- package/src/selector/asset-selector-example/general-example/asset-selector-example.module.ts +22 -0
- package/src/selector/asset-selector-example/global-search/asset-selector-global-search.component.ts +50 -0
- package/src/selector/asset-selector-example/global-search/asset-selector-global-search.module.ts +24 -0
- package/src/selector/asset-selector-example/miller-columns-options/asset-selector-miller-example.component.ts +85 -0
- package/src/selector/asset-selector-example/miller-columns-options/asset-selector-miller-example.module.ts +26 -0
- package/src/selector/asset-selector-example/multi-select/asset-selector-multi-select.component.ts +50 -0
- package/src/selector/asset-selector-example/multi-select/asset-selector-multi-select.module.ts +24 -0
- package/src/selector/asset-selector-example/only-devices/asset-selector-only-devices.component.ts +44 -0
- package/src/selector/asset-selector-example/only-devices/asset-selector-only-devices.module.ts +24 -0
- package/src/selector/asset-selector-example/single-search/asset-selector-single-search.component.ts +71 -0
- package/src/selector/asset-selector-example/single-search/asset-selector-single-search.module.ts +24 -0
- package/src/selector/asset-selector-example/single-select/asset-selector-single-select.component.ts +47 -0
- package/src/selector/asset-selector-example/single-select/asset-single-select.module.ts +24 -0
- package/src/selector/asset-selector-example/tree-devices/asset-selector-tree-devices.component.ts +62 -0
- package/src/selector/asset-selector-example/tree-devices/asset-selector-tree-devices.module.ts +24 -0
- package/src/selector/asset-selector-example/tree-options/asset-selector-tree-example.component.ts +83 -0
- package/src/selector/asset-selector-example/tree-options/asset-selector-tree-example.module.ts +26 -0
- package/src/selector/asset-selector-example/tree-search/asset-selector-tree-search.component.ts +75 -0
- package/src/selector/asset-selector-example/tree-search/asset-selector-tree-search.module.ts +24 -0
- package/src/selector/asset-selector-example/tree-single/asset-selector-tree-single.component.ts +66 -0
- package/src/selector/asset-selector-example/tree-single/asset-selector-tree-single.module.ts +24 -0
- package/src/selector/datapoint-selection-example/context-example/datapoint-selection-context-example.component.ts +54 -0
- package/src/selector/datapoint-selection-example/context-example/datapoint-selection-context-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/dragdrop-example/datapoint-selection-dragdrop-example.component.ts +43 -0
- package/src/selector/datapoint-selection-example/dragdrop-example/datapoint-selection-dragdrop-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/general-example/datapoint-selection-example.component.html +202 -0
- package/src/selector/datapoint-selection-example/general-example/datapoint-selection-example.component.ts +51 -0
- package/src/selector/datapoint-selection-example/general-example/datapoint-selection-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/list-example/datapoint-selection-list-example.component.ts +42 -0
- package/src/selector/datapoint-selection-example/list-example/datapoint-selection-list-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/modal-example/datapoint-selection-modal-example.component.ts +51 -0
- package/src/selector/datapoint-selection-example/modal-example/datapoint-selection-modal-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/no-templates-example/datapoint-selection-notemplates-example.component.ts +43 -0
- package/src/selector/datapoint-selection-example/no-templates-example/datapoint-selection-notemplates-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/selector/datapoint-selection-selector-example.component.ts +43 -0
- package/src/selector/datapoint-selection-example/selector/datapoint-selection-selector-example.module.ts +24 -0
- package/src/selector/datapoint-selection-example/validation-example/datapoint-selection-validation-example.component.ts +46 -0
- package/src/selector/datapoint-selection-example/validation-example/datapoint-selection-validation-example.module.ts +24 -0
- package/src/standalone-demo/index.ts +1 -0
- package/src/standalone-demo/standalone-component/standalone-component.component.html +4 -0
- package/src/standalone-demo/standalone-component/standalone-component.component.ts +11 -0
- package/src/standalone-demo/standalone-demo.module.ts +23 -0
- package/src/stepper/device-stepper.component.html +70 -0
- package/src/stepper/device-stepper.component.ts +98 -0
- package/src/stepper/device.model.ts +5 -0
- package/src/stepper/index.ts +1 -0
- package/src/stepper/stepper.component.ts +19 -0
- package/src/stepper/stepper.module.ts +24 -0
- package/src/stepper/stepper.service.ts +32 -0
- package/src/time/time-picker-example.component.ts +19 -0
- package/src/time/time-picker-example.module.ts +21 -0
- package/src/translations/date-translation/c8y-translation/c8y-date-translation.component.ts +23 -0
- package/src/translations/date-translation/c8y-translation/c8y-date-translation.module.ts +22 -0
- package/src/translations/date-translation/ng-translation/date-translation.component.ts +17 -0
- package/src/translations/date-translation/ng-translation/date-translation.module.ts +22 -0
- package/src/translations/dynamic-form-translation/dynamic-form-translation.component.ts +58 -0
- package/src/translations/dynamic-form-translation/dynamic-form-translation.module.ts +22 -0
- package/src/translations/index.ts +1 -0
- package/src/translations/locales/it.po +18 -0
- package/src/translations/locales/pt_BR.po +33 -0
- package/src/translations/new-language/new-language.component.html +45 -0
- package/src/translations/new-language/new-language.component.ts +19 -0
- package/src/translations/new-language/new-language.module.ts +21 -0
- package/src/translations/new-translate/new-translation.component.html +92 -0
- package/src/translations/new-translate/new-translation.component.ts +9 -0
- package/src/translations/new-translate/new-translation.module.ts +22 -0
- package/src/translations/text-translation/gettext-translation/text-translation-gettext.component.ts +18 -0
- package/src/translations/text-translation/gettext-translation/text-translation-gettext.module.ts +22 -0
- package/src/translations/text-translation/ngNonBindable-translation/text-translation-ngnonbindable.component.ts +22 -0
- package/src/translations/text-translation/ngNonBindable-translation/text-translation-ngnonbindable.module.ts +24 -0
- package/src/translations/text-translation/service-translation/text-translation-by-service.component.ts +38 -0
- package/src/translations/text-translation/service-translation/text-translation-by-service.module.ts +24 -0
- package/src/translations/translation-tabs.ts +50 -0
- package/src/translations/translations.module.ts +18 -0
- package/src/user-menu/index.ts +1 -0
- package/src/user-menu/user-menu.module.ts +13 -0
- package/src/user-menu/user-menu.ts +26 -0
- package/src/widget/demo-widget-config.component.ts +81 -0
- package/src/widget/demo-widget.component.ts +35 -0
- package/src/widget/demo-widget.module.ts +47 -0
- package/src/widget/index.ts +1 -0
- package/src/widget-resolvers/alternative-event.resolver.ts +21 -0
- package/src/widget-resolvers/event-property.resolver.ts +52 -0
- package/src/widget-resolvers/event.resolver.ts +100 -0
- package/src/widget-resolvers/index.ts +1 -0
- package/src/widget-resolvers/widget-resolvers-config/widget-resolvers-config.component.html +31 -0
- package/src/widget-resolvers/widget-resolvers-config/widget-resolvers-config.component.ts +67 -0
- package/src/widget-resolvers/widget-resolvers.component.html +13 -0
- package/src/widget-resolvers/widget-resolvers.component.ts +37 -0
- package/src/widget-resolvers/widget-resolvers.module.ts +50 -0
- package/tsconfig.app.json +18 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { generateDevice } from '../utils/generators/managedObjects';
|
|
6
|
+
|
|
7
|
+
export class BoilerplateInterceptor implements HttpInterceptor {
|
|
8
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
9
|
+
return handleRequest(req, next, 'inventory/managedObjects', {
|
|
10
|
+
POST: this.mockPOST.bind(this),
|
|
11
|
+
PUT: this.mockPUT.bind(this),
|
|
12
|
+
GET: this.mockGET.bind(this)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mockPOST(_requestDescriptor: string) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mockPUT(_requestDescriptor: string) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private mockGET(_requestDescriptor: string) {
|
|
25
|
+
// TODO: ask Jan about clusters in the map.
|
|
26
|
+
const responseGenerators = this.getResponseGenerators();
|
|
27
|
+
|
|
28
|
+
for (const urlPart in responseGenerators) {
|
|
29
|
+
if (_requestDescriptor.includes(urlPart)) {
|
|
30
|
+
const generatorResult = responseGenerators[urlPart]();
|
|
31
|
+
if (generatorResult) {
|
|
32
|
+
return generateResponse(() => generatorResult);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private getResponseGenerators() {
|
|
40
|
+
return {
|
|
41
|
+
true: () => ({
|
|
42
|
+
managedObjects: [...[...Array(1)].map(() => generateDevice())],
|
|
43
|
+
statistics: {
|
|
44
|
+
totalPages: 201,
|
|
45
|
+
pageSize: 1,
|
|
46
|
+
currentPage: 1
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
'has(c8y_Position)': () => ({
|
|
50
|
+
managedObjects: [...[...Array(201)].map(() => generateDevice())]
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
5
|
+
import { generateDashboard } from '../../__mocks/utils/generators/managedObjects';
|
|
6
|
+
|
|
7
|
+
export class ContextDashboardInterceptor implements HttpInterceptor {
|
|
8
|
+
dashboard = generateDashboard();
|
|
9
|
+
|
|
10
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
11
|
+
return handleRequest(req, next, 'inventory/managedObjects', {
|
|
12
|
+
POST: this.mockPOST.bind(this),
|
|
13
|
+
PUT: this.mockPUT.bind(this),
|
|
14
|
+
GET: this.mockGET.bind(this)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private mockPOST(_requestDescriptor: string) {
|
|
19
|
+
return generateResponse(() => this.dashboard);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private mockPUT(_requestDescriptor: string) {
|
|
23
|
+
return generateResponse(() => this.dashboard);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private mockGET(_requestDescriptor: string) {
|
|
27
|
+
const responseGenerators = this.getResponseGenerators();
|
|
28
|
+
|
|
29
|
+
for (const urlPart in responseGenerators) {
|
|
30
|
+
if (_requestDescriptor.includes(urlPart)) {
|
|
31
|
+
const generatorResult = responseGenerators[urlPart]();
|
|
32
|
+
if (generatorResult) {
|
|
33
|
+
return generateResponse(() => generatorResult);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private getResponseGenerators() {
|
|
41
|
+
return {
|
|
42
|
+
'example-widget': () => ({
|
|
43
|
+
managedObjects: [this.dashboard]
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { generateDevice } from '../../__mocks/utils/generators/managedObjects';
|
|
6
|
+
|
|
7
|
+
export class DeviceDataGridInterceptor implements HttpInterceptor {
|
|
8
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
9
|
+
return handleRequest(req, next, 'inventory/managedObjects', {
|
|
10
|
+
POST: this.mockPOST.bind(this),
|
|
11
|
+
PUT: this.mockPUT.bind(this),
|
|
12
|
+
GET: this.mockGET.bind(this)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mockPOST(_requestDescriptor: string) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mockPUT(_requestDescriptor: string) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
private mockGET(_requestDescriptor: string) {
|
|
24
|
+
const responseGenerators = this.getResponseGenerators();
|
|
25
|
+
|
|
26
|
+
for (const urlPart in responseGenerators) {
|
|
27
|
+
if (_requestDescriptor.includes(urlPart)) {
|
|
28
|
+
const generatorResult = responseGenerators[urlPart]();
|
|
29
|
+
if (generatorResult) {
|
|
30
|
+
return generateResponse(() => generatorResult);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private getResponseGenerators() {
|
|
38
|
+
return {
|
|
39
|
+
pageSize: () => ({
|
|
40
|
+
managedObjects: [...[...Array(25)].map(() => generateDevice())]
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
5
|
+
import { generateDashboard } from '../../__mocks/utils/generators/managedObjects';
|
|
6
|
+
|
|
7
|
+
export class NamedContextDashboardInterceptor implements HttpInterceptor {
|
|
8
|
+
dashboard = generateDashboard({
|
|
9
|
+
id: '1000000',
|
|
10
|
+
name: 'myCustomDeviceDashboardName-3',
|
|
11
|
+
device: {
|
|
12
|
+
name: 'Device abc',
|
|
13
|
+
id: '200'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
18
|
+
return handleRequest(req, next, 'inventory/managedObjects', {
|
|
19
|
+
POST: this.mockPOST.bind(this),
|
|
20
|
+
PUT: this.mockPUT.bind(this),
|
|
21
|
+
GET: this.mockGET.bind(this)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private mockPOST(_requestDescriptor: string) {
|
|
26
|
+
if (_requestDescriptor.includes('childAdditions')) {
|
|
27
|
+
return generateResponse(() => this.dashboard);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private mockPUT(_requestDescriptor: string) {
|
|
33
|
+
if (/\/\d+/.test(_requestDescriptor)) {
|
|
34
|
+
return generateResponse(() => this.dashboard);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private mockGET(_requestDescriptor: string) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { generateRandomMo } from '../../__mocks/utils/generators/managedObjects';
|
|
6
|
+
import { filterObjects } from '../utils/grid';
|
|
7
|
+
|
|
8
|
+
export class ServerSideDataGridInterceptor implements HttpInterceptor {
|
|
9
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
10
|
+
return handleRequest(req, next, 'managedObjects', {
|
|
11
|
+
POST: this.mockPOST.bind(this),
|
|
12
|
+
PUT: this.mockPUT.bind(this),
|
|
13
|
+
GET: this.mockGET.bind(this)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
mockPOST(_requestDescriptor: string) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mockPUT(_requestDescriptor: string) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private mockGET(_requestDescriptor: string) {
|
|
26
|
+
const responseGenerators = this.getResponseGenerators();
|
|
27
|
+
|
|
28
|
+
for (const urlPart in responseGenerators) {
|
|
29
|
+
if (_requestDescriptor.includes(urlPart)) {
|
|
30
|
+
const generatorResult = responseGenerators[urlPart]();
|
|
31
|
+
if (generatorResult) {
|
|
32
|
+
const filteredData = filterObjects(generatorResult.managedObjects, _requestDescriptor);
|
|
33
|
+
return generateResponse(() => ({ managedObjects: filteredData }));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private getResponseGenerators() {
|
|
41
|
+
return {
|
|
42
|
+
pageSize: () => ({
|
|
43
|
+
managedObjects: [...[...Array(25)].map(() => generateRandomMo())]
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IFetchResponse } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler, HttpInterceptor } from '@c8y/ngx-components/api';
|
|
3
|
+
import { generateResponse, handleRequest } from '../utils/common';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { generateDashboard } from '../utils/generators/managedObjects';
|
|
6
|
+
|
|
7
|
+
export class ServiceDashboardInterceptor implements HttpInterceptor {
|
|
8
|
+
dashboard = generateDashboard({
|
|
9
|
+
id: '1000000',
|
|
10
|
+
name: 'myCustomDeviceDashboardName-3',
|
|
11
|
+
device: {
|
|
12
|
+
name: 'Service',
|
|
13
|
+
id: '<contextId>'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
18
|
+
return handleRequest(req, next, 'inventory/managedObjects', {
|
|
19
|
+
POST: this.mockPOST.bind(this),
|
|
20
|
+
PUT: this.mockPUT.bind(this),
|
|
21
|
+
GET: this.mockGET.bind(this)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
mockPOST(_requestDescriptor: string) {
|
|
26
|
+
if (_requestDescriptor.includes('childAdditions')) {
|
|
27
|
+
return generateResponse(() => this.dashboard);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
mockPUT(_requestDescriptor: string) {
|
|
33
|
+
if (/\/\d+/.test(_requestDescriptor)) {
|
|
34
|
+
return generateResponse(() => this.dashboard);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private mockGET(_requestDescriptor: string) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { OptionsService } from '@c8y/ngx-components';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
@Injectable({ providedIn: 'root' })
|
|
6
|
+
export class CleanRealtime {
|
|
7
|
+
stop$: Subject<void> = new Subject();
|
|
8
|
+
onDestroy$: Subject<void> = new Subject();
|
|
9
|
+
|
|
10
|
+
constructor(private options: OptionsService) {}
|
|
11
|
+
|
|
12
|
+
onDestroy() {
|
|
13
|
+
if (this.options.get<boolean>('noLogin', false) && this.onDestroy$) {
|
|
14
|
+
this.onDestroy$.next();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
stop() {
|
|
19
|
+
if (this.options.get<boolean>('noLogin', false) && this.stop$) {
|
|
20
|
+
this.stop$.next();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { IFetchResponse, ISource } from '@c8y/client';
|
|
2
|
+
import { ApiCall, HttpHandler } from '@c8y/ngx-components/api';
|
|
3
|
+
import { DEFAULT_STATISTICS, HttpMethods, ResponseWithType } from '../mock.model';
|
|
4
|
+
import { from } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles HTTP requests and provides mock responses based on the method type and URL path.
|
|
8
|
+
* This function is primarily designed to be used in HTTP interceptors.
|
|
9
|
+
*
|
|
10
|
+
* @param req - The incoming HTTP request to be handled. This request should be of `ApiCall` type.
|
|
11
|
+
* @param next - The next middleware function in the pipeline. If no matching handler is found, the request is passed to this next handler.
|
|
12
|
+
* @param urlPath - The URL path which will be used to determine if the request should be handled. If the request URL includes this path, a handler will be searched for.
|
|
13
|
+
* @param handlers - An object mapping HTTP methods to their respective handlers. These handlers are functions that accept a string argument (requestDescriptor), which is a combination of the request URL and any parameters or body, and return either a Promise or an object of `IFetchResponse` type.
|
|
14
|
+
*
|
|
15
|
+
* For example:
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* {
|
|
19
|
+
* POST: mockPOSTFunction,
|
|
20
|
+
* PUT: mockPUTFunction,
|
|
21
|
+
* GET: mockGETFunction,
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* If a handler is found for the HTTP method of the request, the handler function is called with the `requestDescriptor` as its argument.
|
|
26
|
+
* @returns An Observable which will either contain the response from the matched handler function or, if no handler is matched, the result of the `next.handle(req)` call.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* In the example below, all requests to inventory/managedObjects will pass through the interceptor.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* export class TestInterceptor implements HttpInterceptor {
|
|
33
|
+
* intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse> {
|
|
34
|
+
* return handleRequest(req, next, 'inventory/managedObjects', {
|
|
35
|
+
* POST: this.mockPOST.bind(this),
|
|
36
|
+
* PUT: this.mockPUT.bind(this),
|
|
37
|
+
* GET: this.mockGET.bind(this)
|
|
38
|
+
* });
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* mockPOST(_requestDescriptor: string) {
|
|
42
|
+
* return null;
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* mockPUT(_requestDescriptor: string) {
|
|
46
|
+
* return null;
|
|
47
|
+
* }
|
|
48
|
+
* ...
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function handleRequest(
|
|
53
|
+
req: ApiCall,
|
|
54
|
+
next: HttpHandler,
|
|
55
|
+
urlPath: string,
|
|
56
|
+
handlers: {
|
|
57
|
+
[method in HttpMethods]?: (
|
|
58
|
+
requestDescriptor: string
|
|
59
|
+
) => Promise<IFetchResponse> | IFetchResponse;
|
|
60
|
+
} = {}
|
|
61
|
+
): ReturnType<HttpHandler['handle']> {
|
|
62
|
+
let requestDescriptor = req?.url;
|
|
63
|
+
|
|
64
|
+
if (req?.options.params) {
|
|
65
|
+
requestDescriptor += JSON.stringify(req.options.params);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (req?.options?.body) {
|
|
69
|
+
requestDescriptor += req.options.body;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const { method = 'GET' } = req?.options || {};
|
|
73
|
+
|
|
74
|
+
if (requestDescriptor.includes(urlPath) && handlers[method]) {
|
|
75
|
+
const response = handlers[method](requestDescriptor);
|
|
76
|
+
return response ? from(Promise.resolve(response)) : next.handle(req);
|
|
77
|
+
}
|
|
78
|
+
return next.handle(req);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function generateId() {
|
|
82
|
+
return Math.floor(Math.random() * 100000).toString();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getFakeSource(): ISource {
|
|
86
|
+
return {
|
|
87
|
+
id: generateId(),
|
|
88
|
+
self: 'https://example.com/inventory/managedObjects/...'
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A utility function for generating mock responses with predefined status, body content, and statistics.
|
|
94
|
+
*
|
|
95
|
+
* @function generateResponse
|
|
96
|
+
*
|
|
97
|
+
* @template T - The type of the data that will be included in the response body.
|
|
98
|
+
*
|
|
99
|
+
* @param bodyGenerator - A function that generates the content of the body of the response.
|
|
100
|
+
* @param statistics - An optional parameter providing statistics for the response. Defaults to DEFAULT_STATISTICS.
|
|
101
|
+
*
|
|
102
|
+
* @returns A mock Response object with status 200 and a json method that resolves to a custom body object.
|
|
103
|
+
*/
|
|
104
|
+
export function generateResponse<T>(bodyGenerator: () => T, statistics = DEFAULT_STATISTICS) {
|
|
105
|
+
const newResponse = new Response(null, {
|
|
106
|
+
status: 200
|
|
107
|
+
});
|
|
108
|
+
newResponse.json = () =>
|
|
109
|
+
Promise.resolve({
|
|
110
|
+
...bodyGenerator(),
|
|
111
|
+
statistics
|
|
112
|
+
});
|
|
113
|
+
return newResponse as ResponseWithType<T & { statistics: typeof DEFAULT_STATISTICS }>;
|
|
114
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AlarmStatus, IAlarm, Severity } from '@c8y/client';
|
|
2
|
+
import { generateId, getFakeSource } from '../common';
|
|
3
|
+
|
|
4
|
+
export function getFakeAlarm(): IAlarm {
|
|
5
|
+
const severities: Severity[] = [
|
|
6
|
+
Severity.CRITICAL,
|
|
7
|
+
Severity.MAJOR,
|
|
8
|
+
Severity.MINOR,
|
|
9
|
+
Severity.WARNING
|
|
10
|
+
];
|
|
11
|
+
const statuses: AlarmStatus[] = [
|
|
12
|
+
AlarmStatus.ACKNOWLEDGED,
|
|
13
|
+
AlarmStatus.CLEARED,
|
|
14
|
+
AlarmStatus.ACTIVE
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
severity: severities[Math.floor(Math.random() * severities.length)] as Severity,
|
|
19
|
+
source: getFakeSource(),
|
|
20
|
+
type: `Type_${Math.floor(Math.random() * 1000)}`,
|
|
21
|
+
time: new Date().toISOString(),
|
|
22
|
+
text: `Text_${Math.floor(Math.random() * 1000)}`,
|
|
23
|
+
id: generateId(),
|
|
24
|
+
status: statuses[Math.floor(Math.random() * statuses.length)] as AlarmStatus,
|
|
25
|
+
count: Math.floor(Math.random() * 100),
|
|
26
|
+
name: `Name_${Math.floor(Math.random() * 1000)}`,
|
|
27
|
+
self: 'https://example.com/self/...}',
|
|
28
|
+
creationTime: new Date().toISOString()
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IEvent } from '@c8y/client';
|
|
2
|
+
import { generateId, getFakeSource } from '../common';
|
|
3
|
+
|
|
4
|
+
export function getFakeEvent(): IEvent {
|
|
5
|
+
return {
|
|
6
|
+
source: getFakeSource(),
|
|
7
|
+
type: `Type_${Math.floor(Math.random() * 1000)}`,
|
|
8
|
+
time: new Date().toISOString(),
|
|
9
|
+
text: `Text_${Math.floor(Math.random() * 1000)}`,
|
|
10
|
+
id: generateId(),
|
|
11
|
+
self: 'https://example.com/self/...',
|
|
12
|
+
creationTime: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { IManagedObject, IManagedObjectReferences } from '@c8y/client';
|
|
2
|
+
import { generateId } from '../common';
|
|
3
|
+
|
|
4
|
+
const cords = [
|
|
5
|
+
{
|
|
6
|
+
lat: '51.225324115117',
|
|
7
|
+
lng: '6.758050918579102'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
lat: '51.22446407082351',
|
|
11
|
+
lng: '6.75933837890625'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
lat: '51.22338899285697',
|
|
15
|
+
lng: '6.760711669921875'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
lat: '51.222152622151995',
|
|
19
|
+
lng: '6.762084960937499'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
lat: '51.2212387615908',
|
|
23
|
+
lng: '6.763544082641601'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
lat: '51.21994857461735',
|
|
27
|
+
lng: '6.765260696411133'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
lat: '51.21828202959081',
|
|
31
|
+
lng: '6.766977310180663'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
lat: '51.21731433059918',
|
|
35
|
+
lng: '6.769466400146484'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
lat: '51.21849707104884',
|
|
39
|
+
lng: '6.771183013916016'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
lat: '51.219034670299344',
|
|
43
|
+
lng: '6.772127151489258'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export function generateRealtimeDeviceMO(): IManagedObject {
|
|
48
|
+
return generateDevice<{ id: string; customFragment: string }>({
|
|
49
|
+
id: '1',
|
|
50
|
+
customFragment: 'customFragment'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function generateDevice<T>(customAttributes?: T): IManagedObject {
|
|
55
|
+
const randomPosition = Math.floor(Math.random() * 10);
|
|
56
|
+
return {
|
|
57
|
+
id: generateId(),
|
|
58
|
+
name: `Child_Device_${generateId()}`,
|
|
59
|
+
...getMOCommonProps(),
|
|
60
|
+
type: 'c8y_SensorPhone',
|
|
61
|
+
c8y_IsDevice: {},
|
|
62
|
+
c8y_Position: {
|
|
63
|
+
lng: cords[randomPosition].lng,
|
|
64
|
+
alt: 0,
|
|
65
|
+
accuracy: 10,
|
|
66
|
+
lat: cords[randomPosition].lat
|
|
67
|
+
},
|
|
68
|
+
...customAttributes
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function generateAsset<T>(customAttributes?: T): IManagedObject {
|
|
73
|
+
return {
|
|
74
|
+
id: generateId(),
|
|
75
|
+
name: `Asset_${generateId()}`,
|
|
76
|
+
...getMOCommonProps(),
|
|
77
|
+
type: 'building',
|
|
78
|
+
c8y_IsAsset: {},
|
|
79
|
+
c8y_IsDeviceGroup: {},
|
|
80
|
+
icon: {
|
|
81
|
+
name: 'hospital-o',
|
|
82
|
+
category: 'userInterface'
|
|
83
|
+
},
|
|
84
|
+
...customAttributes
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function generateAssetType<T>(customAttributes?: T): IManagedObject {
|
|
89
|
+
return {
|
|
90
|
+
id: generateId(),
|
|
91
|
+
name: 'building',
|
|
92
|
+
...getMOCommonProps(),
|
|
93
|
+
type: 'lemon',
|
|
94
|
+
c8y_IsAssetType: {
|
|
95
|
+
allowedAssetTypes: [
|
|
96
|
+
{
|
|
97
|
+
id: generateId()
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
isNoneChildAssetsAllowed: 'false',
|
|
101
|
+
icon: {
|
|
102
|
+
name: 'hospital-o',
|
|
103
|
+
category: 'userInterface'
|
|
104
|
+
},
|
|
105
|
+
properties: []
|
|
106
|
+
},
|
|
107
|
+
description: '...',
|
|
108
|
+
label: 'Building',
|
|
109
|
+
...customAttributes
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function generateGroup<T>(customAttributes?: T): IManagedObject {
|
|
114
|
+
return {
|
|
115
|
+
id: generateId(),
|
|
116
|
+
name: `Group_${generateId()}`,
|
|
117
|
+
...getMOCommonProps(),
|
|
118
|
+
type: 'c8y_DeviceGroup',
|
|
119
|
+
c8y_IsDeviceGroup: {},
|
|
120
|
+
...customAttributes
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function generateSubGroup<T>(customAttributes?: T): IManagedObject {
|
|
125
|
+
return generateGroup({
|
|
126
|
+
name: `Sub_Group_${generateId()}`,
|
|
127
|
+
type: 'c8y_DeviceSubgroup',
|
|
128
|
+
...customAttributes
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function generateRandomMo() {
|
|
133
|
+
const randomPosition = Math.floor(Math.random() * 3);
|
|
134
|
+
const generators = [generateAsset, generateSubGroup, generateDevice];
|
|
135
|
+
return generators[randomPosition]();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getMOCommonProps() {
|
|
139
|
+
return {
|
|
140
|
+
creationTime: new Date().toISOString(),
|
|
141
|
+
lastUpdated: new Date().toISOString(),
|
|
142
|
+
owner: 'owner1',
|
|
143
|
+
self: 'http://example.com/self/...',
|
|
144
|
+
additionParents: getFakeManagedObjectReferences(),
|
|
145
|
+
assetParents: getFakeManagedObjectReferences(),
|
|
146
|
+
childAdditions: getFakeManagedObjectReferences(),
|
|
147
|
+
childAssets: getFakeManagedObjectReferences(),
|
|
148
|
+
childDevices: getFakeManagedObjectReferences(),
|
|
149
|
+
deviceParents: getFakeManagedObjectReferences(),
|
|
150
|
+
['customFragment']: 'customData'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getFakeManagedObjectReferences(): IManagedObjectReferences {
|
|
155
|
+
return { references: [] };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function generateDashboard({
|
|
159
|
+
id = '6000',
|
|
160
|
+
name = 'example-widget',
|
|
161
|
+
globalRolesIds = undefined,
|
|
162
|
+
device = undefined
|
|
163
|
+
} = {}) {
|
|
164
|
+
const dashboard = {
|
|
165
|
+
id: id,
|
|
166
|
+
c8y_Global: {},
|
|
167
|
+
c8y_Dashboard: {
|
|
168
|
+
c8y_IsNavigatorNode: null,
|
|
169
|
+
children: {
|
|
170
|
+
[id]: {
|
|
171
|
+
componentId: 'angular.widget.demo',
|
|
172
|
+
_x: 3,
|
|
173
|
+
_y: 0,
|
|
174
|
+
id: id,
|
|
175
|
+
title: 'Hello',
|
|
176
|
+
_width: 6,
|
|
177
|
+
config: {
|
|
178
|
+
text: 'Welcome to a context dashboard'
|
|
179
|
+
},
|
|
180
|
+
_height: 6
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
widgetClasses: {
|
|
184
|
+
'dashboard-theme-light': true,
|
|
185
|
+
'panel-title-regular': true
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
[`c8y_Dashboard!name!${name}`]: {}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
if (globalRolesIds) {
|
|
192
|
+
(dashboard.c8y_Dashboard as any).globalRolesIds = globalRolesIds;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (device) {
|
|
196
|
+
(dashboard.c8y_Dashboard.children[id].config as any).device = device;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return dashboard;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function generateUserPreferences() {
|
|
203
|
+
return {
|
|
204
|
+
type: 'c8y_UserPreference',
|
|
205
|
+
id: generateId(),
|
|
206
|
+
language: 'en'
|
|
207
|
+
};
|
|
208
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IMeasurement, IMeasurementValue } from '@c8y/client';
|
|
2
|
+
import { generateId, getFakeSource } from '../common';
|
|
3
|
+
|
|
4
|
+
export function getFakeMeasurement(): IMeasurement {
|
|
5
|
+
return {
|
|
6
|
+
id: generateId(),
|
|
7
|
+
type: 'c8y_Temperature',
|
|
8
|
+
time: new Date().toISOString(),
|
|
9
|
+
self: 'https://example.com/measurement/measurements/...',
|
|
10
|
+
source: getFakeSource(),
|
|
11
|
+
c8y_Temperature: {
|
|
12
|
+
T: getFakeMeasurementValue()
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getFakeMeasurementValue(): IMeasurementValue {
|
|
18
|
+
return {
|
|
19
|
+
value: Math.random() * 100,
|
|
20
|
+
unit: `ºC`
|
|
21
|
+
};
|
|
22
|
+
}
|