@mxtommy/kip 1.3.0 → 2.0.1
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/CHANGELOG.md +38 -3
- package/CONTRIBUTORS.md +4 -4
- package/KipGaugeSample3-1024x508.png +0 -0
- package/LICENSE +21 -0
- package/README.md +80 -42
- package/package.json +52 -46
- package/public/3rdpartylicenses.txt +47 -419
- package/public/assets/NoSleep.min.js +2 -2
- package/public/assets/icon-64x64.png +0 -0
- package/public/assets/icon-72x72.png +0 -0
- package/public/index.html +3 -3
- package/public/main.f3d15cc777474f5f.js +1 -0
- package/public/manifest.json +9 -4
- package/public/polyfills.64db6be9cdc8f808.js +1 -0
- package/public/runtime.e75056c32c37f59d.js +1 -0
- package/public/styles.6b1c2c92be18a2cc.css +1 -0
- package/.angulardoc.json +0 -4
- package/angular.json +0 -162
- package/e2e/app.e2e-spec.ts +0 -14
- package/e2e/app.po.ts +0 -11
- package/e2e/tsconfig.e2e.json +0 -14
- package/karma.conf.js +0 -31
- package/protractor.conf.js +0 -28
- package/public/assets/svg-autopilot-inkscape-plain.svg +0 -983
- package/public/assets/svg-wind-inkscape.svg +0 -1358
- package/public/main-es2018.98175eb4c61ccaf7eb17.js +0 -1
- package/public/main-es5.98175eb4c61ccaf7eb17.js +0 -1
- package/public/polyfills-es2018.3a61665863c173cd6ba3.js +0 -1
- package/public/polyfills-es5.44827ae4ff4e41de51fb.js +0 -1
- package/public/runtime-es2018.baedb88c6d2abacae2b8.js +0 -1
- package/public/runtime-es5.baedb88c6d2abacae2b8.js +0 -1
- package/public/styles.b92ae2c466c89712209d.css +0 -5
- package/src/app/alarm-menu/alarm-menu.component.html +0 -55
- package/src/app/alarm-menu/alarm-menu.component.scss +0 -52
- package/src/app/alarm-menu/alarm-menu.component.spec.ts +0 -25
- package/src/app/alarm-menu/alarm-menu.component.ts +0 -186
- package/src/app/app-help/app-help.component.css +0 -4
- package/src/app/app-help/app-help.component.html +0 -135
- package/src/app/app-help/app-help.component.ts +0 -45
- package/src/app/app-settings.service.spec.ts +0 -15
- package/src/app/app-settings.service.ts +0 -478
- package/src/app/app.component.css +0 -39
- package/src/app/app.component.html +0 -93
- package/src/app/app.component.scss +0 -79
- package/src/app/app.component.spec.ts +0 -32
- package/src/app/app.component.ts +0 -191
- package/src/app/app.module.ts +0 -200
- package/src/app/config.blank.const.ts +0 -52
- package/src/app/config.blank.notification.const.ts +0 -19
- package/src/app/config.blank.units.const.ts +0 -23
- package/src/app/config.demo.const.ts +0 -384
- package/src/app/data-browser/data-browser.component.css +0 -29
- package/src/app/data-browser/data-browser.component.html +0 -44
- package/src/app/data-browser/data-browser.component.spec.ts +0 -25
- package/src/app/data-browser/data-browser.component.ts +0 -91
- package/src/app/data-browser-row/data-browser-row-unit-modal.html +0 -17
- package/src/app/data-browser-row/data-browser-row.component.css +0 -10
- package/src/app/data-browser-row/data-browser-row.component.html +0 -5
- package/src/app/data-browser-row/data-browser-row.component.ts +0 -79
- package/src/app/data-set.service.spec.ts +0 -15
- package/src/app/data-set.service.ts +0 -273
- package/src/app/dynamic-widget.directive.spec.ts +0 -8
- package/src/app/dynamic-widget.directive.ts +0 -11
- package/src/app/filter-self.pipe.spec.ts +0 -8
- package/src/app/filter-self.pipe.ts +0 -14
- package/src/app/fit-text.directive.spec.ts +0 -8
- package/src/app/fit-text.directive.ts +0 -61
- package/src/app/gauge-steel/gauge-steel.component.css +0 -5
- package/src/app/gauge-steel/gauge-steel.component.html +0 -4
- package/src/app/gauge-steel/gauge-steel.component.spec.ts +0 -25
- package/src/app/gauge-steel/gauge-steel.component.ts +0 -282
- package/src/app/gauges-module/base-gauge.ts +0 -301
- package/src/app/gauges-module/gauges.module.ts +0 -17
- package/src/app/gauges-module/linear-gauge.ts +0 -50
- package/src/app/gauges-module/radial-gauge.ts +0 -48
- package/src/app/layout-split/layout-split.component.html +0 -30
- package/src/app/layout-split/layout-split.component.scss +0 -33
- package/src/app/layout-split/layout-split.component.spec.ts +0 -25
- package/src/app/layout-split/layout-split.component.ts +0 -59
- package/src/app/layout-splits.service.spec.ts +0 -15
- package/src/app/layout-splits.service.ts +0 -284
- package/src/app/modal-path-selector/modal-path-selector.component.html +0 -62
- package/src/app/modal-path-selector/modal-path-selector.component.scss +0 -39
- package/src/app/modal-path-selector/modal-path-selector.component.spec.ts +0 -25
- package/src/app/modal-path-selector/modal-path-selector.component.ts +0 -132
- package/src/app/modal-widget/modal-widget.component.css +0 -33
- package/src/app/modal-widget/modal-widget.component.html +0 -341
- package/src/app/modal-widget/modal-widget.component.spec.ts +0 -25
- package/src/app/modal-widget/modal-widget.component.ts +0 -84
- package/src/app/notifications.service.spec.ts +0 -12
- package/src/app/notifications.service.ts +0 -392
- package/src/app/object-keys.pipe.spec.ts +0 -8
- package/src/app/object-keys.pipe.ts +0 -13
- package/src/app/reset-config/reset-config.component.css +0 -0
- package/src/app/reset-config/reset-config.component.html +0 -3
- package/src/app/reset-config/reset-config.component.spec.ts +0 -25
- package/src/app/reset-config/reset-config.component.ts +0 -31
- package/src/app/root-display/root-display.component.css +0 -0
- package/src/app/root-display/root-display.component.html +0 -4
- package/src/app/root-display/root-display.component.spec.ts +0 -25
- package/src/app/root-display/root-display.component.ts +0 -57
- package/src/app/safe.pipe.ts +0 -16
- package/src/app/settings/settings.component.css +0 -9
- package/src/app/settings/settings.component.html +0 -25
- package/src/app/settings/settings.component.spec.ts +0 -25
- package/src/app/settings/settings.component.ts +0 -22
- package/src/app/settings-config/settings-config.component.css +0 -39
- package/src/app/settings-config/settings-config.component.html +0 -118
- package/src/app/settings-config/settings-config.component.spec.ts +0 -25
- package/src/app/settings-config/settings-config.component.ts +0 -161
- package/src/app/settings-datasets/settings-datasets.component.html +0 -43
- package/src/app/settings-datasets/settings-datasets.component.scss +0 -39
- package/src/app/settings-datasets/settings-datasets.component.spec.ts +0 -25
- package/src/app/settings-datasets/settings-datasets.component.ts +0 -98
- package/src/app/settings-datasets/settings-datasets.modal.html +0 -54
- package/src/app/settings-notifications/settings-notifications.component.css +0 -0
- package/src/app/settings-notifications/settings-notifications.component.html +0 -65
- package/src/app/settings-notifications/settings-notifications.component.spec.ts +0 -25
- package/src/app/settings-notifications/settings-notifications.component.ts +0 -29
- package/src/app/settings-signalk/settings-signalk.component.css +0 -3
- package/src/app/settings-signalk/settings-signalk.component.html +0 -89
- package/src/app/settings-signalk/settings-signalk.component.spec.ts +0 -25
- package/src/app/settings-signalk/settings-signalk.component.ts +0 -174
- package/src/app/settings-units/settings-units.component.css +0 -4
- package/src/app/settings-units/settings-units.component.html +0 -19
- package/src/app/settings-units/settings-units.component.spec.ts +0 -25
- package/src/app/settings-units/settings-units.component.ts +0 -62
- package/src/app/settings-zones/settings-zones.component.css +0 -22
- package/src/app/settings-zones/settings-zones.component.html +0 -70
- package/src/app/settings-zones/settings-zones.component.ts +0 -154
- package/src/app/settings-zones/settings-zones.modal.css +0 -14
- package/src/app/settings-zones/settings-zones.modal.html +0 -39
- package/src/app/signalk-connection.service.ts +0 -344
- package/src/app/signalk-delta.service.spec.ts +0 -15
- package/src/app/signalk-delta.service.ts +0 -97
- package/src/app/signalk-full.service.spec.ts +0 -15
- package/src/app/signalk-full.service.ts +0 -99
- package/src/app/signalk-interfaces.ts +0 -129
- package/src/app/signalk-requests.service.spec.ts +0 -12
- package/src/app/signalk-requests.service.ts +0 -180
- package/src/app/signalk.service.spec.ts +0 -15
- package/src/app/signalk.service.ts +0 -428
- package/src/app/svg-autopilot/svg-autopilot.component.html +0 -1036
- package/src/app/svg-autopilot/svg-autopilot.component.spec.ts +0 -25
- package/src/app/svg-autopilot/svg-autopilot.component.ts +0 -174
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.html +0 -119
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.scss +0 -0
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.spec.ts +0 -25
- package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.ts +0 -49
- package/src/app/svg-wind/svg-wind.component.css +0 -0
- package/src/app/svg-wind/svg-wind.component.html +0 -969
- package/src/app/svg-wind/svg-wind.component.scss +0 -76
- package/src/app/svg-wind/svg-wind.component.spec.ts +0 -25
- package/src/app/svg-wind/svg-wind.component.ts +0 -280
- package/src/app/unit-window/unit-window.component.css +0 -37
- package/src/app/unit-window/unit-window.component.html +0 -8
- package/src/app/unit-window/unit-window.component.spec.ts +0 -25
- package/src/app/unit-window/unit-window.component.ts +0 -134
- package/src/app/unit-window/unit-window.modal.html +0 -25
- package/src/app/units.service.ts +0 -300
- package/src/app/widget-autopilot/widget-autopilot.component.html +0 -78
- package/src/app/widget-autopilot/widget-autopilot.component.scss +0 -191
- package/src/app/widget-autopilot/widget-autopilot.component.spec.ts +0 -25
- package/src/app/widget-autopilot/widget-autopilot.component.ts +0 -774
- package/src/app/widget-blank/widget-blank.component.html +0 -5
- package/src/app/widget-blank/widget-blank.component.scss +0 -21
- package/src/app/widget-blank/widget-blank.component.spec.ts +0 -25
- package/src/app/widget-blank/widget-blank.component.ts +0 -17
- package/src/app/widget-gauge/widget-gauge.component.css +0 -26
- package/src/app/widget-gauge/widget-gauge.component.html +0 -29
- package/src/app/widget-gauge/widget-gauge.component.spec.ts +0 -25
- package/src/app/widget-gauge/widget-gauge.component.ts +0 -120
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.html +0 -126
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.scss +0 -94
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.spec.ts +0 -25
- package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.ts +0 -424
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.html +0 -122
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.scss +0 -69
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.spec.ts +0 -25
- package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.ts +0 -553
- package/src/app/widget-historical/widget-historical.component.css +0 -31
- package/src/app/widget-historical/widget-historical.component.html +0 -14
- package/src/app/widget-historical/widget-historical.component.scss +0 -0
- package/src/app/widget-historical/widget-historical.component.spec.ts +0 -25
- package/src/app/widget-historical/widget-historical.component.ts +0 -306
- package/src/app/widget-iframe/widget-iframe.component.css +0 -12
- package/src/app/widget-iframe/widget-iframe.component.html +0 -21
- package/src/app/widget-iframe/widget-iframe.component.spec.ts +0 -25
- package/src/app/widget-iframe/widget-iframe.component.ts +0 -63
- package/src/app/widget-list.service.spec.ts +0 -15
- package/src/app/widget-list.service.ts +0 -135
- package/src/app/widget-manager.service.spec.ts +0 -15
- package/src/app/widget-manager.service.ts +0 -141
- package/src/app/widget-numeric/widget-numeric.component.html +0 -13
- package/src/app/widget-numeric/widget-numeric.component.scss +0 -52
- package/src/app/widget-numeric/widget-numeric.component.spec.ts +0 -25
- package/src/app/widget-numeric/widget-numeric.component.ts +0 -457
- package/src/app/widget-simple-linear/widget-simple-linear.component.html +0 -28
- package/src/app/widget-simple-linear/widget-simple-linear.component.scss +0 -64
- package/src/app/widget-simple-linear/widget-simple-linear.component.spec.ts +0 -25
- package/src/app/widget-simple-linear/widget-simple-linear.component.ts +0 -199
- package/src/app/widget-state/widget-state.component.html +0 -27
- package/src/app/widget-state/widget-state.component.scss +0 -68
- package/src/app/widget-state/widget-state.component.spec.ts +0 -25
- package/src/app/widget-state/widget-state.component.ts +0 -178
- package/src/app/widget-switch/widget-switch.component.css +0 -70
- package/src/app/widget-switch/widget-switch.component.html +0 -17
- package/src/app/widget-switch/widget-switch.component.spec.ts +0 -25
- package/src/app/widget-switch/widget-switch.component.ts +0 -134
- package/src/app/widget-text-generic/widget-text-generic.component.css +0 -55
- package/src/app/widget-text-generic/widget-text-generic.component.html +0 -9
- package/src/app/widget-text-generic/widget-text-generic.component.spec.ts +0 -25
- package/src/app/widget-text-generic/widget-text-generic.component.ts +0 -253
- package/src/app/widget-tutorial/widget-tutorial.component.css +0 -0
- package/src/app/widget-tutorial/widget-tutorial.component.html +0 -34
- package/src/app/widget-tutorial/widget-tutorial.component.spec.ts +0 -25
- package/src/app/widget-tutorial/widget-tutorial.component.ts +0 -18
- package/src/app/widget-unknown/widget-unknown.component.css +0 -0
- package/src/app/widget-unknown/widget-unknown.component.html +0 -3
- package/src/app/widget-unknown/widget-unknown.component.spec.ts +0 -25
- package/src/app/widget-unknown/widget-unknown.component.ts +0 -15
- package/src/app/widget-wind/widget-wind.component.css +0 -24
- package/src/app/widget-wind/widget-wind.component.html +0 -20
- package/src/app/widget-wind/widget-wind.component.spec.ts +0 -25
- package/src/app/widget-wind/widget-wind.component.ts +0 -369
- package/src/assets/.gitkeep +0 -0
- package/src/assets/NoSleep.min.js +0 -2
- package/src/assets/alarm.mp3 +0 -0
- package/src/assets/alert.mp3 +0 -0
- package/src/assets/alertl.old.mp3 +0 -0
- package/src/assets/emergency.mp3 +0 -0
- package/src/assets/fontawesome6/css/all.min.css +0 -6
- 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/notification.mp3 +0 -0
- package/src/assets/steelseries-min.js +0 -25
- package/src/assets/steelseries-min.js.map +0 -8
- package/src/assets/steelseries.js +0 -15834
- package/src/assets/svg-autopilot-inkscape-plain.svg +0 -983
- package/src/assets/svg-wind-inkscape.svg +0 -1358
- package/src/assets/tween-min.js +0 -1
- package/src/assets/tween.js +0 -381
- package/src/assets/warn.mp3 +0 -0
- package/src/environments/environment.prod.ts +0 -3
- package/src/environments/environment.ts +0 -8
- package/src/favicon.ico +0 -0
- package/src/index.html +0 -20
- package/src/main.ts +0 -11
- package/src/manifest.json +0 -33
- package/src/polyfills.ts +0 -80
- package/src/styles.css +0 -47
- package/src/styles.scss +0 -157
- package/src/test.ts +0 -32
- package/src/themes/darkBlueTheme.scss +0 -117
- package/src/themes/defaultTheme.scss +0 -50
- package/src/themes/highContrastTheme.scss +0 -47
- package/src/themes/modernTheme.scss +0 -143
- package/src/themes/nightMode.scss +0 -185
- package/src/themes/platypusTheme.scss +0 -80
- package/src/themes/signalkTheme.scss +0 -112
- package/src/tsconfig.app.json +0 -15
- package/src/tsconfig.spec.json +0 -20
- package/src/typings.d.ts +0 -5
- package/tsconfig.json +0 -24
- package/tslint.json +0 -143
- /package/{KipGaugeSample-1-1024x545.png → KipGaugeSample1-1024x545.png} +0 -0
- /package/{KipMonitor-1024x488.png → KipGaugeSample2-1024x488.png} +0 -0
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { AppSettingsService } from './app-settings.service';
|
|
3
|
-
import { Format, Policy } from "./signalk-interfaces";
|
|
4
|
-
|
|
5
|
-
export interface IWidget {
|
|
6
|
-
uuid: string;
|
|
7
|
-
type: string;
|
|
8
|
-
config: IWidgetConfig;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface IWidgetConfig {
|
|
12
|
-
displayName?: string;
|
|
13
|
-
filterSelfPaths?: boolean; //widget filter self paths only?
|
|
14
|
-
paths?: {
|
|
15
|
-
[key: string]: IWidgetPaths;
|
|
16
|
-
},
|
|
17
|
-
convertUnitTo?: string;
|
|
18
|
-
usage?: {
|
|
19
|
-
[key: string]: string[]; // Autopilot: key should match key in paths, specifies autopilot widget possible paths for AP mode
|
|
20
|
-
},
|
|
21
|
-
typeVal?: {
|
|
22
|
-
[key: string]: string; // Autopilot: key should match key in paths, specifies autopilot widget paths value type for AP mode
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
//numeric data
|
|
26
|
-
numDecimal?: number; // number of decimal places if a number
|
|
27
|
-
numInt?: number;
|
|
28
|
-
showMin?: boolean;
|
|
29
|
-
showMax?: boolean;
|
|
30
|
-
|
|
31
|
-
//Wind Gauge data
|
|
32
|
-
windSectorEnable?: boolean;
|
|
33
|
-
windSectorWindowSeconds?: number;
|
|
34
|
-
laylineEnable?: boolean;
|
|
35
|
-
laylineAngle?: number;
|
|
36
|
-
|
|
37
|
-
//gauge Data
|
|
38
|
-
gaugeType?: string;
|
|
39
|
-
gaugeUnitLabelFormat?: string;
|
|
40
|
-
gaugeTicks?: boolean;
|
|
41
|
-
barGraph?: boolean;
|
|
42
|
-
backgroundColor?: string;
|
|
43
|
-
frameColor?: string;
|
|
44
|
-
barColor?: string;
|
|
45
|
-
radialSize?: string;
|
|
46
|
-
minValue?: number;
|
|
47
|
-
maxValue?: number;
|
|
48
|
-
rotateFace?: boolean;
|
|
49
|
-
autoStart?: boolean;
|
|
50
|
-
compassUseNumbers?: boolean;
|
|
51
|
-
|
|
52
|
-
//Historical
|
|
53
|
-
dataSetUUID?: string;
|
|
54
|
-
invertData?: boolean;
|
|
55
|
-
displayMinMax?: boolean;
|
|
56
|
-
animateGraph?: boolean;
|
|
57
|
-
includeZero?: boolean;
|
|
58
|
-
verticalGraph?: boolean;
|
|
59
|
-
|
|
60
|
-
//Puts
|
|
61
|
-
putEnable?: boolean;
|
|
62
|
-
putMomentary?: boolean;
|
|
63
|
-
putMomentaryValue?: boolean;
|
|
64
|
-
|
|
65
|
-
//iFrame
|
|
66
|
-
widgetUrl?: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface IWidgetPaths {
|
|
70
|
-
description: string;
|
|
71
|
-
path: string | null; //can be null or set
|
|
72
|
-
source: string | null; //can be null or set
|
|
73
|
-
pathType: string | null;
|
|
74
|
-
pathFilter?: string, //Future - use to filter path list ie. self.navigation.* or *.navigation.*.blabla.*
|
|
75
|
-
convertUnitTo?: string; // Convert SignalK value to specific format for display. Also used as a source to identify conversion group
|
|
76
|
-
isPathConfigurable: boolean; // should we show this path in Widget Path config or is it static and hidden
|
|
77
|
-
period?: number; // SignalK - period=[millisecs] becomes the transmission rate, e.g. every period/1000 seconds. Default: 1000
|
|
78
|
-
format?: Format; // SignalK - format=[delta|full] specifies delta or full format. Default: delta
|
|
79
|
-
policy?: Policy; // SignalK - policy=[instant|ideal|fixed]. Default: ideal
|
|
80
|
-
minPeriod?: number; // SignalK - minPeriod=[millisecs] becomes the fastest message transmission rate allowed, e.g. every minPeriod/1000 seconds. This is only relevant for policy='instant' to avoid swamping the client or network.
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@Injectable()
|
|
86
|
-
export class WidgetManagerService {
|
|
87
|
-
|
|
88
|
-
widgets: Array<IWidget>;
|
|
89
|
-
|
|
90
|
-
constructor(
|
|
91
|
-
private AppSettingsService: AppSettingsService
|
|
92
|
-
) {
|
|
93
|
-
this.widgets = this.AppSettingsService.getWidgets();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
private newUuid() {
|
|
99
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
100
|
-
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
101
|
-
return v.toString(16);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getWidget(uuid: string) {
|
|
106
|
-
return this.widgets.find(w => w.uuid == uuid);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
newWidget() {
|
|
110
|
-
let uuid = this.newUuid();
|
|
111
|
-
this.widgets.push({ uuid: uuid, type: "WidgetBlank", config: null });
|
|
112
|
-
this.saveWidgets();
|
|
113
|
-
return uuid;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
deleteWidget(uuid) {
|
|
117
|
-
let wIndex = this.widgets.findIndex(w => w.uuid == uuid)
|
|
118
|
-
if (wIndex < 0) { return; } // not found
|
|
119
|
-
this.widgets.splice(wIndex, 1);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
updateWidgetType(uuid: string, newNodeType: string) {
|
|
123
|
-
let wIndex = this.widgets.findIndex(w => w.uuid == uuid)
|
|
124
|
-
if (wIndex < 0) { return; } // not found
|
|
125
|
-
this.widgets[wIndex].config = null;
|
|
126
|
-
this.widgets[wIndex].type = newNodeType;
|
|
127
|
-
this.saveWidgets();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
updateWidgetConfig(uuid: string, newConfig) {
|
|
131
|
-
let wIndex = this.widgets.findIndex(w => w.uuid == uuid)
|
|
132
|
-
if (wIndex < 0) { return; } // not found
|
|
133
|
-
this.widgets[wIndex].config = newConfig;
|
|
134
|
-
this.saveWidgets();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
saveWidgets() {
|
|
138
|
-
this.AppSettingsService.saveWidgets(this.widgets);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<div #wrapperDiv class="textGenericWrapper">
|
|
2
|
-
<canvas id="canvasValue" class="canvas-size" #canvasEl></canvas>
|
|
3
|
-
<canvas id="cancasBG" class="canvas-size numeric-labels" #canvasBG></canvas>
|
|
4
|
-
|
|
5
|
-
<div #warn class='warn' style="display: none;"></div>
|
|
6
|
-
<div #warncontrast class='warn-contrast' style="display: none;"></div>
|
|
7
|
-
|
|
8
|
-
<div class="settingsButton" *ngIf="unlockStatus">
|
|
9
|
-
<button color="accent" mat-mini-fab class="selector-fab" (click)="openWidgetSettings()">
|
|
10
|
-
<span class="fa-solid fa-cog"></span>
|
|
11
|
-
</button>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
@use '~@angular/material' as mat;
|
|
2
|
-
|
|
3
|
-
@mixin widget-numeric-theme($theme) {
|
|
4
|
-
$primary: map-get($theme, primary);
|
|
5
|
-
$warn: map-get($theme, warn);
|
|
6
|
-
$background: map-get($theme, background);
|
|
7
|
-
$foreground: map-get($theme, foreground);
|
|
8
|
-
$wind: map-get($theme, wind);
|
|
9
|
-
|
|
10
|
-
.warn {
|
|
11
|
-
color: mat.get-color-from-palette($warn, 500);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.warn-contrast {
|
|
15
|
-
color: mat.get-contrast-color-from-palette($warn, 500);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
canvas.numeric-labels {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.textGenericWrapper {
|
|
24
|
-
position: relative;
|
|
25
|
-
width: 100%;
|
|
26
|
-
height: 100%;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.canvas-size {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 0;
|
|
32
|
-
left: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.settingsButton {
|
|
36
|
-
position: absolute;
|
|
37
|
-
bottom: 5%;
|
|
38
|
-
left: 50%;
|
|
39
|
-
transform: translate(-50%);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.tab-group {
|
|
43
|
-
border: 1px solid #e8e8e8;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.tab-content {
|
|
47
|
-
padding: 16px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.full-width {
|
|
51
|
-
width: 100%;
|
|
52
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { WidgetNumericComponent } from './widget-numeric.component';
|
|
4
|
-
|
|
5
|
-
describe('WidgetNumericComponent', () => {
|
|
6
|
-
let component: WidgetNumericComponent;
|
|
7
|
-
let fixture: ComponentFixture<WidgetNumericComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(waitForAsync(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ WidgetNumericComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(WidgetNumericComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should be created', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import { Component, Input, OnInit, OnDestroy, ViewChild, ElementRef, AfterViewChecked } from '@angular/core';
|
|
2
|
-
import { Subscription } from 'rxjs';
|
|
3
|
-
import { MatDialog } from '@angular/material/dialog';
|
|
4
|
-
|
|
5
|
-
import { ModalWidgetComponent } from '../modal-widget/modal-widget.component';
|
|
6
|
-
import { SignalKService } from '../signalk.service';
|
|
7
|
-
import { WidgetManagerService, IWidget, IWidgetConfig } from '../widget-manager.service';
|
|
8
|
-
import { UnitsService } from '../units.service';
|
|
9
|
-
import { AppSettingsService, ZoneState } from '../app-settings.service';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const defaultConfig: IWidgetConfig = {
|
|
13
|
-
displayName: null,
|
|
14
|
-
filterSelfPaths: true,
|
|
15
|
-
paths: {
|
|
16
|
-
"numericPath": {
|
|
17
|
-
description: "Numeric Data",
|
|
18
|
-
path: null,
|
|
19
|
-
source: null,
|
|
20
|
-
pathType: "number",
|
|
21
|
-
isPathConfigurable: true,
|
|
22
|
-
convertUnitTo: "unitless"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
showMax: false,
|
|
26
|
-
showMin: false,
|
|
27
|
-
numDecimal: 1,
|
|
28
|
-
numInt: 1
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
@Component({
|
|
32
|
-
selector: 'app-widget-numeric',
|
|
33
|
-
templateUrl: './widget-numeric.component.html',
|
|
34
|
-
styleUrls: ['./widget-numeric.component.scss']
|
|
35
|
-
})
|
|
36
|
-
export class WidgetNumericComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|
37
|
-
|
|
38
|
-
@Input('widgetUUID') widgetUUID: string;
|
|
39
|
-
@Input('unlockStatus') unlockStatus: boolean;
|
|
40
|
-
@ViewChild('canvasEl', {static: true, read: ElementRef}) canvasEl: ElementRef;
|
|
41
|
-
@ViewChild('canvasBG', {static: true, read: ElementRef}) canvasBG: ElementRef;
|
|
42
|
-
@ViewChild('wrapperDiv', {static: true, read: ElementRef}) wrapperDiv: ElementRef;
|
|
43
|
-
@ViewChild('warn', {static: true, read: ElementRef}) private warnElement: ElementRef;
|
|
44
|
-
@ViewChild('warncontrast', {static: true, read: ElementRef}) private warnContrastElement: ElementRef;
|
|
45
|
-
|
|
46
|
-
activeWidget: IWidget;
|
|
47
|
-
config: IWidgetConfig;
|
|
48
|
-
|
|
49
|
-
dataValue: number = null;
|
|
50
|
-
zoneState: ZoneState = null;
|
|
51
|
-
maxValue: number = null;
|
|
52
|
-
minValue: number = null;
|
|
53
|
-
dataTimestamp: number = Date.now();
|
|
54
|
-
currentValueLength: number = 0; // length (in charaters) of value text to be displayed. if changed from last time, need to recalculate font size...
|
|
55
|
-
currentMinMaxLength: number = 0;
|
|
56
|
-
valueFontSize: number = 1;
|
|
57
|
-
minMaxFontSize: number = 1;
|
|
58
|
-
flashOn: boolean = false;
|
|
59
|
-
flashInterval;
|
|
60
|
-
|
|
61
|
-
//subs
|
|
62
|
-
valueSub: Subscription = null;
|
|
63
|
-
|
|
64
|
-
// dynamics theme support
|
|
65
|
-
themeNameSub: Subscription = null;
|
|
66
|
-
|
|
67
|
-
canvasCtx;
|
|
68
|
-
canvasBGCtx;
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
public dialog:MatDialog,
|
|
72
|
-
private SignalKService: SignalKService,
|
|
73
|
-
private WidgetManagerService: WidgetManagerService,
|
|
74
|
-
private UnitsService: UnitsService,
|
|
75
|
-
private AppSettingsService: AppSettingsService, // need for theme change subscription
|
|
76
|
-
) {
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
ngOnInit() {
|
|
80
|
-
this.activeWidget = this.WidgetManagerService.getWidget(this.widgetUUID);
|
|
81
|
-
if (this.activeWidget.config === null) {
|
|
82
|
-
// no data, let's set some!
|
|
83
|
-
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, defaultConfig);
|
|
84
|
-
this.config = defaultConfig; // load default config.
|
|
85
|
-
} else {
|
|
86
|
-
this.config = this.activeWidget.config;
|
|
87
|
-
}
|
|
88
|
-
this.subscribePath();
|
|
89
|
-
this.subscribeTheme();
|
|
90
|
-
|
|
91
|
-
this.canvasCtx = this.canvasEl.nativeElement.getContext('2d');
|
|
92
|
-
this.canvasBGCtx = this.canvasBG.nativeElement.getContext('2d');
|
|
93
|
-
this.resizeWidget();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
ngOnDestroy() {
|
|
97
|
-
this.unsubscribePath();
|
|
98
|
-
this.unsubscribeTheme();
|
|
99
|
-
if (this.flashInterval) {
|
|
100
|
-
clearInterval(this.flashInterval);
|
|
101
|
-
this.flashInterval = null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
ngAfterViewChecked() {
|
|
106
|
-
this.resizeWidget();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
resizeWidget() {
|
|
110
|
-
let rect = this.wrapperDiv.nativeElement.getBoundingClientRect();
|
|
111
|
-
|
|
112
|
-
if (rect.height < 50) { return; }
|
|
113
|
-
if (rect.width < 50) { return; }
|
|
114
|
-
if ((this.canvasEl.nativeElement.width != Math.floor(rect.width)) || (this.canvasEl.nativeElement.height != Math.floor(rect.height))) {
|
|
115
|
-
this.canvasEl.nativeElement.width = Math.floor(rect.width);
|
|
116
|
-
this.canvasEl.nativeElement.height = Math.floor(rect.height);
|
|
117
|
-
this.canvasBG.nativeElement.width = Math.floor(rect.width);
|
|
118
|
-
this.canvasBG.nativeElement.height = Math.floor(rect.height);
|
|
119
|
-
this.currentValueLength = 0; //will force resetting the font size
|
|
120
|
-
this.currentMinMaxLength = 0;
|
|
121
|
-
this.updateCanvas();
|
|
122
|
-
this.updateCanvasBG();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
subscribePath() {
|
|
128
|
-
this.unsubscribePath();
|
|
129
|
-
if (typeof(this.config.paths['numericPath'].path) != 'string') { return } // nothing to sub to...
|
|
130
|
-
|
|
131
|
-
this.valueSub = this.SignalKService.subscribePath(this.widgetUUID, this.config.paths['numericPath'].path, this.config.paths['numericPath'].source).subscribe(
|
|
132
|
-
newValue => {
|
|
133
|
-
this.dataValue = newValue.value;
|
|
134
|
-
this.zoneState = newValue.state;
|
|
135
|
-
//start flashing if alarm
|
|
136
|
-
if (this.zoneState == ZoneState.alarm && !this.flashInterval) {
|
|
137
|
-
this.flashInterval = setInterval(() => {
|
|
138
|
-
this.flashOn = !this.flashOn;
|
|
139
|
-
this.updateCanvas();
|
|
140
|
-
}, 350); // used to flash stuff in alarm
|
|
141
|
-
} else if (this.zoneState != ZoneState.alarm) {
|
|
142
|
-
// stop alarming if not in alarm state
|
|
143
|
-
if (this.flashInterval) {
|
|
144
|
-
clearInterval(this.flashInterval);
|
|
145
|
-
this.flashInterval = null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// init min/max
|
|
149
|
-
if (this.minValue === null) { this.minValue = this.dataValue; }
|
|
150
|
-
if (this.maxValue === null) { this.maxValue = this.dataValue; }
|
|
151
|
-
if (this.dataValue > this.maxValue) { this.maxValue = this.dataValue; }
|
|
152
|
-
if (this.dataValue < this.minValue) { this.minValue = this.dataValue; }
|
|
153
|
-
this.updateCanvas();
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
unsubscribePath() {
|
|
159
|
-
if (this.valueSub !== null) {
|
|
160
|
-
this.valueSub.unsubscribe();
|
|
161
|
-
this.valueSub = null;
|
|
162
|
-
|
|
163
|
-
this.SignalKService.unsubscribePath(this.widgetUUID, this.config.paths['numericPath'].path);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Subscribe to theme event
|
|
168
|
-
subscribeTheme() {
|
|
169
|
-
this.themeNameSub = this.AppSettingsService.getThemeNameAsO().subscribe(
|
|
170
|
-
themeChange => {
|
|
171
|
-
setTimeout(() => { // need a delay so browser getComputedStyles has time to complete theme application.
|
|
172
|
-
this.updateCanvas();
|
|
173
|
-
this.updateCanvasBG();
|
|
174
|
-
}, 100);
|
|
175
|
-
})
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
unsubscribeTheme(){
|
|
179
|
-
if (this.themeNameSub !== null) {
|
|
180
|
-
this.themeNameSub.unsubscribe();
|
|
181
|
-
this.themeNameSub = null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
openWidgetSettings() {
|
|
186
|
-
|
|
187
|
-
let dialogRef = this.dialog.open(ModalWidgetComponent, {
|
|
188
|
-
width: '80%',
|
|
189
|
-
data: this.config
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
dialogRef.afterClosed().subscribe(result => {
|
|
193
|
-
// save new settings
|
|
194
|
-
if (result) {
|
|
195
|
-
console.log(result);
|
|
196
|
-
this.unsubscribePath();//unsub now as we will change variables so wont know what was subbed before...
|
|
197
|
-
this.config = result;
|
|
198
|
-
this.WidgetManagerService.updateWidgetConfig(this.widgetUUID, this.config);
|
|
199
|
-
this.subscribePath();
|
|
200
|
-
this.updateCanvas();
|
|
201
|
-
this.updateCanvasBG();
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/* ******************************************************************************************* */
|
|
207
|
-
/* ******************************************************************************************* */
|
|
208
|
-
/* ******************************************************************************************* */
|
|
209
|
-
/* Canvas */
|
|
210
|
-
/* ******************************************************************************************* */
|
|
211
|
-
/* ******************************************************************************************* */
|
|
212
|
-
/* ******************************************************************************************* */
|
|
213
|
-
|
|
214
|
-
updateCanvas() {
|
|
215
|
-
if (this.canvasCtx) {
|
|
216
|
-
this.canvasCtx.clearRect(0,0,this.canvasEl.nativeElement.width, this.canvasEl.nativeElement.height);
|
|
217
|
-
this.drawValue();
|
|
218
|
-
if (this.config.showMax || this.config.showMin) {
|
|
219
|
-
this.drawMinMax();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
updateCanvasBG() {
|
|
225
|
-
if (this.canvasBGCtx) {
|
|
226
|
-
this.canvasBGCtx.clearRect(0,0,this.canvasEl.nativeElement.width, this.canvasEl.nativeElement.height);
|
|
227
|
-
this.drawTitle();
|
|
228
|
-
this.drawUnit();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
drawValue() {
|
|
235
|
-
let maxTextWidth = Math.floor(this.canvasEl.nativeElement.width - (this.canvasEl.nativeElement.width * 0.15));
|
|
236
|
-
let maxTextHeight = Math.floor(this.canvasEl.nativeElement.height - (this.canvasEl.nativeElement.height * 0.2));
|
|
237
|
-
let valueText: any;
|
|
238
|
-
|
|
239
|
-
if (this.dataValue != null) {
|
|
240
|
-
let converted: number = Number(this.dataValue);
|
|
241
|
-
converted = this.UnitsService.convertUnit(this.config.paths['numericPath'].convertUnitTo, this.dataValue);
|
|
242
|
-
if (!isNaN(converted)) { // retest as convert stuff might have returned a text string
|
|
243
|
-
valueText = this.padValue(converted.toFixed(this.config.numDecimal), this.config.numInt, this.config.numDecimal);
|
|
244
|
-
} else {
|
|
245
|
-
valueText = converted;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
} else {
|
|
249
|
-
valueText = "--";
|
|
250
|
-
}
|
|
251
|
-
//check if length of string has changed since laste time.
|
|
252
|
-
if (this.currentValueLength != valueText.length) {
|
|
253
|
-
//we need to set font size...
|
|
254
|
-
this.currentValueLength = valueText.length;
|
|
255
|
-
|
|
256
|
-
// start with large font, no sense in going bigger than the size of the canvas :)
|
|
257
|
-
this.valueFontSize = maxTextHeight;
|
|
258
|
-
this.canvasCtx.font = "bold " + this.valueFontSize.toString() + "px Arial";
|
|
259
|
-
let measure = this.canvasCtx.measureText(valueText).width;
|
|
260
|
-
|
|
261
|
-
// if we are not too wide, we stop there, maxHeight was our limit... if we're too wide, we need to scale back
|
|
262
|
-
if (measure > maxTextWidth) {
|
|
263
|
-
let estimateRatio = maxTextWidth / measure;
|
|
264
|
-
this.valueFontSize = Math.floor(this.valueFontSize * estimateRatio);
|
|
265
|
-
this.canvasCtx.font = "bold " + this.valueFontSize.toString() + "px Arial";
|
|
266
|
-
}
|
|
267
|
-
// now decrease by 1 to in case still too big
|
|
268
|
-
while (this.canvasCtx.measureText(valueText).width > maxTextWidth && this.valueFontSize > 0) {
|
|
269
|
-
this.valueFontSize--;
|
|
270
|
-
this.canvasCtx.font = "bold " + this.valueFontSize.toString() + "px Arial";
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// get color based on zone
|
|
275
|
-
switch (this.zoneState) {
|
|
276
|
-
|
|
277
|
-
case ZoneState.alarm:
|
|
278
|
-
|
|
279
|
-
if (this.flashOn) {
|
|
280
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.warnElement.nativeElement).color;
|
|
281
|
-
} else {
|
|
282
|
-
// draw warn background
|
|
283
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.warnElement.nativeElement).color;
|
|
284
|
-
this.canvasCtx.fillRect(0,0,this.canvasEl.nativeElement.width, this.canvasEl.nativeElement.height);
|
|
285
|
-
// text color
|
|
286
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.warnContrastElement.nativeElement).color;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
break;
|
|
291
|
-
|
|
292
|
-
case ZoneState.warning:
|
|
293
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.warnElement.nativeElement).color;
|
|
294
|
-
break;
|
|
295
|
-
|
|
296
|
-
default:
|
|
297
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.wrapperDiv.nativeElement).color;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
this.canvasCtx.font = "bold " + this.valueFontSize.toString() + "px Arial";
|
|
301
|
-
this.canvasCtx.textAlign = "center";
|
|
302
|
-
this.canvasCtx.textBaseline="middle";
|
|
303
|
-
this.canvasCtx.fillText(valueText,this.canvasEl.nativeElement.width/2,(this.canvasEl.nativeElement.height/2)+(this.valueFontSize/15), maxTextWidth);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
drawTitle() {
|
|
307
|
-
var maxTextWidth = Math.floor(this.canvasEl.nativeElement.width - (this.canvasEl.nativeElement.width * 0.2));
|
|
308
|
-
var maxTextHeight = Math.floor(this.canvasEl.nativeElement.height - (this.canvasEl.nativeElement.height * 0.8));
|
|
309
|
-
// set font small and make bigger until we hit a max.
|
|
310
|
-
if (this.config.displayName === null) { return; }
|
|
311
|
-
|
|
312
|
-
// start with large font, no sense in going bigger than the size of the canvas :)
|
|
313
|
-
var fontSize = maxTextHeight;
|
|
314
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
315
|
-
let measure = this.canvasBGCtx.measureText(this.config.displayName).width;
|
|
316
|
-
|
|
317
|
-
// if we are not too wide, we stop there, maxHeight was our limit... if we're too wide, we need to scale back
|
|
318
|
-
if (measure > maxTextWidth) {
|
|
319
|
-
let estimateRatio = maxTextWidth / measure;
|
|
320
|
-
fontSize = Math.floor(fontSize * estimateRatio);
|
|
321
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
322
|
-
}
|
|
323
|
-
// now decrease by 1 to in case still too big
|
|
324
|
-
while (this.canvasBGCtx.measureText(this.config.displayName).width > maxTextWidth && fontSize > 0) {
|
|
325
|
-
fontSize--;
|
|
326
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
this.canvasBGCtx.textAlign = "left";
|
|
330
|
-
this.canvasBGCtx.textBaseline="top";
|
|
331
|
-
this.canvasBGCtx.fillStyle = window.getComputedStyle(this.wrapperDiv.nativeElement).color;
|
|
332
|
-
this.canvasBGCtx.fillText(this.config.displayName,this.canvasEl.nativeElement.width*0.03,this.canvasEl.nativeElement.height*0.03, maxTextWidth);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
drawUnit() {
|
|
336
|
-
if (this.config.paths['numericPath'].convertUnitTo == 'unitless') { return; }
|
|
337
|
-
if (this.config.paths['numericPath'].convertUnitTo.startsWith('percent')) { return; }
|
|
338
|
-
if (this.config.paths['numericPath'].convertUnitTo == 'ratio') { return; }
|
|
339
|
-
if (this.config.paths['numericPath'].convertUnitTo.startsWith('lat')) { return; }
|
|
340
|
-
if (this.config.paths['numericPath'].convertUnitTo.startsWith('lon')) { return; }
|
|
341
|
-
var maxTextWidth = Math.floor(this.canvasEl.nativeElement.width - (this.canvasEl.nativeElement.width * 0.8));
|
|
342
|
-
var maxTextHeight = Math.floor(this.canvasEl.nativeElement.height - (this.canvasEl.nativeElement.height * 0.8));
|
|
343
|
-
|
|
344
|
-
// start with large font, no sense in going bigger than the size of the canvas :)
|
|
345
|
-
var fontSize = maxTextHeight;
|
|
346
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
347
|
-
let measure = this.canvasBGCtx.measureText(this.config.paths['numericPath'].convertUnitTo).width;
|
|
348
|
-
|
|
349
|
-
// if we are not too wide, we stop there, maxHeight was our limit... if we're too wide, we need to scale back
|
|
350
|
-
if (measure > maxTextWidth) {
|
|
351
|
-
let estimateRatio = maxTextWidth / measure;
|
|
352
|
-
fontSize = Math.floor(fontSize * estimateRatio);
|
|
353
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
354
|
-
}
|
|
355
|
-
// now decrease by 1 to in case still too big
|
|
356
|
-
while (this.canvasBGCtx.measureText(this.config.paths['numericPath'].convertUnitTo).width > maxTextWidth && fontSize > 0) {
|
|
357
|
-
fontSize--;
|
|
358
|
-
this.canvasBGCtx.font = "bold " + fontSize.toString() + "px Arial";
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
this.canvasBGCtx.textAlign = "right";
|
|
362
|
-
this.canvasBGCtx.textBaseline="bottom";
|
|
363
|
-
this.canvasBGCtx.fillStyle = window.getComputedStyle(this.wrapperDiv.nativeElement).color;
|
|
364
|
-
this.canvasBGCtx.fillText(this.config.paths['numericPath'].convertUnitTo,this.canvasEl.nativeElement.width*0.97,this.canvasEl.nativeElement.height*0.97, maxTextWidth);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
drawMinMax() {
|
|
368
|
-
|
|
369
|
-
if (!this.config.showMin && !this.config.showMax) { return; } //no need to do anything if we're not showing min/max
|
|
370
|
-
|
|
371
|
-
let valueText: string = '';
|
|
372
|
-
|
|
373
|
-
if (this.config.showMin) {
|
|
374
|
-
if (this.minValue != null) {
|
|
375
|
-
let converted: number = this.UnitsService.convertUnit(this.config.paths['numericPath'].convertUnitTo, this.minValue);
|
|
376
|
-
if (!isNaN(converted)) { // retest as convert stuff might have returned a text string
|
|
377
|
-
valueText = valueText + " Min: " + this.padValue(converted.toFixed(this.config.numDecimal), this.config.numInt, this.config.numDecimal);
|
|
378
|
-
} else {
|
|
379
|
-
valueText = valueText + " Min: " + converted;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
} else {
|
|
383
|
-
valueText = valueText + " Min: --";
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (this.config.showMax) {
|
|
387
|
-
if (this.maxValue != null) {
|
|
388
|
-
let converted = this.UnitsService.convertUnit(this.config.paths['numericPath'].convertUnitTo, this.maxValue);
|
|
389
|
-
if (!isNaN(converted)) { // retest as convert stuff might have returned a text string
|
|
390
|
-
valueText = valueText + " Max: " + this.padValue(converted.toFixed(this.config.numDecimal), this.config.numInt, this.config.numDecimal);
|
|
391
|
-
} else {
|
|
392
|
-
valueText = valueText + " Max: " + converted;
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
valueText = valueText + " Max: --";
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
valueText = valueText.trim();
|
|
399
|
-
|
|
400
|
-
if (this.currentMinMaxLength != valueText.length) {
|
|
401
|
-
this.currentMinMaxLength = valueText.length;
|
|
402
|
-
var maxTextWidth = Math.floor(this.canvasEl.nativeElement.width - (this.canvasEl.nativeElement.width * 0.6));
|
|
403
|
-
var maxTextHeight = Math.floor(this.canvasEl.nativeElement.height - (this.canvasEl.nativeElement.height * 0.85));
|
|
404
|
-
|
|
405
|
-
// start with large font, no sense in going bigger than the size of the canvas :)
|
|
406
|
-
this.minMaxFontSize = maxTextHeight;
|
|
407
|
-
this.canvasBGCtx.font = "bold " + this.minMaxFontSize.toString() + "px Arial";
|
|
408
|
-
let measure = this.canvasBGCtx.measureText(valueText).width;
|
|
409
|
-
|
|
410
|
-
// if we are not too wide, we stop there, maxHeight was our limit... if we're too wide, we need to scale back
|
|
411
|
-
if (measure > maxTextWidth) {
|
|
412
|
-
let estimateRatio = maxTextWidth / measure;
|
|
413
|
-
this.minMaxFontSize = Math.floor(this.minMaxFontSize * estimateRatio);
|
|
414
|
-
this.canvasBGCtx.font = "bold " + this.minMaxFontSize.toString() + "px Arial";
|
|
415
|
-
}
|
|
416
|
-
// now decrease by 1 to in case still too big
|
|
417
|
-
while (this.canvasBGCtx.measureText(valueText).width > maxTextWidth && this.minMaxFontSize > 0) {
|
|
418
|
-
this.minMaxFontSize--;
|
|
419
|
-
this.canvasBGCtx.font = "bold " + this.minMaxFontSize.toString() + "px Arial";
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
this.canvasCtx.font = "bold " + this.minMaxFontSize.toString() + "px Arial";
|
|
425
|
-
this.canvasCtx.textAlign = "left";
|
|
426
|
-
this.canvasCtx.textBaseline="bottom";
|
|
427
|
-
this.canvasCtx.fillStyle = window.getComputedStyle(this.wrapperDiv.nativeElement).color;
|
|
428
|
-
this.canvasCtx.fillText(valueText,this.canvasEl.nativeElement.width*0.03,this.canvasEl.nativeElement.height*0.97, maxTextWidth);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
padValue(val, int, dec): string {
|
|
432
|
-
let i = 0;
|
|
433
|
-
let s, n, foo;
|
|
434
|
-
let strVal: string
|
|
435
|
-
val = parseFloat(val);
|
|
436
|
-
n = (val < 0);
|
|
437
|
-
val = Math.abs(val);
|
|
438
|
-
if (dec > 0) {
|
|
439
|
-
foo = val.toFixed(dec).toString().split('.');
|
|
440
|
-
s = int - foo[0].length;
|
|
441
|
-
for (; i < s; ++i) {
|
|
442
|
-
foo[0] = '0' + foo[0];
|
|
443
|
-
}
|
|
444
|
-
strVal = (n ? '-' : '') + foo[0] + '.' + foo[1];
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
strVal = Math.round(val).toString();
|
|
448
|
-
s = int - strVal.length;
|
|
449
|
-
for (; i < s; ++i) {
|
|
450
|
-
strVal = '0' + strVal;
|
|
451
|
-
}
|
|
452
|
-
strVal = (n ? '-' : '') + strVal;
|
|
453
|
-
}
|
|
454
|
-
return strVal;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
}
|