@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.
Files changed (277) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/CONTRIBUTORS.md +4 -4
  3. package/KipGaugeSample3-1024x508.png +0 -0
  4. package/LICENSE +21 -0
  5. package/README.md +80 -42
  6. package/package.json +52 -46
  7. package/public/3rdpartylicenses.txt +47 -419
  8. package/public/assets/NoSleep.min.js +2 -2
  9. package/public/assets/icon-64x64.png +0 -0
  10. package/public/assets/icon-72x72.png +0 -0
  11. package/public/index.html +3 -3
  12. package/public/main.f3d15cc777474f5f.js +1 -0
  13. package/public/manifest.json +9 -4
  14. package/public/polyfills.64db6be9cdc8f808.js +1 -0
  15. package/public/runtime.e75056c32c37f59d.js +1 -0
  16. package/public/styles.6b1c2c92be18a2cc.css +1 -0
  17. package/.angulardoc.json +0 -4
  18. package/angular.json +0 -162
  19. package/e2e/app.e2e-spec.ts +0 -14
  20. package/e2e/app.po.ts +0 -11
  21. package/e2e/tsconfig.e2e.json +0 -14
  22. package/karma.conf.js +0 -31
  23. package/protractor.conf.js +0 -28
  24. package/public/assets/svg-autopilot-inkscape-plain.svg +0 -983
  25. package/public/assets/svg-wind-inkscape.svg +0 -1358
  26. package/public/main-es2018.98175eb4c61ccaf7eb17.js +0 -1
  27. package/public/main-es5.98175eb4c61ccaf7eb17.js +0 -1
  28. package/public/polyfills-es2018.3a61665863c173cd6ba3.js +0 -1
  29. package/public/polyfills-es5.44827ae4ff4e41de51fb.js +0 -1
  30. package/public/runtime-es2018.baedb88c6d2abacae2b8.js +0 -1
  31. package/public/runtime-es5.baedb88c6d2abacae2b8.js +0 -1
  32. package/public/styles.b92ae2c466c89712209d.css +0 -5
  33. package/src/app/alarm-menu/alarm-menu.component.html +0 -55
  34. package/src/app/alarm-menu/alarm-menu.component.scss +0 -52
  35. package/src/app/alarm-menu/alarm-menu.component.spec.ts +0 -25
  36. package/src/app/alarm-menu/alarm-menu.component.ts +0 -186
  37. package/src/app/app-help/app-help.component.css +0 -4
  38. package/src/app/app-help/app-help.component.html +0 -135
  39. package/src/app/app-help/app-help.component.ts +0 -45
  40. package/src/app/app-settings.service.spec.ts +0 -15
  41. package/src/app/app-settings.service.ts +0 -478
  42. package/src/app/app.component.css +0 -39
  43. package/src/app/app.component.html +0 -93
  44. package/src/app/app.component.scss +0 -79
  45. package/src/app/app.component.spec.ts +0 -32
  46. package/src/app/app.component.ts +0 -191
  47. package/src/app/app.module.ts +0 -200
  48. package/src/app/config.blank.const.ts +0 -52
  49. package/src/app/config.blank.notification.const.ts +0 -19
  50. package/src/app/config.blank.units.const.ts +0 -23
  51. package/src/app/config.demo.const.ts +0 -384
  52. package/src/app/data-browser/data-browser.component.css +0 -29
  53. package/src/app/data-browser/data-browser.component.html +0 -44
  54. package/src/app/data-browser/data-browser.component.spec.ts +0 -25
  55. package/src/app/data-browser/data-browser.component.ts +0 -91
  56. package/src/app/data-browser-row/data-browser-row-unit-modal.html +0 -17
  57. package/src/app/data-browser-row/data-browser-row.component.css +0 -10
  58. package/src/app/data-browser-row/data-browser-row.component.html +0 -5
  59. package/src/app/data-browser-row/data-browser-row.component.ts +0 -79
  60. package/src/app/data-set.service.spec.ts +0 -15
  61. package/src/app/data-set.service.ts +0 -273
  62. package/src/app/dynamic-widget.directive.spec.ts +0 -8
  63. package/src/app/dynamic-widget.directive.ts +0 -11
  64. package/src/app/filter-self.pipe.spec.ts +0 -8
  65. package/src/app/filter-self.pipe.ts +0 -14
  66. package/src/app/fit-text.directive.spec.ts +0 -8
  67. package/src/app/fit-text.directive.ts +0 -61
  68. package/src/app/gauge-steel/gauge-steel.component.css +0 -5
  69. package/src/app/gauge-steel/gauge-steel.component.html +0 -4
  70. package/src/app/gauge-steel/gauge-steel.component.spec.ts +0 -25
  71. package/src/app/gauge-steel/gauge-steel.component.ts +0 -282
  72. package/src/app/gauges-module/base-gauge.ts +0 -301
  73. package/src/app/gauges-module/gauges.module.ts +0 -17
  74. package/src/app/gauges-module/linear-gauge.ts +0 -50
  75. package/src/app/gauges-module/radial-gauge.ts +0 -48
  76. package/src/app/layout-split/layout-split.component.html +0 -30
  77. package/src/app/layout-split/layout-split.component.scss +0 -33
  78. package/src/app/layout-split/layout-split.component.spec.ts +0 -25
  79. package/src/app/layout-split/layout-split.component.ts +0 -59
  80. package/src/app/layout-splits.service.spec.ts +0 -15
  81. package/src/app/layout-splits.service.ts +0 -284
  82. package/src/app/modal-path-selector/modal-path-selector.component.html +0 -62
  83. package/src/app/modal-path-selector/modal-path-selector.component.scss +0 -39
  84. package/src/app/modal-path-selector/modal-path-selector.component.spec.ts +0 -25
  85. package/src/app/modal-path-selector/modal-path-selector.component.ts +0 -132
  86. package/src/app/modal-widget/modal-widget.component.css +0 -33
  87. package/src/app/modal-widget/modal-widget.component.html +0 -341
  88. package/src/app/modal-widget/modal-widget.component.spec.ts +0 -25
  89. package/src/app/modal-widget/modal-widget.component.ts +0 -84
  90. package/src/app/notifications.service.spec.ts +0 -12
  91. package/src/app/notifications.service.ts +0 -392
  92. package/src/app/object-keys.pipe.spec.ts +0 -8
  93. package/src/app/object-keys.pipe.ts +0 -13
  94. package/src/app/reset-config/reset-config.component.css +0 -0
  95. package/src/app/reset-config/reset-config.component.html +0 -3
  96. package/src/app/reset-config/reset-config.component.spec.ts +0 -25
  97. package/src/app/reset-config/reset-config.component.ts +0 -31
  98. package/src/app/root-display/root-display.component.css +0 -0
  99. package/src/app/root-display/root-display.component.html +0 -4
  100. package/src/app/root-display/root-display.component.spec.ts +0 -25
  101. package/src/app/root-display/root-display.component.ts +0 -57
  102. package/src/app/safe.pipe.ts +0 -16
  103. package/src/app/settings/settings.component.css +0 -9
  104. package/src/app/settings/settings.component.html +0 -25
  105. package/src/app/settings/settings.component.spec.ts +0 -25
  106. package/src/app/settings/settings.component.ts +0 -22
  107. package/src/app/settings-config/settings-config.component.css +0 -39
  108. package/src/app/settings-config/settings-config.component.html +0 -118
  109. package/src/app/settings-config/settings-config.component.spec.ts +0 -25
  110. package/src/app/settings-config/settings-config.component.ts +0 -161
  111. package/src/app/settings-datasets/settings-datasets.component.html +0 -43
  112. package/src/app/settings-datasets/settings-datasets.component.scss +0 -39
  113. package/src/app/settings-datasets/settings-datasets.component.spec.ts +0 -25
  114. package/src/app/settings-datasets/settings-datasets.component.ts +0 -98
  115. package/src/app/settings-datasets/settings-datasets.modal.html +0 -54
  116. package/src/app/settings-notifications/settings-notifications.component.css +0 -0
  117. package/src/app/settings-notifications/settings-notifications.component.html +0 -65
  118. package/src/app/settings-notifications/settings-notifications.component.spec.ts +0 -25
  119. package/src/app/settings-notifications/settings-notifications.component.ts +0 -29
  120. package/src/app/settings-signalk/settings-signalk.component.css +0 -3
  121. package/src/app/settings-signalk/settings-signalk.component.html +0 -89
  122. package/src/app/settings-signalk/settings-signalk.component.spec.ts +0 -25
  123. package/src/app/settings-signalk/settings-signalk.component.ts +0 -174
  124. package/src/app/settings-units/settings-units.component.css +0 -4
  125. package/src/app/settings-units/settings-units.component.html +0 -19
  126. package/src/app/settings-units/settings-units.component.spec.ts +0 -25
  127. package/src/app/settings-units/settings-units.component.ts +0 -62
  128. package/src/app/settings-zones/settings-zones.component.css +0 -22
  129. package/src/app/settings-zones/settings-zones.component.html +0 -70
  130. package/src/app/settings-zones/settings-zones.component.ts +0 -154
  131. package/src/app/settings-zones/settings-zones.modal.css +0 -14
  132. package/src/app/settings-zones/settings-zones.modal.html +0 -39
  133. package/src/app/signalk-connection.service.ts +0 -344
  134. package/src/app/signalk-delta.service.spec.ts +0 -15
  135. package/src/app/signalk-delta.service.ts +0 -97
  136. package/src/app/signalk-full.service.spec.ts +0 -15
  137. package/src/app/signalk-full.service.ts +0 -99
  138. package/src/app/signalk-interfaces.ts +0 -129
  139. package/src/app/signalk-requests.service.spec.ts +0 -12
  140. package/src/app/signalk-requests.service.ts +0 -180
  141. package/src/app/signalk.service.spec.ts +0 -15
  142. package/src/app/signalk.service.ts +0 -428
  143. package/src/app/svg-autopilot/svg-autopilot.component.html +0 -1036
  144. package/src/app/svg-autopilot/svg-autopilot.component.spec.ts +0 -25
  145. package/src/app/svg-autopilot/svg-autopilot.component.ts +0 -174
  146. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.html +0 -119
  147. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.scss +0 -0
  148. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.spec.ts +0 -25
  149. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.ts +0 -49
  150. package/src/app/svg-wind/svg-wind.component.css +0 -0
  151. package/src/app/svg-wind/svg-wind.component.html +0 -969
  152. package/src/app/svg-wind/svg-wind.component.scss +0 -76
  153. package/src/app/svg-wind/svg-wind.component.spec.ts +0 -25
  154. package/src/app/svg-wind/svg-wind.component.ts +0 -280
  155. package/src/app/unit-window/unit-window.component.css +0 -37
  156. package/src/app/unit-window/unit-window.component.html +0 -8
  157. package/src/app/unit-window/unit-window.component.spec.ts +0 -25
  158. package/src/app/unit-window/unit-window.component.ts +0 -134
  159. package/src/app/unit-window/unit-window.modal.html +0 -25
  160. package/src/app/units.service.ts +0 -300
  161. package/src/app/widget-autopilot/widget-autopilot.component.html +0 -78
  162. package/src/app/widget-autopilot/widget-autopilot.component.scss +0 -191
  163. package/src/app/widget-autopilot/widget-autopilot.component.spec.ts +0 -25
  164. package/src/app/widget-autopilot/widget-autopilot.component.ts +0 -774
  165. package/src/app/widget-blank/widget-blank.component.html +0 -5
  166. package/src/app/widget-blank/widget-blank.component.scss +0 -21
  167. package/src/app/widget-blank/widget-blank.component.spec.ts +0 -25
  168. package/src/app/widget-blank/widget-blank.component.ts +0 -17
  169. package/src/app/widget-gauge/widget-gauge.component.css +0 -26
  170. package/src/app/widget-gauge/widget-gauge.component.html +0 -29
  171. package/src/app/widget-gauge/widget-gauge.component.spec.ts +0 -25
  172. package/src/app/widget-gauge/widget-gauge.component.ts +0 -120
  173. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.html +0 -126
  174. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.scss +0 -94
  175. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.spec.ts +0 -25
  176. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.ts +0 -424
  177. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.html +0 -122
  178. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.scss +0 -69
  179. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.spec.ts +0 -25
  180. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.ts +0 -553
  181. package/src/app/widget-historical/widget-historical.component.css +0 -31
  182. package/src/app/widget-historical/widget-historical.component.html +0 -14
  183. package/src/app/widget-historical/widget-historical.component.scss +0 -0
  184. package/src/app/widget-historical/widget-historical.component.spec.ts +0 -25
  185. package/src/app/widget-historical/widget-historical.component.ts +0 -306
  186. package/src/app/widget-iframe/widget-iframe.component.css +0 -12
  187. package/src/app/widget-iframe/widget-iframe.component.html +0 -21
  188. package/src/app/widget-iframe/widget-iframe.component.spec.ts +0 -25
  189. package/src/app/widget-iframe/widget-iframe.component.ts +0 -63
  190. package/src/app/widget-list.service.spec.ts +0 -15
  191. package/src/app/widget-list.service.ts +0 -135
  192. package/src/app/widget-manager.service.spec.ts +0 -15
  193. package/src/app/widget-manager.service.ts +0 -141
  194. package/src/app/widget-numeric/widget-numeric.component.html +0 -13
  195. package/src/app/widget-numeric/widget-numeric.component.scss +0 -52
  196. package/src/app/widget-numeric/widget-numeric.component.spec.ts +0 -25
  197. package/src/app/widget-numeric/widget-numeric.component.ts +0 -457
  198. package/src/app/widget-simple-linear/widget-simple-linear.component.html +0 -28
  199. package/src/app/widget-simple-linear/widget-simple-linear.component.scss +0 -64
  200. package/src/app/widget-simple-linear/widget-simple-linear.component.spec.ts +0 -25
  201. package/src/app/widget-simple-linear/widget-simple-linear.component.ts +0 -199
  202. package/src/app/widget-state/widget-state.component.html +0 -27
  203. package/src/app/widget-state/widget-state.component.scss +0 -68
  204. package/src/app/widget-state/widget-state.component.spec.ts +0 -25
  205. package/src/app/widget-state/widget-state.component.ts +0 -178
  206. package/src/app/widget-switch/widget-switch.component.css +0 -70
  207. package/src/app/widget-switch/widget-switch.component.html +0 -17
  208. package/src/app/widget-switch/widget-switch.component.spec.ts +0 -25
  209. package/src/app/widget-switch/widget-switch.component.ts +0 -134
  210. package/src/app/widget-text-generic/widget-text-generic.component.css +0 -55
  211. package/src/app/widget-text-generic/widget-text-generic.component.html +0 -9
  212. package/src/app/widget-text-generic/widget-text-generic.component.spec.ts +0 -25
  213. package/src/app/widget-text-generic/widget-text-generic.component.ts +0 -253
  214. package/src/app/widget-tutorial/widget-tutorial.component.css +0 -0
  215. package/src/app/widget-tutorial/widget-tutorial.component.html +0 -34
  216. package/src/app/widget-tutorial/widget-tutorial.component.spec.ts +0 -25
  217. package/src/app/widget-tutorial/widget-tutorial.component.ts +0 -18
  218. package/src/app/widget-unknown/widget-unknown.component.css +0 -0
  219. package/src/app/widget-unknown/widget-unknown.component.html +0 -3
  220. package/src/app/widget-unknown/widget-unknown.component.spec.ts +0 -25
  221. package/src/app/widget-unknown/widget-unknown.component.ts +0 -15
  222. package/src/app/widget-wind/widget-wind.component.css +0 -24
  223. package/src/app/widget-wind/widget-wind.component.html +0 -20
  224. package/src/app/widget-wind/widget-wind.component.spec.ts +0 -25
  225. package/src/app/widget-wind/widget-wind.component.ts +0 -369
  226. package/src/assets/.gitkeep +0 -0
  227. package/src/assets/NoSleep.min.js +0 -2
  228. package/src/assets/alarm.mp3 +0 -0
  229. package/src/assets/alert.mp3 +0 -0
  230. package/src/assets/alertl.old.mp3 +0 -0
  231. package/src/assets/emergency.mp3 +0 -0
  232. package/src/assets/fontawesome6/css/all.min.css +0 -6
  233. package/src/assets/fontawesome6/webfonts/fa-brands-400.ttf +0 -0
  234. package/src/assets/fontawesome6/webfonts/fa-brands-400.woff2 +0 -0
  235. package/src/assets/fontawesome6/webfonts/fa-regular-400.ttf +0 -0
  236. package/src/assets/fontawesome6/webfonts/fa-regular-400.woff2 +0 -0
  237. package/src/assets/fontawesome6/webfonts/fa-solid-900.ttf +0 -0
  238. package/src/assets/fontawesome6/webfonts/fa-solid-900.woff2 +0 -0
  239. package/src/assets/fontawesome6/webfonts/fa-v4compatibility.ttf +0 -0
  240. package/src/assets/fontawesome6/webfonts/fa-v4compatibility.woff2 +0 -0
  241. package/src/assets/icon-192x192.png +0 -0
  242. package/src/assets/icon-256x256.png +0 -0
  243. package/src/assets/icon-384x384.png +0 -0
  244. package/src/assets/icon-512x512.png +0 -0
  245. package/src/assets/notification.mp3 +0 -0
  246. package/src/assets/steelseries-min.js +0 -25
  247. package/src/assets/steelseries-min.js.map +0 -8
  248. package/src/assets/steelseries.js +0 -15834
  249. package/src/assets/svg-autopilot-inkscape-plain.svg +0 -983
  250. package/src/assets/svg-wind-inkscape.svg +0 -1358
  251. package/src/assets/tween-min.js +0 -1
  252. package/src/assets/tween.js +0 -381
  253. package/src/assets/warn.mp3 +0 -0
  254. package/src/environments/environment.prod.ts +0 -3
  255. package/src/environments/environment.ts +0 -8
  256. package/src/favicon.ico +0 -0
  257. package/src/index.html +0 -20
  258. package/src/main.ts +0 -11
  259. package/src/manifest.json +0 -33
  260. package/src/polyfills.ts +0 -80
  261. package/src/styles.css +0 -47
  262. package/src/styles.scss +0 -157
  263. package/src/test.ts +0 -32
  264. package/src/themes/darkBlueTheme.scss +0 -117
  265. package/src/themes/defaultTheme.scss +0 -50
  266. package/src/themes/highContrastTheme.scss +0 -47
  267. package/src/themes/modernTheme.scss +0 -143
  268. package/src/themes/nightMode.scss +0 -185
  269. package/src/themes/platypusTheme.scss +0 -80
  270. package/src/themes/signalkTheme.scss +0 -112
  271. package/src/tsconfig.app.json +0 -15
  272. package/src/tsconfig.spec.json +0 -20
  273. package/src/typings.d.ts +0 -5
  274. package/tsconfig.json +0 -24
  275. package/tslint.json +0 -143
  276. /package/{KipGaugeSample-1-1024x545.png → KipGaugeSample1-1024x545.png} +0 -0
  277. /package/{KipMonitor-1024x488.png → KipGaugeSample2-1024x488.png} +0 -0
