@mxtommy/kip 1.2.3 → 1.3.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/.angulardoc.json +3 -3
- package/CHANGELOG.md +145 -135
- package/CONTRIBUTORS.md +16 -16
- package/README.md +102 -102
- package/angular.json +162 -153
- package/karma.conf.js +31 -31
- package/package.json +87 -84
- package/public/3rdpartylicenses.txt +301 -21
- package/public/assets/NoSleep.min.js +1 -1
- package/public/assets/fontawesome6/css/all.min.css +6 -0
- package/public/assets/fontawesome6/webfonts/fa-brands-400.ttf +0 -0
- package/public/assets/fontawesome6/webfonts/fa-brands-400.woff2 +0 -0
- package/public/assets/fontawesome6/webfonts/fa-regular-400.ttf +0 -0
- package/public/assets/fontawesome6/webfonts/fa-regular-400.woff2 +0 -0
- package/public/assets/fontawesome6/webfonts/fa-solid-900.ttf +0 -0
- package/public/assets/fontawesome6/webfonts/fa-solid-900.woff2 +0 -0
- package/public/assets/fontawesome6/webfonts/fa-v4compatibility.ttf +0 -0
- package/public/assets/fontawesome6/webfonts/fa-v4compatibility.woff2 +0 -0
- package/public/assets/icon-192x192.png +0 -0
- package/public/assets/icon-256x256.png +0 -0
- package/public/assets/icon-384x384.png +0 -0
- package/public/assets/icon-512x512.png +0 -0
- package/public/assets/steelseries-min.js +25 -25
- package/public/assets/steelseries-min.js.map +8 -8
- package/public/assets/steelseries.js +15834 -15834
- package/public/assets/svg-autopilot-inkscape-plain.svg +983 -983
- package/public/assets/svg-wind-inkscape.svg +1358 -1358
- package/public/assets/tween.js +381 -381
- package/public/index.html +19 -20
- package/public/main-es2018.98175eb4c61ccaf7eb17.js +1 -0
- package/public/main-es5.98175eb4c61ccaf7eb17.js +1 -0
- package/public/manifest.json +33 -0
- package/public/polyfills-es2018.3a61665863c173cd6ba3.js +1 -0
- package/public/polyfills-es5.44827ae4ff4e41de51fb.js +1 -0
- package/public/runtime-es2018.baedb88c6d2abacae2b8.js +1 -0
- package/public/runtime-es5.baedb88c6d2abacae2b8.js +1 -0
- package/public/styles.b92ae2c466c89712209d.css +5 -0
- package/src/app/alarm-menu/alarm-menu.component.html +55 -55
- package/src/app/alarm-menu/alarm-menu.component.scss +52 -53
- package/src/app/alarm-menu/alarm-menu.component.spec.ts +25 -25
- package/src/app/alarm-menu/alarm-menu.component.ts +186 -186
- package/src/app/app-help/app-help.component.css +4 -4
- package/src/app/app-help/app-help.component.html +135 -135
- package/src/app/app-help/app-help.component.ts +45 -45
- package/src/app/app.component.css +39 -39
- package/src/app/app.component.html +93 -93
- package/src/app/app.component.scss +79 -79
- package/src/app/app.component.spec.ts +32 -32
- package/src/app/app.component.ts +191 -192
- package/src/app/app.module.ts +200 -200
- package/src/app/config.blank.const.ts +51 -51
- package/src/app/config.blank.notification.const.ts +19 -19
- package/src/app/config.blank.units.const.ts +23 -23
- package/src/app/config.demo.const.ts +383 -383
- package/src/app/data-browser/data-browser.component.css +29 -29
- package/src/app/data-browser/data-browser.component.html +44 -44
- package/src/app/data-browser/data-browser.component.spec.ts +25 -25
- package/src/app/data-browser/data-browser.component.ts +91 -91
- package/src/app/data-browser-row/data-browser-row-unit-modal.html +17 -17
- package/src/app/data-browser-row/data-browser-row.component.css +9 -9
- package/src/app/data-browser-row/data-browser-row.component.html +4 -4
- package/src/app/data-browser-row/data-browser-row.component.ts +78 -78
- package/src/app/data-set.service.ts +273 -273
- package/src/app/dynamic-widget.directive.ts +11 -11
- package/src/app/gauge-steel/gauge-steel.component.css +4 -4
- package/src/app/gauge-steel/gauge-steel.component.html +4 -4
- package/src/app/gauge-steel/gauge-steel.component.spec.ts +25 -25
- package/src/app/gauge-steel/gauge-steel.component.ts +282 -282
- package/src/app/gauges-module/base-gauge.ts +300 -300
- package/src/app/gauges-module/linear-gauge.ts +49 -49
- package/src/app/gauges-module/radial-gauge.ts +47 -47
- package/src/app/layout-split/layout-split.component.html +30 -30
- package/src/app/layout-split/layout-split.component.scss +33 -33
- package/src/app/layout-split/layout-split.component.spec.ts +25 -25
- package/src/app/layout-split/layout-split.component.ts +59 -59
- package/src/app/layout-splits.service.ts +284 -284
- package/src/app/modal-path-selector/modal-path-selector.component.html +62 -62
- package/src/app/modal-path-selector/modal-path-selector.component.scss +39 -39
- package/src/app/modal-path-selector/modal-path-selector.component.spec.ts +25 -25
- package/src/app/modal-path-selector/modal-path-selector.component.ts +132 -132
- package/src/app/modal-widget/modal-widget.component.css +32 -32
- package/src/app/modal-widget/modal-widget.component.html +341 -341
- package/src/app/modal-widget/modal-widget.component.spec.ts +25 -25
- package/src/app/modal-widget/modal-widget.component.ts +84 -84
- package/src/app/notifications.service.ts +392 -392
- package/src/app/object-keys.pipe.spec.ts +8 -8
- package/src/app/object-keys.pipe.ts +13 -13
- package/src/app/reset-config/reset-config.component.html +3 -3
- package/src/app/reset-config/reset-config.component.spec.ts +25 -25
- package/src/app/reset-config/reset-config.component.ts +31 -31
- package/src/app/root-display/root-display.component.html +4 -4
- package/src/app/root-display/root-display.component.spec.ts +25 -25
- package/src/app/root-display/root-display.component.ts +57 -57
- package/src/app/safe.pipe.ts +15 -15
- package/src/app/settings/settings.component.css +9 -9
- package/src/app/settings/settings.component.html +25 -25
- package/src/app/settings/settings.component.spec.ts +25 -25
- package/src/app/settings/settings.component.ts +22 -22
- package/src/app/settings-config/settings-config.component.css +38 -38
- package/src/app/settings-config/settings-config.component.spec.ts +25 -25
- package/src/app/settings-config/settings-config.component.ts +161 -161
- package/src/app/settings-datasets/settings-datasets.component.html +43 -43
- package/src/app/settings-datasets/settings-datasets.component.scss +39 -39
- package/src/app/settings-datasets/settings-datasets.component.spec.ts +25 -25
- package/src/app/settings-datasets/settings-datasets.component.ts +98 -98
- package/src/app/settings-datasets/settings-datasets.modal.html +54 -54
- package/src/app/settings-notifications/settings-notifications.component.html +65 -65
- package/src/app/settings-notifications/settings-notifications.component.spec.ts +25 -25
- package/src/app/settings-notifications/settings-notifications.component.ts +29 -29
- package/src/app/settings-signalk/settings-signalk.component.html +8 -8
- package/src/app/settings-signalk/settings-signalk.component.spec.ts +25 -25
- package/src/app/settings-signalk/settings-signalk.component.ts +174 -174
- package/src/app/settings-units/settings-units.component.css +4 -4
- package/src/app/settings-units/settings-units.component.html +19 -19
- package/src/app/settings-units/settings-units.component.spec.ts +25 -25
- package/src/app/settings-units/settings-units.component.ts +62 -62
- package/src/app/settings-zones/settings-zones.component.css +21 -21
- package/src/app/settings-zones/settings-zones.component.html +70 -70
- package/src/app/settings-zones/settings-zones.modal.html +38 -38
- package/src/app/signalk-connection.service.ts +344 -344
- package/src/app/signalk-delta.service.spec.ts +15 -15
- package/src/app/signalk-delta.service.ts +97 -97
- package/src/app/signalk-full.service.ts +99 -99
- package/src/app/signalk-interfaces.ts +129 -129
- package/src/app/signalk-requests.service.spec.ts +12 -12
- package/src/app/signalk-requests.service.ts +180 -180
- package/src/app/svg-autopilot/svg-autopilot.component.html +1036 -1036
- package/src/app/svg-autopilot/svg-autopilot.component.spec.ts +25 -25
- package/src/app/svg-autopilot/svg-autopilot.component.ts +174 -174
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.html +119 -119
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.spec.ts +25 -25
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.ts +49 -49
- package/src/app/svg-wind/svg-wind.component.html +969 -969
- package/src/app/svg-wind/svg-wind.component.scss +76 -76
- package/src/app/svg-wind/svg-wind.component.spec.ts +25 -25
- package/src/app/svg-wind/svg-wind.component.ts +280 -280
- package/src/app/unit-window/unit-window.component.css +37 -37
- package/src/app/unit-window/unit-window.component.html +8 -8
- package/src/app/unit-window/unit-window.component.spec.ts +25 -25
- package/src/app/unit-window/unit-window.component.ts +134 -134
- package/src/app/unit-window/unit-window.modal.html +24 -24
- package/src/app/units.service.ts +300 -300
- package/src/app/widget-autopilot/widget-autopilot.component.html +78 -85
- package/src/app/widget-autopilot/widget-autopilot.component.scss +191 -191
- package/src/app/widget-autopilot/widget-autopilot.component.spec.ts +25 -25
- package/src/app/widget-autopilot/widget-autopilot.component.ts +774 -781
- package/src/app/widget-blank/widget-blank.component.scss +21 -22
- package/src/app/widget-blank/widget-blank.component.spec.ts +25 -25
- package/src/app/widget-blank/widget-blank.component.ts +17 -17
- package/src/app/widget-gauge/widget-gauge.component.css +25 -25
- package/src/app/widget-gauge/widget-gauge.component.html +29 -29
- package/src/app/widget-gauge/widget-gauge.component.spec.ts +25 -25
- package/src/app/widget-gauge/widget-gauge.component.ts +120 -120
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.html +126 -126
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.scss +94 -93
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.spec.ts +25 -25
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.ts +424 -424
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.html +1 -1
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.scss +69 -69
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.spec.ts +25 -25
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.ts +553 -553
- package/src/app/widget-historical/widget-historical.component.html +14 -14
- package/src/app/widget-historical/widget-historical.component.spec.ts +25 -25
- package/src/app/widget-historical/widget-historical.component.ts +306 -306
- package/src/app/widget-iframe/widget-iframe.component.css +11 -11
- package/src/app/widget-iframe/widget-iframe.component.html +21 -21
- package/src/app/widget-iframe/widget-iframe.component.spec.ts +25 -25
- package/src/app/widget-iframe/widget-iframe.component.ts +63 -63
- package/src/app/widget-list.service.ts +135 -135
- package/src/app/widget-manager.service.ts +141 -141
- package/src/app/widget-numeric/widget-numeric.component.html +1 -1
- package/src/app/widget-numeric/widget-numeric.component.scss +3 -3
- package/src/app/widget-numeric/widget-numeric.component.spec.ts +25 -25
- package/src/app/widget-simple-linear/widget-simple-linear.component.html +28 -28
- package/src/app/widget-simple-linear/widget-simple-linear.component.scss +64 -64
- package/src/app/widget-simple-linear/widget-simple-linear.component.spec.ts +25 -25
- package/src/app/widget-simple-linear/widget-simple-linear.component.ts +199 -199
- package/src/app/widget-state/widget-state.component.html +27 -27
- package/src/app/widget-state/widget-state.component.scss +68 -68
- package/src/app/widget-state/widget-state.component.spec.ts +25 -25
- package/src/app/widget-state/widget-state.component.ts +178 -178
- package/src/app/widget-switch/widget-switch.component.css +69 -69
- package/src/app/widget-switch/widget-switch.component.html +17 -17
- package/src/app/widget-switch/widget-switch.component.spec.ts +25 -25
- package/src/app/widget-switch/widget-switch.component.ts +134 -134
- package/src/app/widget-text-generic/widget-text-generic.component.html +9 -9
- package/src/app/widget-text-generic/widget-text-generic.component.spec.ts +25 -25
- package/src/app/widget-tutorial/widget-tutorial.component.html +34 -34
- package/src/app/widget-tutorial/widget-tutorial.component.spec.ts +25 -25
- package/src/app/widget-tutorial/widget-tutorial.component.ts +18 -18
- package/src/app/widget-unknown/widget-unknown.component.spec.ts +25 -25
- package/src/app/widget-wind/widget-wind.component.css +23 -23
- package/src/app/widget-wind/widget-wind.component.html +20 -20
- package/src/app/widget-wind/widget-wind.component.spec.ts +25 -25
- package/src/app/widget-wind/widget-wind.component.ts +369 -369
- package/src/assets/NoSleep.min.js +1 -1
- package/src/assets/fontawesome6/css/all.min.css +6 -0
- package/src/assets/fontawesome6/webfonts/fa-brands-400.ttf +0 -0
- package/src/assets/fontawesome6/webfonts/fa-brands-400.woff2 +0 -0
- package/src/assets/fontawesome6/webfonts/fa-regular-400.ttf +0 -0
- package/src/assets/fontawesome6/webfonts/fa-regular-400.woff2 +0 -0
- package/src/assets/fontawesome6/webfonts/fa-solid-900.ttf +0 -0
- package/src/assets/fontawesome6/webfonts/fa-solid-900.woff2 +0 -0
- package/src/assets/fontawesome6/webfonts/fa-v4compatibility.ttf +0 -0
- package/src/assets/fontawesome6/webfonts/fa-v4compatibility.woff2 +0 -0
- package/src/assets/icon-192x192.png +0 -0
- package/src/assets/icon-256x256.png +0 -0
- package/src/assets/icon-384x384.png +0 -0
- package/src/assets/icon-512x512.png +0 -0
- package/src/assets/steelseries-min.js +25 -25
- package/src/assets/steelseries-min.js.map +8 -8
- package/src/assets/steelseries.js +15834 -15834
- package/src/assets/svg-autopilot-inkscape-plain.svg +983 -983
- package/src/assets/svg-wind-inkscape.svg +1358 -1358
- package/src/assets/tween.js +381 -381
- package/src/index.html +20 -20
- package/src/main.ts +11 -11
- package/src/manifest.json +33 -0
- package/src/polyfills.ts +80 -76
- package/src/styles.scss +11 -11
- package/src/themes/darkBlueTheme.scss +117 -116
- package/src/themes/defaultTheme.scss +50 -49
- package/src/themes/highContrastTheme.scss +47 -46
- package/src/themes/modernTheme.scss +143 -142
- package/src/themes/nightMode.scss +185 -184
- package/src/themes/platypusTheme.scss +80 -79
- package/src/themes/signalkTheme.scss +112 -111
- package/src/tsconfig.app.json +15 -15
- package/src/tsconfig.spec.json +20 -20
- package/tsconfig.json +23 -23
- package/tslint.json +143 -143
- package/public/assets/font-awesome/HELP-US-OUT.txt +0 -7
- package/public/assets/font-awesome/css/font-awesome.css +0 -2337
- package/public/assets/font-awesome/css/font-awesome.min.css +0 -4
- package/public/assets/font-awesome/desktop.ini +0 -4
- package/public/assets/font-awesome/fonts/FontAwesome.otf +0 -0
- package/public/assets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/public/assets/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
- package/public/assets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/public/assets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/public/assets/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/public/assets/font-awesome/less/animated.less +0 -34
- package/public/assets/font-awesome/less/bordered-pulled.less +0 -25
- package/public/assets/font-awesome/less/core.less +0 -12
- package/public/assets/font-awesome/less/fixed-width.less +0 -6
- package/public/assets/font-awesome/less/font-awesome.less +0 -18
- package/public/assets/font-awesome/less/icons.less +0 -789
- package/public/assets/font-awesome/less/larger.less +0 -13
- package/public/assets/font-awesome/less/list.less +0 -19
- package/public/assets/font-awesome/less/mixins.less +0 -60
- package/public/assets/font-awesome/less/path.less +0 -15
- package/public/assets/font-awesome/less/rotated-flipped.less +0 -20
- package/public/assets/font-awesome/less/screen-reader.less +0 -5
- package/public/assets/font-awesome/less/stacked.less +0 -20
- package/public/assets/font-awesome/less/variables.less +0 -800
- package/public/assets/font-awesome/scss/_animated.scss +0 -34
- package/public/assets/font-awesome/scss/_bordered-pulled.scss +0 -25
- package/public/assets/font-awesome/scss/_core.scss +0 -12
- package/public/assets/font-awesome/scss/_fixed-width.scss +0 -6
- package/public/assets/font-awesome/scss/_icons.scss +0 -789
- package/public/assets/font-awesome/scss/_larger.scss +0 -13
- package/public/assets/font-awesome/scss/_list.scss +0 -19
- package/public/assets/font-awesome/scss/_mixins.scss +0 -60
- package/public/assets/font-awesome/scss/_path.scss +0 -15
- package/public/assets/font-awesome/scss/_rotated-flipped.scss +0 -20
- package/public/assets/font-awesome/scss/_screen-reader.scss +0 -5
- package/public/assets/font-awesome/scss/_stacked.scss +0 -20
- package/public/assets/font-awesome/scss/_variables.scss +0 -800
- package/public/assets/font-awesome/scss/font-awesome.scss +0 -18
- package/public/main-es2018.ab0adc5af3ab3e70c849.js +0 -1
- package/public/main-es5.ab0adc5af3ab3e70c849.js +0 -1
- package/public/polyfills-es2018.713f95af1f028e444854.js +0 -1
- package/public/polyfills-es5.c78877945523541d2597.js +0 -1
- package/public/runtime-es2018.a4dadbc03350107420a4.js +0 -1
- package/public/runtime-es5.a4dadbc03350107420a4.js +0 -1
- package/public/styles.71bb0d04cad96b5efbe1.css +0 -19
- package/src/assets/font-awesome/HELP-US-OUT.txt +0 -7
- package/src/assets/font-awesome/css/font-awesome.css +0 -2337
- package/src/assets/font-awesome/css/font-awesome.min.css +0 -4
- package/src/assets/font-awesome/desktop.ini +0 -4
- package/src/assets/font-awesome/fonts/FontAwesome.otf +0 -0
- package/src/assets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- package/src/assets/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
- package/src/assets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- package/src/assets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- package/src/assets/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- package/src/assets/font-awesome/less/animated.less +0 -34
- package/src/assets/font-awesome/less/bordered-pulled.less +0 -25
- package/src/assets/font-awesome/less/core.less +0 -12
- package/src/assets/font-awesome/less/fixed-width.less +0 -6
- package/src/assets/font-awesome/less/font-awesome.less +0 -18
- package/src/assets/font-awesome/less/icons.less +0 -789
- package/src/assets/font-awesome/less/larger.less +0 -13
- package/src/assets/font-awesome/less/list.less +0 -19
- package/src/assets/font-awesome/less/mixins.less +0 -60
- package/src/assets/font-awesome/less/path.less +0 -15
- package/src/assets/font-awesome/less/rotated-flipped.less +0 -20
- package/src/assets/font-awesome/less/screen-reader.less +0 -5
- package/src/assets/font-awesome/less/stacked.less +0 -20
- package/src/assets/font-awesome/less/variables.less +0 -800
- package/src/assets/font-awesome/scss/_animated.scss +0 -34
- package/src/assets/font-awesome/scss/_bordered-pulled.scss +0 -25
- package/src/assets/font-awesome/scss/_core.scss +0 -12
- package/src/assets/font-awesome/scss/_fixed-width.scss +0 -6
- package/src/assets/font-awesome/scss/_icons.scss +0 -789
- package/src/assets/font-awesome/scss/_larger.scss +0 -13
- package/src/assets/font-awesome/scss/_list.scss +0 -19
- package/src/assets/font-awesome/scss/_mixins.scss +0 -60
- package/src/assets/font-awesome/scss/_path.scss +0 -15
- package/src/assets/font-awesome/scss/_rotated-flipped.scss +0 -20
- package/src/assets/font-awesome/scss/_screen-reader.scss +0 -5
- package/src/assets/font-awesome/scss/_stacked.scss +0 -20
- package/src/assets/font-awesome/scss/_variables.scss +0 -800
- package/src/assets/font-awesome/scss/font-awesome.scss +0 -18
|
@@ -1,424 +1,424 @@
|
|
|
1
|
-
import { ViewChild, ElementRef, Component, OnInit, AfterContentInit, Input, OnDestroy } from '@angular/core';
|
|
2
|
-
import { Subscription } from 'rxjs';
|
|
3
|
-
import { MatDialog } from '@angular/material/dialog';
|
|
4
|
-
import { ResizedEvent } from 'angular-resize-event';
|
|
5
|
-
|
|
6
|
-
import { SignalKService } from '../signalk.service';
|
|
7
|
-
import { ModalWidgetComponent } from '../modal-widget/modal-widget.component';
|
|
8
|
-
import { WidgetManagerService, IWidget, IWidgetConfig } from '../widget-manager.service';
|
|
9
|
-
import { UnitsService } from '../units.service' ;
|
|
10
|
-
import { AppSettingsService, IZone, ZoneState } from '../app-settings.service';
|
|
11
|
-
import { LinearGauge, LinearGaugeOptions } from '@biacsics/ng-canvas-gauges';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const defaultConfig: IWidgetConfig = {
|
|
15
|
-
displayName: null,
|
|
16
|
-
filterSelfPaths: true,
|
|
17
|
-
paths: {
|
|
18
|
-
"gaugePath": {
|
|
19
|
-
description: "Numeric Data",
|
|
20
|
-
path: null,
|
|
21
|
-
source: null,
|
|
22
|
-
pathType: "number",
|
|
23
|
-
isPathConfigurable: true,
|
|
24
|
-
convertUnitTo: "unitless"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
gaugeType: 'ngLinearVertical', //ngLinearVertical or ngLinearHorizontal
|
|
28
|
-
gaugeTicks: false,
|
|
29
|
-
minValue: 0,
|
|
30
|
-
maxValue: 100,
|
|
31
|
-
numInt: 1,
|
|
32
|
-
numDecimal: 0,
|
|
33
|
-
barColor: 'accent',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
interface IDataHighlight extends Array<{
|
|
37
|
-
from : number;
|
|
38
|
-
to : number;
|
|
39
|
-
color: string;
|
|
40
|
-
}> {};
|
|
41
|
-
|
|
42
|
-
@Component({
|
|
43
|
-
selector: 'app-widget-gauge-ng-linear',
|
|
44
|
-
templateUrl: './widget-gauge-ng-linear.component.html',
|
|
45
|
-
styleUrls: ['./widget-gauge-ng-linear.component.scss']
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
export class WidgetGaugeNgLinearComponent implements OnInit, OnDestroy, AfterContentInit {
|
|
49
|
-
@ViewChild('linearWrapperDiv', {static: true, read: ElementRef}) private wrapper: ElementRef;
|
|
50
|
-
@ViewChild('linearGauge', {static: true, read: ElementRef}) protected linearGauge: ElementRef;
|
|
51
|
-
|
|
52
|
-
@Input('widgetUUID') widgetUUID: string;
|
|
53
|
-
@Input('unlockStatus') unlockStatus: boolean;
|
|
54
|
-
|
|
55
|
-
@ViewChild('primary', {static: true, read: ElementRef}) private primaryElement: ElementRef;
|
|
56
|
-
@ViewChild('accent', {static: true, read: ElementRef}) private accentElement: ElementRef;
|
|
57
|
-
@ViewChild('warn', {static: true, read: ElementRef}) private warnElement: ElementRef;
|
|
58
|
-
@ViewChild('primaryDark', {static: true, read: ElementRef}) private primaryDarkElement: ElementRef;
|
|
59
|
-
@ViewChild('accentDark', {static: true, read: ElementRef}) private accentDarkElement: ElementRef;
|
|
60
|
-
@ViewChild('warnDark', {static: true, read: ElementRef}) private warnDarkElement: ElementRef;
|
|
61
|
-
@ViewChild('background', {static: true, read: ElementRef}) private backgroundElement: ElementRef;
|
|
62
|
-
|
|
63
|
-
activeWidget: IWidget;
|
|
64
|
-
config: IWidgetConfig;
|
|
65
|
-
|
|
66
|
-
public dataValue = 0;
|
|
67
|
-
public dataValueTrimmed = 0;
|
|
68
|
-
|
|
69
|
-
valueSub: Subscription = null;
|
|
70
|
-
|
|
71
|
-
// dynamics theme support
|
|
72
|
-
themeNameSub: Subscription = null;
|
|
73
|
-
|
|
74
|
-
public gaugeOptions = {} as LinearGaugeOptions;
|
|
75
|
-
|
|
76
|
-
public isGaugeVertical: Boolean = true;
|
|
77
|
-
|
|
78
|
-
zones: Array<IZone> = [];
|
|
79
|
-
zonesSub: Subscription;
|
|
80
|
-
|
|
81
|
-
constructor(
|
|
82
|
-
public dialog:MatDialog,
|
|
83
|
-
private SignalKService: SignalKService,
|
|
84
|
-
private WidgetManagerService: WidgetManagerService,
|
|
85
|
-
private UnitsService: UnitsService,
|
|
86
|
-
private AppSettingsService: AppSettingsService, // need for theme change subscription
|
|
87
|
-
) {}
|
|
88
|
-
|
|
89
|
-
ngOnInit() {
|
|
90
|
-
this.activeWidget = this.WidgetManagerService.getWidget(this.widgetUUID);
|
|
91
|
-
if (this.activeWidget.config === null) {
|
|
92
|
-
// no data, let's set some!
|
|
93
|
-
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, defaultConfig);
|
|
94
|
-
this.config = defaultConfig; // load default config.
|
|
95
|
-
} else {
|
|
96
|
-
this.config = this.activeWidget.config;
|
|
97
|
-
}
|
|
98
|
-
this.subscribePath();
|
|
99
|
-
this.subscribeTheme();
|
|
100
|
-
this.subscribeZones();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
ngOnDestroy() {
|
|
104
|
-
this.unsubscribePath();
|
|
105
|
-
this.unsubscribeTheme();
|
|
106
|
-
this.unsubscribeZones();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
ngAfterContentInit(){
|
|
110
|
-
this.updateGaugeConfig();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
subscribePath() {
|
|
114
|
-
this.unsubscribePath();
|
|
115
|
-
if (typeof(this.config.paths['gaugePath'].path) != 'string') { return } // nothing to sub to...
|
|
116
|
-
|
|
117
|
-
this.valueSub = this.SignalKService.subscribePath(this.widgetUUID, this.config.paths['gaugePath'].path, this.config.paths['gaugePath'].source).subscribe(
|
|
118
|
-
newValue => {
|
|
119
|
-
this.dataValue = this.UnitsService.convertUnit(this.config.paths['gaugePath'].convertUnitTo, newValue.value);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// set colors for zone state
|
|
123
|
-
switch (newValue.state) {
|
|
124
|
-
case ZoneState.warning:
|
|
125
|
-
this.gaugeOptions.colorValueText = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
126
|
-
break;
|
|
127
|
-
case ZoneState.alarm:
|
|
128
|
-
this.gaugeOptions.colorValueText = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
this.gaugeOptions.colorValueText = getComputedStyle(this.wrapper.nativeElement).color;
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
unsubscribePath() {
|
|
140
|
-
if (this.valueSub !== null) {
|
|
141
|
-
this.valueSub.unsubscribe();
|
|
142
|
-
this.valueSub = null;
|
|
143
|
-
this.SignalKService.unsubscribePath(this.widgetUUID, this.config.paths['gaugePath'].path)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Subscribe to theme event
|
|
148
|
-
subscribeTheme() {
|
|
149
|
-
this.themeNameSub = this.AppSettingsService.getThemeNameAsO().subscribe(
|
|
150
|
-
themeChange => {
|
|
151
|
-
setTimeout(() => { // delay so browser getComputedStyles has time to complet theme style change.
|
|
152
|
-
this.updateGaugeConfig();
|
|
153
|
-
}, 50);
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
unsubscribeTheme(){
|
|
158
|
-
if (this.themeNameSub !== null) {
|
|
159
|
-
this.themeNameSub.unsubscribe();
|
|
160
|
-
this.themeNameSub = null;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Subscribe to Zones
|
|
165
|
-
subscribeZones() {
|
|
166
|
-
this.zonesSub = this.AppSettingsService.getZonesAsO().subscribe(
|
|
167
|
-
zones => {
|
|
168
|
-
this.zones = zones;
|
|
169
|
-
this.updateGaugeConfig();
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
unsubscribeZones(){
|
|
174
|
-
if (this.zonesSub !== null) {
|
|
175
|
-
this.zonesSub.unsubscribe();
|
|
176
|
-
this.zonesSub = null;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
openWidgetSettings() {
|
|
181
|
-
let dialogRef = this.dialog.open(ModalWidgetComponent, {
|
|
182
|
-
width: '80%',
|
|
183
|
-
data: this.config
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
dialogRef.afterClosed().subscribe(result => {
|
|
187
|
-
// save new settings
|
|
188
|
-
if (result) {
|
|
189
|
-
console.log(result);
|
|
190
|
-
this.unsubscribePath(); //unsub now as we will change variables so wont know what was subbed before...
|
|
191
|
-
this.config = result;
|
|
192
|
-
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, this.config);
|
|
193
|
-
this.subscribePath();
|
|
194
|
-
this.updateGaugeConfig();
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
updateGaugeConfig(){
|
|
200
|
-
//// Hack to get Theme colors using hidden minxin, DIV and @ViewChild
|
|
201
|
-
let themePaletteColor = "";
|
|
202
|
-
let themePaletteDarkColor = "";
|
|
203
|
-
|
|
204
|
-
this.gaugeOptions.colorTitle = this.gaugeOptions.colorUnits = this.gaugeOptions.colorValueText = window.getComputedStyle(this.wrapper.nativeElement).color;
|
|
205
|
-
|
|
206
|
-
this.gaugeOptions.colorPlate = window.getComputedStyle(this.wrapper.nativeElement).backgroundColor;
|
|
207
|
-
this.gaugeOptions.colorBar = getComputedStyle(this.backgroundElement.nativeElement).color;
|
|
208
|
-
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorTitle;
|
|
209
|
-
this.gaugeOptions.colorMinorTicks = this.gaugeOptions.colorTitle;
|
|
210
|
-
|
|
211
|
-
this.gaugeOptions.colorNeedleEnd = "";
|
|
212
|
-
this.gaugeOptions.colorNeedleShadowUp = "";
|
|
213
|
-
this.gaugeOptions.colorNeedleShadowDown = "black";
|
|
214
|
-
|
|
215
|
-
switch (this.config.barColor) {
|
|
216
|
-
case "primary":
|
|
217
|
-
themePaletteColor = getComputedStyle(this.primaryElement.nativeElement).color;
|
|
218
|
-
themePaletteDarkColor = getComputedStyle(this.primaryDarkElement.nativeElement).color;
|
|
219
|
-
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
220
|
-
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
221
|
-
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
222
|
-
this.gaugeOptions.needleWidth = 5;
|
|
223
|
-
break;
|
|
224
|
-
|
|
225
|
-
case "accent":
|
|
226
|
-
themePaletteColor = getComputedStyle(this.accentElement.nativeElement).color;
|
|
227
|
-
themePaletteDarkColor = getComputedStyle(this.accentDarkElement.nativeElement).color;
|
|
228
|
-
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
229
|
-
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
230
|
-
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
231
|
-
this.gaugeOptions.needleWidth = 5;
|
|
232
|
-
break;
|
|
233
|
-
|
|
234
|
-
case "warn":
|
|
235
|
-
themePaletteColor = getComputedStyle(this.warnElement.nativeElement).color;
|
|
236
|
-
themePaletteDarkColor = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
237
|
-
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
238
|
-
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
239
|
-
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
240
|
-
this.gaugeOptions.needleWidth = 5;
|
|
241
|
-
break;
|
|
242
|
-
|
|
243
|
-
case "nobar":
|
|
244
|
-
themePaletteColor = getComputedStyle(this.backgroundElement.nativeElement).color;
|
|
245
|
-
themePaletteDarkColor = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
246
|
-
this.gaugeOptions.colorBar = themePaletteColor;
|
|
247
|
-
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
248
|
-
this.gaugeOptions.colorBarProgressEnd = themePaletteColor;
|
|
249
|
-
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
250
|
-
this.gaugeOptions.needleWidth = 20;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
default:
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// highlights
|
|
258
|
-
let myZones: IDataHighlight = [];
|
|
259
|
-
this.zones.forEach(zone => {
|
|
260
|
-
// get zones for our path
|
|
261
|
-
if (zone.path == this.config.paths['gaugePath'].path) {
|
|
262
|
-
let lower = zone.lower || this.config.minValue;
|
|
263
|
-
let upper = zone.upper || this.config.maxValue;
|
|
264
|
-
let color: string;
|
|
265
|
-
switch (zone.state) {
|
|
266
|
-
case 1:
|
|
267
|
-
color = getComputedStyle(this.warnElement.nativeElement).color;
|
|
268
|
-
break;
|
|
269
|
-
case ZoneState.alarm:
|
|
270
|
-
color = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
271
|
-
break;
|
|
272
|
-
default:
|
|
273
|
-
color = getComputedStyle(this.primaryElement.nativeElement).color;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
myZones.push({from: lower, to: upper, color: color});
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
this.gaugeOptions.highlights = myZones;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// Config storage values
|
|
283
|
-
this.gaugeOptions.minValue = this.config.minValue;
|
|
284
|
-
this.gaugeOptions.maxValue = this.config.maxValue;
|
|
285
|
-
this.gaugeOptions.valueInt = this.config.numInt;
|
|
286
|
-
this.gaugeOptions.valueDec = this.config.numDecimal;
|
|
287
|
-
|
|
288
|
-
this.gaugeOptions.majorTicksInt = this.config.numInt;
|
|
289
|
-
this.gaugeOptions.majorTicksDec = this.config.numDecimal;
|
|
290
|
-
|
|
291
|
-
if (this.config.gaugeTicks) {
|
|
292
|
-
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorNumbers = this.gaugeOptions.colorMinorTicks = this.gaugeOptions.colorTitle;
|
|
293
|
-
} else {
|
|
294
|
-
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorNumbers = this.gaugeOptions.colorMinorTicks = "";
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
this.gaugeOptions.valueBox = true;
|
|
298
|
-
this.gaugeOptions.valueBoxWidth = 100;
|
|
299
|
-
this.gaugeOptions.valueBoxBorderRadius = 0;
|
|
300
|
-
|
|
301
|
-
this.gaugeOptions.needle = true;
|
|
302
|
-
this.gaugeOptions.needleType = "line";
|
|
303
|
-
this.gaugeOptions.needleShadow = false;
|
|
304
|
-
this.gaugeOptions.needleSide = "both";
|
|
305
|
-
|
|
306
|
-
// Vertical
|
|
307
|
-
if (this.config.gaugeType == 'ngLinearVertical'){
|
|
308
|
-
this.isGaugeVertical = true; // Changes div wrapper class to respect aspect ratio
|
|
309
|
-
this.gaugeOptions.barLength = 75;
|
|
310
|
-
this.gaugeOptions.fontUnitsSize = 40;
|
|
311
|
-
this.gaugeOptions.fontTitleSize = 40;
|
|
312
|
-
|
|
313
|
-
// Vertical With ticks
|
|
314
|
-
if (this.config.gaugeTicks == true) {
|
|
315
|
-
this.gaugeOptions.barWidth = 30;
|
|
316
|
-
|
|
317
|
-
this.gaugeOptions.needleStart = -45;
|
|
318
|
-
this.gaugeOptions.needleEnd = 55;
|
|
319
|
-
|
|
320
|
-
this.gaugeOptions.exactTicks = false;
|
|
321
|
-
this.gaugeOptions.tickSide = "right";
|
|
322
|
-
this.gaugeOptions.ticksWidth = 8;
|
|
323
|
-
this.gaugeOptions.ticksPadding = 4;
|
|
324
|
-
|
|
325
|
-
this.gaugeOptions.strokeTicks = false;
|
|
326
|
-
this.gaugeOptions.majorTicks = [this.config.minValue, this.config.maxValue];
|
|
327
|
-
|
|
328
|
-
this.gaugeOptions.numberSide = "right";
|
|
329
|
-
this.gaugeOptions.numbersMargin = 0;
|
|
330
|
-
this.gaugeOptions.fontNumbersSize = 25;
|
|
331
|
-
|
|
332
|
-
this.gaugeOptions.minorTicks = 10;
|
|
333
|
-
this.gaugeOptions.ticksWidthMinor = 4;
|
|
334
|
-
|
|
335
|
-
this.gaugeOptions.highlightsWidth = 15;
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
// Vertical No ticks
|
|
339
|
-
this.gaugeOptions.barWidth = 100;
|
|
340
|
-
|
|
341
|
-
this.gaugeOptions.needleStart = 0;
|
|
342
|
-
this.gaugeOptions.needleEnd = 100;
|
|
343
|
-
|
|
344
|
-
this.gaugeOptions.ticksWidth = 0;
|
|
345
|
-
this.gaugeOptions.strokeTicks = false;
|
|
346
|
-
this.gaugeOptions.majorTicks = [];
|
|
347
|
-
|
|
348
|
-
this.gaugeOptions.ticksPadding = 0;
|
|
349
|
-
this.gaugeOptions.minorTicks = 0;
|
|
350
|
-
this.gaugeOptions.ticksWidthMinor = 0;
|
|
351
|
-
this.gaugeOptions.numbersMargin = 0;
|
|
352
|
-
this.gaugeOptions.fontNumbersSize = 0;
|
|
353
|
-
|
|
354
|
-
this.gaugeOptions.highlightsWidth = 15;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
// horizontal
|
|
359
|
-
this.isGaugeVertical = false; // Changes div wrapper class to respect aspect ratio
|
|
360
|
-
this.gaugeOptions.barLength = 80;
|
|
361
|
-
this.gaugeOptions.fontTitleSize = 45;
|
|
362
|
-
this.gaugeOptions.fontUnitsSize = 35;
|
|
363
|
-
|
|
364
|
-
// horizontal With ticks
|
|
365
|
-
this.gaugeOptions.barWidth = 40;
|
|
366
|
-
if (this.config.gaugeTicks == true) {
|
|
367
|
-
|
|
368
|
-
this.gaugeOptions.exactTicks = false;
|
|
369
|
-
this.gaugeOptions.barWidth = 30;
|
|
370
|
-
|
|
371
|
-
this.gaugeOptions.needleStart = -45;
|
|
372
|
-
this.gaugeOptions.needleEnd = 56;
|
|
373
|
-
|
|
374
|
-
this.gaugeOptions.tickSide = "right";
|
|
375
|
-
this.gaugeOptions.ticksWidth = 8;
|
|
376
|
-
this.gaugeOptions.ticksPadding = 5;
|
|
377
|
-
|
|
378
|
-
this.gaugeOptions.strokeTicks = false;
|
|
379
|
-
this.gaugeOptions.majorTicks = [this.config.minValue, this.config.maxValue];
|
|
380
|
-
|
|
381
|
-
this.gaugeOptions.numberSide = "right";
|
|
382
|
-
this.gaugeOptions.numbersMargin = -5;
|
|
383
|
-
this.gaugeOptions.fontNumbersSize = 25;
|
|
384
|
-
|
|
385
|
-
this.gaugeOptions.minorTicks = 10;
|
|
386
|
-
this.gaugeOptions.ticksWidthMinor = 5;
|
|
387
|
-
|
|
388
|
-
this.gaugeOptions.highlightsWidth = 15;
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
// horizontal No ticks
|
|
392
|
-
this.gaugeOptions.barWidth = 60;
|
|
393
|
-
|
|
394
|
-
this.gaugeOptions.needleStart = 0;
|
|
395
|
-
this.gaugeOptions.needleEnd = 100;
|
|
396
|
-
|
|
397
|
-
this.gaugeOptions.ticksWidth = 0;
|
|
398
|
-
this.gaugeOptions.strokeTicks = false;
|
|
399
|
-
this.gaugeOptions.majorTicks = [];
|
|
400
|
-
|
|
401
|
-
this.gaugeOptions.ticksPadding = 0;
|
|
402
|
-
this.gaugeOptions.minorTicks = 0;
|
|
403
|
-
this.gaugeOptions.ticksWidthMinor = 0;
|
|
404
|
-
this.gaugeOptions.numbersMargin = 0;
|
|
405
|
-
this.gaugeOptions.fontNumbersSize = 0;
|
|
406
|
-
|
|
407
|
-
this.gaugeOptions.highlightsWidth = 15;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
onResized(event: ResizedEvent) {
|
|
413
|
-
|
|
414
|
-
this.gaugeOptions.height = event.
|
|
415
|
-
|
|
416
|
-
if (this.isGaugeVertical == true) {
|
|
417
|
-
this.gaugeOptions.width = (event.
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
this.gaugeOptions.width = event.
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
}
|
|
1
|
+
import { ViewChild, ElementRef, Component, OnInit, AfterContentInit, Input, OnDestroy } from '@angular/core';
|
|
2
|
+
import { Subscription } from 'rxjs';
|
|
3
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
4
|
+
import { ResizedEvent } from 'angular-resize-event';
|
|
5
|
+
|
|
6
|
+
import { SignalKService } from '../signalk.service';
|
|
7
|
+
import { ModalWidgetComponent } from '../modal-widget/modal-widget.component';
|
|
8
|
+
import { WidgetManagerService, IWidget, IWidgetConfig } from '../widget-manager.service';
|
|
9
|
+
import { UnitsService } from '../units.service' ;
|
|
10
|
+
import { AppSettingsService, IZone, ZoneState } from '../app-settings.service';
|
|
11
|
+
import { LinearGauge, LinearGaugeOptions } from '@biacsics/ng-canvas-gauges';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const defaultConfig: IWidgetConfig = {
|
|
15
|
+
displayName: null,
|
|
16
|
+
filterSelfPaths: true,
|
|
17
|
+
paths: {
|
|
18
|
+
"gaugePath": {
|
|
19
|
+
description: "Numeric Data",
|
|
20
|
+
path: null,
|
|
21
|
+
source: null,
|
|
22
|
+
pathType: "number",
|
|
23
|
+
isPathConfigurable: true,
|
|
24
|
+
convertUnitTo: "unitless"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
gaugeType: 'ngLinearVertical', //ngLinearVertical or ngLinearHorizontal
|
|
28
|
+
gaugeTicks: false,
|
|
29
|
+
minValue: 0,
|
|
30
|
+
maxValue: 100,
|
|
31
|
+
numInt: 1,
|
|
32
|
+
numDecimal: 0,
|
|
33
|
+
barColor: 'accent',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
interface IDataHighlight extends Array<{
|
|
37
|
+
from : number;
|
|
38
|
+
to : number;
|
|
39
|
+
color: string;
|
|
40
|
+
}> {};
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
selector: 'app-widget-gauge-ng-linear',
|
|
44
|
+
templateUrl: './widget-gauge-ng-linear.component.html',
|
|
45
|
+
styleUrls: ['./widget-gauge-ng-linear.component.scss']
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
export class WidgetGaugeNgLinearComponent implements OnInit, OnDestroy, AfterContentInit {
|
|
49
|
+
@ViewChild('linearWrapperDiv', {static: true, read: ElementRef}) private wrapper: ElementRef;
|
|
50
|
+
@ViewChild('linearGauge', {static: true, read: ElementRef}) protected linearGauge: ElementRef;
|
|
51
|
+
|
|
52
|
+
@Input('widgetUUID') widgetUUID: string;
|
|
53
|
+
@Input('unlockStatus') unlockStatus: boolean;
|
|
54
|
+
|
|
55
|
+
@ViewChild('primary', {static: true, read: ElementRef}) private primaryElement: ElementRef;
|
|
56
|
+
@ViewChild('accent', {static: true, read: ElementRef}) private accentElement: ElementRef;
|
|
57
|
+
@ViewChild('warn', {static: true, read: ElementRef}) private warnElement: ElementRef;
|
|
58
|
+
@ViewChild('primaryDark', {static: true, read: ElementRef}) private primaryDarkElement: ElementRef;
|
|
59
|
+
@ViewChild('accentDark', {static: true, read: ElementRef}) private accentDarkElement: ElementRef;
|
|
60
|
+
@ViewChild('warnDark', {static: true, read: ElementRef}) private warnDarkElement: ElementRef;
|
|
61
|
+
@ViewChild('background', {static: true, read: ElementRef}) private backgroundElement: ElementRef;
|
|
62
|
+
|
|
63
|
+
activeWidget: IWidget;
|
|
64
|
+
config: IWidgetConfig;
|
|
65
|
+
|
|
66
|
+
public dataValue = 0;
|
|
67
|
+
public dataValueTrimmed = 0;
|
|
68
|
+
|
|
69
|
+
valueSub: Subscription = null;
|
|
70
|
+
|
|
71
|
+
// dynamics theme support
|
|
72
|
+
themeNameSub: Subscription = null;
|
|
73
|
+
|
|
74
|
+
public gaugeOptions = {} as LinearGaugeOptions;
|
|
75
|
+
|
|
76
|
+
public isGaugeVertical: Boolean = true;
|
|
77
|
+
|
|
78
|
+
zones: Array<IZone> = [];
|
|
79
|
+
zonesSub: Subscription;
|
|
80
|
+
|
|
81
|
+
constructor(
|
|
82
|
+
public dialog:MatDialog,
|
|
83
|
+
private SignalKService: SignalKService,
|
|
84
|
+
private WidgetManagerService: WidgetManagerService,
|
|
85
|
+
private UnitsService: UnitsService,
|
|
86
|
+
private AppSettingsService: AppSettingsService, // need for theme change subscription
|
|
87
|
+
) {}
|
|
88
|
+
|
|
89
|
+
ngOnInit() {
|
|
90
|
+
this.activeWidget = this.WidgetManagerService.getWidget(this.widgetUUID);
|
|
91
|
+
if (this.activeWidget.config === null) {
|
|
92
|
+
// no data, let's set some!
|
|
93
|
+
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, defaultConfig);
|
|
94
|
+
this.config = defaultConfig; // load default config.
|
|
95
|
+
} else {
|
|
96
|
+
this.config = this.activeWidget.config;
|
|
97
|
+
}
|
|
98
|
+
this.subscribePath();
|
|
99
|
+
this.subscribeTheme();
|
|
100
|
+
this.subscribeZones();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
ngOnDestroy() {
|
|
104
|
+
this.unsubscribePath();
|
|
105
|
+
this.unsubscribeTheme();
|
|
106
|
+
this.unsubscribeZones();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ngAfterContentInit(){
|
|
110
|
+
this.updateGaugeConfig();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
subscribePath() {
|
|
114
|
+
this.unsubscribePath();
|
|
115
|
+
if (typeof(this.config.paths['gaugePath'].path) != 'string') { return } // nothing to sub to...
|
|
116
|
+
|
|
117
|
+
this.valueSub = this.SignalKService.subscribePath(this.widgetUUID, this.config.paths['gaugePath'].path, this.config.paths['gaugePath'].source).subscribe(
|
|
118
|
+
newValue => {
|
|
119
|
+
this.dataValue = this.UnitsService.convertUnit(this.config.paths['gaugePath'].convertUnitTo, newValue.value);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// set colors for zone state
|
|
123
|
+
switch (newValue.state) {
|
|
124
|
+
case ZoneState.warning:
|
|
125
|
+
this.gaugeOptions.colorValueText = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
126
|
+
break;
|
|
127
|
+
case ZoneState.alarm:
|
|
128
|
+
this.gaugeOptions.colorValueText = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
this.gaugeOptions.colorValueText = getComputedStyle(this.wrapper.nativeElement).color;
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
unsubscribePath() {
|
|
140
|
+
if (this.valueSub !== null) {
|
|
141
|
+
this.valueSub.unsubscribe();
|
|
142
|
+
this.valueSub = null;
|
|
143
|
+
this.SignalKService.unsubscribePath(this.widgetUUID, this.config.paths['gaugePath'].path)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Subscribe to theme event
|
|
148
|
+
subscribeTheme() {
|
|
149
|
+
this.themeNameSub = this.AppSettingsService.getThemeNameAsO().subscribe(
|
|
150
|
+
themeChange => {
|
|
151
|
+
setTimeout(() => { // delay so browser getComputedStyles has time to complet theme style change.
|
|
152
|
+
this.updateGaugeConfig();
|
|
153
|
+
}, 50);
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
unsubscribeTheme(){
|
|
158
|
+
if (this.themeNameSub !== null) {
|
|
159
|
+
this.themeNameSub.unsubscribe();
|
|
160
|
+
this.themeNameSub = null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Subscribe to Zones
|
|
165
|
+
subscribeZones() {
|
|
166
|
+
this.zonesSub = this.AppSettingsService.getZonesAsO().subscribe(
|
|
167
|
+
zones => {
|
|
168
|
+
this.zones = zones;
|
|
169
|
+
this.updateGaugeConfig();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
unsubscribeZones(){
|
|
174
|
+
if (this.zonesSub !== null) {
|
|
175
|
+
this.zonesSub.unsubscribe();
|
|
176
|
+
this.zonesSub = null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
openWidgetSettings() {
|
|
181
|
+
let dialogRef = this.dialog.open(ModalWidgetComponent, {
|
|
182
|
+
width: '80%',
|
|
183
|
+
data: this.config
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
dialogRef.afterClosed().subscribe(result => {
|
|
187
|
+
// save new settings
|
|
188
|
+
if (result) {
|
|
189
|
+
console.log(result);
|
|
190
|
+
this.unsubscribePath(); //unsub now as we will change variables so wont know what was subbed before...
|
|
191
|
+
this.config = result;
|
|
192
|
+
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, this.config);
|
|
193
|
+
this.subscribePath();
|
|
194
|
+
this.updateGaugeConfig();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
updateGaugeConfig(){
|
|
200
|
+
//// Hack to get Theme colors using hidden minxin, DIV and @ViewChild
|
|
201
|
+
let themePaletteColor = "";
|
|
202
|
+
let themePaletteDarkColor = "";
|
|
203
|
+
|
|
204
|
+
this.gaugeOptions.colorTitle = this.gaugeOptions.colorUnits = this.gaugeOptions.colorValueText = window.getComputedStyle(this.wrapper.nativeElement).color;
|
|
205
|
+
|
|
206
|
+
this.gaugeOptions.colorPlate = window.getComputedStyle(this.wrapper.nativeElement).backgroundColor;
|
|
207
|
+
this.gaugeOptions.colorBar = getComputedStyle(this.backgroundElement.nativeElement).color;
|
|
208
|
+
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorTitle;
|
|
209
|
+
this.gaugeOptions.colorMinorTicks = this.gaugeOptions.colorTitle;
|
|
210
|
+
|
|
211
|
+
this.gaugeOptions.colorNeedleEnd = "";
|
|
212
|
+
this.gaugeOptions.colorNeedleShadowUp = "";
|
|
213
|
+
this.gaugeOptions.colorNeedleShadowDown = "black";
|
|
214
|
+
|
|
215
|
+
switch (this.config.barColor) {
|
|
216
|
+
case "primary":
|
|
217
|
+
themePaletteColor = getComputedStyle(this.primaryElement.nativeElement).color;
|
|
218
|
+
themePaletteDarkColor = getComputedStyle(this.primaryDarkElement.nativeElement).color;
|
|
219
|
+
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
220
|
+
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
221
|
+
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
222
|
+
this.gaugeOptions.needleWidth = 5;
|
|
223
|
+
break;
|
|
224
|
+
|
|
225
|
+
case "accent":
|
|
226
|
+
themePaletteColor = getComputedStyle(this.accentElement.nativeElement).color;
|
|
227
|
+
themePaletteDarkColor = getComputedStyle(this.accentDarkElement.nativeElement).color;
|
|
228
|
+
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
229
|
+
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
230
|
+
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
231
|
+
this.gaugeOptions.needleWidth = 5;
|
|
232
|
+
break;
|
|
233
|
+
|
|
234
|
+
case "warn":
|
|
235
|
+
themePaletteColor = getComputedStyle(this.warnElement.nativeElement).color;
|
|
236
|
+
themePaletteDarkColor = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
237
|
+
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
238
|
+
this.gaugeOptions.colorBarProgressEnd = themePaletteDarkColor;
|
|
239
|
+
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
240
|
+
this.gaugeOptions.needleWidth = 5;
|
|
241
|
+
break;
|
|
242
|
+
|
|
243
|
+
case "nobar":
|
|
244
|
+
themePaletteColor = getComputedStyle(this.backgroundElement.nativeElement).color;
|
|
245
|
+
themePaletteDarkColor = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
246
|
+
this.gaugeOptions.colorBar = themePaletteColor;
|
|
247
|
+
this.gaugeOptions.colorBarProgress = themePaletteColor;
|
|
248
|
+
this.gaugeOptions.colorBarProgressEnd = themePaletteColor;
|
|
249
|
+
this.gaugeOptions.colorNeedle = themePaletteDarkColor;
|
|
250
|
+
this.gaugeOptions.needleWidth = 20;
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
default:
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// highlights
|
|
258
|
+
let myZones: IDataHighlight = [];
|
|
259
|
+
this.zones.forEach(zone => {
|
|
260
|
+
// get zones for our path
|
|
261
|
+
if (zone.path == this.config.paths['gaugePath'].path) {
|
|
262
|
+
let lower = zone.lower || this.config.minValue;
|
|
263
|
+
let upper = zone.upper || this.config.maxValue;
|
|
264
|
+
let color: string;
|
|
265
|
+
switch (zone.state) {
|
|
266
|
+
case 1:
|
|
267
|
+
color = getComputedStyle(this.warnElement.nativeElement).color;
|
|
268
|
+
break;
|
|
269
|
+
case ZoneState.alarm:
|
|
270
|
+
color = getComputedStyle(this.warnDarkElement.nativeElement).color;
|
|
271
|
+
break;
|
|
272
|
+
default:
|
|
273
|
+
color = getComputedStyle(this.primaryElement.nativeElement).color;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
myZones.push({from: lower, to: upper, color: color});
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
this.gaugeOptions.highlights = myZones;
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// Config storage values
|
|
283
|
+
this.gaugeOptions.minValue = this.config.minValue;
|
|
284
|
+
this.gaugeOptions.maxValue = this.config.maxValue;
|
|
285
|
+
this.gaugeOptions.valueInt = this.config.numInt;
|
|
286
|
+
this.gaugeOptions.valueDec = this.config.numDecimal;
|
|
287
|
+
|
|
288
|
+
this.gaugeOptions.majorTicksInt = this.config.numInt;
|
|
289
|
+
this.gaugeOptions.majorTicksDec = this.config.numDecimal;
|
|
290
|
+
|
|
291
|
+
if (this.config.gaugeTicks) {
|
|
292
|
+
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorNumbers = this.gaugeOptions.colorMinorTicks = this.gaugeOptions.colorTitle;
|
|
293
|
+
} else {
|
|
294
|
+
this.gaugeOptions.colorMajorTicks = this.gaugeOptions.colorNumbers = this.gaugeOptions.colorMinorTicks = "";
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
this.gaugeOptions.valueBox = true;
|
|
298
|
+
this.gaugeOptions.valueBoxWidth = 100;
|
|
299
|
+
this.gaugeOptions.valueBoxBorderRadius = 0;
|
|
300
|
+
|
|
301
|
+
this.gaugeOptions.needle = true;
|
|
302
|
+
this.gaugeOptions.needleType = "line";
|
|
303
|
+
this.gaugeOptions.needleShadow = false;
|
|
304
|
+
this.gaugeOptions.needleSide = "both";
|
|
305
|
+
|
|
306
|
+
// Vertical
|
|
307
|
+
if (this.config.gaugeType == 'ngLinearVertical'){
|
|
308
|
+
this.isGaugeVertical = true; // Changes div wrapper class to respect aspect ratio
|
|
309
|
+
this.gaugeOptions.barLength = 75;
|
|
310
|
+
this.gaugeOptions.fontUnitsSize = 40;
|
|
311
|
+
this.gaugeOptions.fontTitleSize = 40;
|
|
312
|
+
|
|
313
|
+
// Vertical With ticks
|
|
314
|
+
if (this.config.gaugeTicks == true) {
|
|
315
|
+
this.gaugeOptions.barWidth = 30;
|
|
316
|
+
|
|
317
|
+
this.gaugeOptions.needleStart = -45;
|
|
318
|
+
this.gaugeOptions.needleEnd = 55;
|
|
319
|
+
|
|
320
|
+
this.gaugeOptions.exactTicks = false;
|
|
321
|
+
this.gaugeOptions.tickSide = "right";
|
|
322
|
+
this.gaugeOptions.ticksWidth = 8;
|
|
323
|
+
this.gaugeOptions.ticksPadding = 4;
|
|
324
|
+
|
|
325
|
+
this.gaugeOptions.strokeTicks = false;
|
|
326
|
+
this.gaugeOptions.majorTicks = [this.config.minValue, this.config.maxValue];
|
|
327
|
+
|
|
328
|
+
this.gaugeOptions.numberSide = "right";
|
|
329
|
+
this.gaugeOptions.numbersMargin = 0;
|
|
330
|
+
this.gaugeOptions.fontNumbersSize = 25;
|
|
331
|
+
|
|
332
|
+
this.gaugeOptions.minorTicks = 10;
|
|
333
|
+
this.gaugeOptions.ticksWidthMinor = 4;
|
|
334
|
+
|
|
335
|
+
this.gaugeOptions.highlightsWidth = 15;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
// Vertical No ticks
|
|
339
|
+
this.gaugeOptions.barWidth = 100;
|
|
340
|
+
|
|
341
|
+
this.gaugeOptions.needleStart = 0;
|
|
342
|
+
this.gaugeOptions.needleEnd = 100;
|
|
343
|
+
|
|
344
|
+
this.gaugeOptions.ticksWidth = 0;
|
|
345
|
+
this.gaugeOptions.strokeTicks = false;
|
|
346
|
+
this.gaugeOptions.majorTicks = [];
|
|
347
|
+
|
|
348
|
+
this.gaugeOptions.ticksPadding = 0;
|
|
349
|
+
this.gaugeOptions.minorTicks = 0;
|
|
350
|
+
this.gaugeOptions.ticksWidthMinor = 0;
|
|
351
|
+
this.gaugeOptions.numbersMargin = 0;
|
|
352
|
+
this.gaugeOptions.fontNumbersSize = 0;
|
|
353
|
+
|
|
354
|
+
this.gaugeOptions.highlightsWidth = 15;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// horizontal
|
|
359
|
+
this.isGaugeVertical = false; // Changes div wrapper class to respect aspect ratio
|
|
360
|
+
this.gaugeOptions.barLength = 80;
|
|
361
|
+
this.gaugeOptions.fontTitleSize = 45;
|
|
362
|
+
this.gaugeOptions.fontUnitsSize = 35;
|
|
363
|
+
|
|
364
|
+
// horizontal With ticks
|
|
365
|
+
this.gaugeOptions.barWidth = 40;
|
|
366
|
+
if (this.config.gaugeTicks == true) {
|
|
367
|
+
|
|
368
|
+
this.gaugeOptions.exactTicks = false;
|
|
369
|
+
this.gaugeOptions.barWidth = 30;
|
|
370
|
+
|
|
371
|
+
this.gaugeOptions.needleStart = -45;
|
|
372
|
+
this.gaugeOptions.needleEnd = 56;
|
|
373
|
+
|
|
374
|
+
this.gaugeOptions.tickSide = "right";
|
|
375
|
+
this.gaugeOptions.ticksWidth = 8;
|
|
376
|
+
this.gaugeOptions.ticksPadding = 5;
|
|
377
|
+
|
|
378
|
+
this.gaugeOptions.strokeTicks = false;
|
|
379
|
+
this.gaugeOptions.majorTicks = [this.config.minValue, this.config.maxValue];
|
|
380
|
+
|
|
381
|
+
this.gaugeOptions.numberSide = "right";
|
|
382
|
+
this.gaugeOptions.numbersMargin = -5;
|
|
383
|
+
this.gaugeOptions.fontNumbersSize = 25;
|
|
384
|
+
|
|
385
|
+
this.gaugeOptions.minorTicks = 10;
|
|
386
|
+
this.gaugeOptions.ticksWidthMinor = 5;
|
|
387
|
+
|
|
388
|
+
this.gaugeOptions.highlightsWidth = 15;
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// horizontal No ticks
|
|
392
|
+
this.gaugeOptions.barWidth = 60;
|
|
393
|
+
|
|
394
|
+
this.gaugeOptions.needleStart = 0;
|
|
395
|
+
this.gaugeOptions.needleEnd = 100;
|
|
396
|
+
|
|
397
|
+
this.gaugeOptions.ticksWidth = 0;
|
|
398
|
+
this.gaugeOptions.strokeTicks = false;
|
|
399
|
+
this.gaugeOptions.majorTicks = [];
|
|
400
|
+
|
|
401
|
+
this.gaugeOptions.ticksPadding = 0;
|
|
402
|
+
this.gaugeOptions.minorTicks = 0;
|
|
403
|
+
this.gaugeOptions.ticksWidthMinor = 0;
|
|
404
|
+
this.gaugeOptions.numbersMargin = 0;
|
|
405
|
+
this.gaugeOptions.fontNumbersSize = 0;
|
|
406
|
+
|
|
407
|
+
this.gaugeOptions.highlightsWidth = 15;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
onResized(event: ResizedEvent) {
|
|
413
|
+
|
|
414
|
+
this.gaugeOptions.height = event.newRect.height;
|
|
415
|
+
|
|
416
|
+
if (this.isGaugeVertical == true) {
|
|
417
|
+
this.gaugeOptions.width = (event.newRect.height * 0.30);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this.gaugeOptions.width = event.newRect.width;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
}
|