@@ -1,99 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- import { SignalKService } from './signalk.service';
4
-
5
- @Injectable()
6
- export class SignalKFullService {
7
-
8
- constructor(private SignalKService: SignalKService,) { }
9
-
10
-
11
- processFullUpdate(data) {
12
-
13
- //set self urn
14
- this.SignalKService.setSelf(data.self)
15
-
16
- // set Sources
17
- //this.SignalKService.setDataFull(data);
18
-
19
- // so we will walk the array recusively
20
- this.findKeys(data);
21
- }
22
-
23
- findKeys(data, currentPath: string[] = []) {
24
- let path = currentPath.join('.');
25
-
26
- if (data === null) { //notifications don't have timestamp... hmmm TODO get notif into tree...
27
- return;
28
- }
29
- if (path == 'sources') { return; } // ignore the sources tree
30
-
31
- if ( (typeof(data) == 'string') || (typeof(data) == 'number') || (typeof(data) == 'boolean')) { // is it a simple value?
32
- let timestamp = Date.now();
33
- let source = 'noSource'
34
- this.SignalKService.updatePathData(path, source, timestamp, data);
35
- this.SignalKService.setDefaultSource(path, source);
36
- return;
37
- }
38
- else if ('timestamp' in data) { // is it a timestamped value?
39
-
40
- // try and get source
41
- let source: string;
42
- if (typeof(data['$source']) == 'string') {
43
- source = data['$source'];
44
- } else if (typeof(data['source']) == 'object') {
45
- source = data['source']['label'];
46
- } else {
47
- source = 'noSource';
48
- }
49
-
50
- let timestamp = Date.parse(data.timestamp);
51
-
52
-
53
- // is it a normal value, or a compound value?
54
- if ('value' in data) {
55
- if (typeof(data['value']) == 'object' && (data['value'] !== null)) {
56
- // compound
57
- Object.keys(data['value']).forEach(key => {
58
- let compoundPath = path+"."+key;
59
- this.SignalKService.updatePathData(compoundPath, source, timestamp, data.value[key]);
60
- this.SignalKService.setDefaultSource(compoundPath, source);
61
- // try and get metadata.
62
- if (typeof(data['meta']) == 'object') {
63
- //does meta have one with properties for each one?
64
- if (typeof(data.meta['properties']) == 'object' && typeof(data.meta.properties[key]) == 'object') {
65
- this.SignalKService.setMeta(compoundPath, data.meta.properties[key]);
66
- } else {
67
- this.SignalKService.setMeta(compoundPath, data['meta']);
68
- }
69
- }
70
- });
71
- } else {
72
- //simple
73
- this.SignalKService.updatePathData(path, source, timestamp, data.value);
74
- this.SignalKService.setDefaultSource(path, source);
75
- // try and get metadata.
76
- if (typeof(data['meta']) == 'object') {
77
- this.SignalKService.setMeta(path, data['meta']);
78
- }
79
- }
80
- }
81
-
82
- return;
83
- }
84
-
85
- // it's not a value, dig deaper
86
- else {
87
- // process children
88
- let keys = Object.keys(data);
89
- let len = keys.length;
90
- for (let i = 0; i < len; i += 1) {
91
- let newPath = currentPath.slice();
92
- newPath.push(keys[i])
93
- this.findKeys(data[keys[i]], newPath);
94
- }
95
- }
96
- }
97
-
98
-
99
- }
@@ -1,129 +0,0 @@
1
- import { ZoneState } from './app-settings.service';
2
-
3
-
4
- // Metadata, Notification and Stream Subscription type restrictions.
5
- const states = ["nominal", "normal", "alert", "warn", "alarm", "emergency"] as ["nominal", "normal", "alert", "warn", "alarm", "emergency"];
6
- type State = typeof states[number];
7
-
8
- const types = ["linear", "logarithmic", "squareroot", "power"] as ["linear", "logarithmic", "squareroot", "power"];
9
- type Type = typeof types[number];
10
-
11
- const methods = ["visual", "sound"] as ["visual", "sound"];
12
- type Method = typeof methods[number];
13
-
14
- const formats = ["delta", "full"] as ["delta", "full"];
15
- export type Format = typeof formats[number];
16
-
17
- const policies = ["instant", "ideal", "fixed"] as ["instant", "ideal", "fixed"];
18
- export type Policy = typeof policies[number];
19
-
20
- /**
21
- * Not used
22
- */
23
- export interface IUpdateMessage {
24
- source: {
25
- label: string;
26
- type: string;
27
- pgn?: string;
28
- src?: string;
29
- talker?: string;
30
- };
31
- timestamp: string;
32
- values: {
33
- path: string;
34
- value: any;
35
- }[]
36
- }
37
-
38
- /**
39
- * SignalK Delta low level raw message interface.
40
- */
41
- export interface IDeltaMessage {
42
- updates?: IUpdateMessage[];
43
- requestId?: string;
44
- state?: string;
45
- statusCode?: number;
46
- context: string;
47
- self?: string;
48
- version?: string;
49
- message?: string;
50
- accessRequest?: {
51
- permission?: string;
52
- token?: string
53
- }
54
- }
55
-
56
- /**
57
- * Kip SignalK path Objects interface. This object is used to contain all server received data
58
- */
59
- export interface IPathObject {
60
- path: string;
61
- defaultSource: string; // default source
62
- sources: {
63
- [sourceName: string]: { // per source data
64
- timestamp: number;
65
- value: any;
66
- }
67
- }
68
- meta?: ISignalKMetadata;
69
- type: string;
70
- state: ZoneState;
71
- }
72
-
73
- /**
74
- * SignalK Metadata Object interface. Follow URL for full SignalK specification
75
- * and description of fields:
76
- * @url https://signalk.org/specification/1.4.0/doc/data_model_metadata.html
77
- */
78
- export interface ISignalKMetadata {
79
- // normal state value
80
- description: string; //SK base required value
81
- units: string; //SK base required value
82
- displayName?: string;
83
- longName?: string;
84
- shortName?: string;
85
- state?: State;
86
- timeout?: number;
87
- method?: Method[];
88
- displayScale?: { //This object provides information regarding the recommended type and extent of the scale used for displaying values.
89
- lower?: number;
90
- upper?: number;
91
- type?: Type;
92
- }
93
- // elevated state value
94
- alertMethod?: Method[];
95
- warnMethod?: Method[];
96
- alarmMethod?: Method[];
97
- emergencyMethod?: Method[];
98
- zones?: { //This provides a series of hints to the consumer which can be used to properly set a range on a display gauge and also color sectors of a gauge to indicate normal or dangerous operating conditions.
99
- state: string;
100
- lower?: number;
101
- upper?: number;
102
- message?: string;
103
- }[]
104
- }
105
-
106
- /**
107
- * Interface for Metadata by Paths
108
- */
109
- export interface IPathAndMetaObjects {
110
- path: string;
111
- meta?: ISignalKMetadata;
112
- }
113
-
114
- /**
115
- * SignalK Notification Object interface. Follow URL for full SignalK specification
116
- * and description of fields:
117
- * @url https://signalk.org/specification/1.4.0/doc/notifications.html
118
- */
119
- export interface ISignalKNotification {
120
- method: Method[],
121
- state: State,
122
- message: string
123
- timestamp: string,
124
- }
125
-
126
- export interface IPathInfo {
127
- path: string;
128
-
129
- }
@@ -1,12 +0,0 @@
1
- import { TestBed } from '@angular/core/testing';
2
-
3
- import { SignalkRequestsService } from './signalk-requests.service';
4
-
5
- describe('SignalkRequestsService', () => {
6
- beforeEach(() => TestBed.configureTestingModule({}));
7
-
8
- it('should be created', () => {
9
- const service: SignalkRequestsService = TestBed.get(SignalkRequestsService);
10
- expect(service).toBeTruthy();
11
- });
12
- });
@@ -1,180 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Subscription , Observable , Subject } from 'rxjs';
3
-
4
- import { AppSettingsService } from './app-settings.service';
5
- import { SignalKConnectionService } from './signalk-connection.service';
6
- import { IDeltaMessage } from './signalk-interfaces';
7
- import { SignalKDeltaService } from './signalk-delta.service';
8
- import { NotificationsService } from './notifications.service';
9
-
10
- const deltaStatusCodes = {
11
- 200: "The request was successfully.",
12
- 202: "The request is awaiting authorization.",
13
- 400: "Bad Client request format.",
14
- 401: "The request has not been applied because it lacks valid authentication credentials.",
15
- 403: "You must be authenticated to send command. Request a Client Authorization Token from Kip configuration. The request must be approved by a SignalK admin in Security > Access Requests.",
16
- 405: "The server does not support the request.",
17
- 500: "The request failed.",
18
- 502: "Something went wrong carrying out the request on the server side.",
19
- 504: "Timeout on the server side trying to carry out the request."
20
- }
21
- export interface skRequest {
22
- requestId: string;
23
- state: string;
24
- statusCode: number;
25
- statusCodeDescription?: string;
26
- widgetUUID?: string;
27
- message?: string;
28
- }
29
-
30
- @Injectable({
31
- providedIn: 'root'
32
- })
33
- export class SignalkRequestsService {
34
-
35
- private requestStatus = new Subject<skRequest>(); // public Observable passing message post processing
36
- private requests: skRequest[] = []; // Private array of all requests.
37
-
38
- constructor(
39
- private SignalKConnectionService: SignalKConnectionService,
40
- private SignalKDeltaService: SignalKDeltaService,
41
- private AppSettingsService: AppSettingsService,
42
- private NotificationsService: NotificationsService,
43
- ) {
44
- let requestsSub: Subscription; // used to get all the requests from signalk-delta while avoiding circular dependencies in services...
45
-
46
- requestsSub = this.SignalKDeltaService.subscribeRequest().subscribe(
47
- requestMessage => { this.updateRequest(requestMessage); }
48
- );
49
-
50
- let endPointStatus: Subscription; // Monitor if Endpoints are reset and clean up
51
- endPointStatus = this.SignalKConnectionService.getSignalKConnectionsStatus().subscribe(
52
- signalKConnections => {
53
- if (!signalKConnections.rest.status) {
54
- this.requests = []; // flush array to clean values that will become stale post error or server reconnect
55
- }
56
- }
57
- );
58
- }
59
-
60
- /**
61
- * Submit a SignalK server Read/Write authorization request - only required if you need to
62
- * submit data to SignalK.
63
- *
64
- * Once approved, an authorization Token will be sent and automatically saved in the Kip
65
- * Config. The authorization is a manual process done on the
66
- * server.
67
- */
68
- public requestAuth() {
69
- let requestId = this.newUuid();
70
- let accessRequest = {
71
- requestId: requestId,
72
- accessRequest: {
73
- clientId: this.AppSettingsService.getKipUUID(),
74
- description: "Kip web app",
75
- permissions: "admin"
76
- }
77
- }
78
-
79
- this.SignalKConnectionService.publishDelta(JSON.stringify(accessRequest));
80
- let request = {
81
- requestId: requestId,
82
- state: null,
83
- statusCode: null
84
- }
85
- this.requests.push(request);
86
- }
87
-
88
- /**
89
- * Sends request to SignalK server and returns requestId.
90
- * @param path SignalK full path. Automatically removes "self" if included in path.
91
- * @param value Value to be sent.
92
- * @param widgetUUID Optional - Subscriber's Widget UUID to be included as part of
93
- * the subscribeRequest Subject response. Enables Widget specific filtering.
94
- * @return requestId Identifier for this specific request. Enables Request specific filtering.
95
- */
96
- public putRequest(path: string, value: any, widgetUUID: string): string {
97
- let requestId = this.newUuid();
98
- let noSelfPath = path.replace(/^(self\.)/,""); //no self in path...
99
- let selfContext: string = "vessels.self"; // hard coded context. Could be dynamic at some point
100
- let message = {
101
- "context": selfContext,
102
- "requestId": requestId,
103
- "put": {
104
- "path": noSelfPath,
105
- "value": value
106
- }
107
- }
108
- this.SignalKConnectionService.publishDelta(JSON.stringify(message)); //send request
109
-
110
- let request: skRequest = {
111
- requestId: requestId,
112
- state: null,
113
- statusCode: null,
114
- widgetUUID: widgetUUID,
115
- };
116
-
117
- this.requests.push(request); // save to private array pending response with widgetUUID so we can filter response from subscriber
118
- return requestId; // return the ID to the Subscriber, if tracking of individual request is required
119
- }
120
-
121
- /**
122
- * Handles request updates, issue display and logging.
123
- *
124
- * @param delta SignalK Delta message
125
- */
126
- private updateRequest(delta: IDeltaMessage) {
127
- let index = this.requests.findIndex(r => r.requestId == delta.requestId);
128
- if (index > -1) { // exists in local array
129
- this.requests[index].state = delta.state;
130
- this.requests[index].statusCode = delta.statusCode;
131
- this.requests[index].message = delta.message;
132
-
133
- const currentStatusCode = deltaStatusCodes[delta.statusCode];
134
-
135
- if ((typeof currentStatusCode != 'undefined') && (this.requests[index].statusCode == 200 || this.requests[index].statusCode == 202)) {
136
- this.requests[index].statusCodeDescription = currentStatusCode;
137
-
138
- if (this.requests[index].statusCode == 202) {
139
- this.NotificationsService.sendSnackbarNotification(this.requests[index].statusCodeDescription);
140
- return;
141
- }
142
- if ((delta.accessRequest !== undefined) && (delta.accessRequest.token !== undefined)) {
143
- this.AppSettingsService.setSignalKToken({token: delta.accessRequest.token, new: true});
144
- this.NotificationsService.sendSnackbarNotification(delta.accessRequest.permission + ": Read/Write Token request response received from server.");
145
- console.log(delta.accessRequest.permission + ": New R/W token response received");
146
- }
147
- } else {
148
- this.NotificationsService.sendSnackbarNotification("Request Error received: " + this.requests[index].statusCode + " - " + deltaStatusCodes[this.requests[index].statusCode] + " - " + this.requests[index].message);
149
- console.log("Request Error received: " + this.requests[index].statusCode + " - " + deltaStatusCodes[this.requests[index].statusCode] + " - " + this.requests[index].message);
150
- }
151
- try {
152
- this.requestStatus.next(this.requests[index]); // Broadcast results
153
- this.requests.splice(index, 1); // result dispatched, cleanup array
154
- } catch (err) {
155
- this.requestStatus.error(err);
156
- console.log(err);
157
- this.requests = []; // flush array to clean values that will become stale post error
158
- }
159
- } else {
160
- this.NotificationsService.sendSnackbarNotification("Received unknown Request delta:\n" + JSON.stringify(delta));
161
- console.log("Received unknown Request delta:\n" + JSON.stringify(delta))
162
- }
163
- }
164
-
165
- /**
166
- * Subscribe to SignalK request response. This allows you to inspect server response information such as State, Status Codes and such for further processing logic. Subscription object should be used for the Return :)
167
- *
168
- * @return Observable if type skRequest.
169
- */
170
- public subscribeRequest(): Observable<skRequest> {
171
- return this.requestStatus.asObservable();
172
- }
173
-
174
- private newUuid() {
175
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
176
- var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
177
- return v.toString(16);
178
- });
179
- }
180
- }
@@ -1,15 +0,0 @@
1
- import { TestBed, inject } from '@angular/core/testing';
2
-
3
- import { SignalkService } from './signalk.service';
4
-
5
- describe('SignalkService', () => {
6
- beforeEach(() => {
7
- TestBed.configureTestingModule({
8
- providers: [SignalkService]
9
- });
10
- });
11
-
12
- it('should be created', inject([SignalkService], (service: SignalkService) => {
13
- expect(service).toBeTruthy();
14
- }));
15
- });