@signalk/freeboard-sk 2.14.2 → 2.15.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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/plugin/flags/flags-service.js +132 -0
- package/plugin/flags/mid.js +1745 -0
- package/public/{78.d4c5c5157ba92d44.js → 78.546e45312a719fb0.js} +1 -1
- package/public/assets/img/waypoints/pob.svg +84 -0
- package/public/assets/img/waypoints/pseudoaton.svg +92 -0
- package/public/assets/img/waypoints/start-boat.svg +58 -0
- package/public/assets/img/waypoints/start-pin.svg +51 -0
- package/public/assets/img/waypoints/whale.svg +81 -0
- package/public/index.html +2 -2
- package/public/main.b8fc66dbdf2d2371.js +1 -0
- package/public/{runtime.6237108b22a63408.js → runtime.b276ba35dd677d50.js} +1 -1
- package/public/{styles.ca697d30ce6fe074.css → styles.de5b92e4ed1bfa7b.css} +1 -1
- package/public/assets/img/finishflag.png +0 -0
- package/public/assets/img/ob/whale.svg +0 -4
- package/public/assets/img/startboat.png +0 -0
- package/public/assets/img/startflag.png +0 -0
- package/public/main.51f0a336e1edbb3e.js +0 -1
- /package/public/assets/img/waypoints/{marker-red.png → pseudoaton.png} +0 -0
- /package/public/assets/img/waypoints/{marker-yellow.png → waypoint.png} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGELOG: Freeboard
|
|
2
2
|
|
|
3
|
+
### v2.15.0
|
|
4
|
+
|
|
5
|
+
- **New**: Night mode which is auto-set using the value of `environment.mode`. _Note: Enable this in settings by checking **Auto-set Night Mode**._ (#239)
|
|
6
|
+
- **Updated**: Waypoint icons and types.
|
|
7
|
+
- **Fixed**: Temperature unit typo.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### v2.14.3
|
|
11
|
+
|
|
12
|
+
- **Fixed**: Only displaying on track on map when multiple selected. (#273)
|
|
13
|
+
- **Updated**: Vessel properties displays country flag _(requires `signalk-flags` plugin)_. (#253)
|
|
14
|
+
|
|
3
15
|
### v2.14.2
|
|
4
16
|
|
|
5
17
|
- **Update**: Hide More / Less buttoon when Alert does not have addittional properties (#272)
|
package/package.json
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initFlags = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const mid_1 = require("./mid");
|
|
7
|
+
let server;
|
|
8
|
+
let pluginId;
|
|
9
|
+
const FLAGS_API_PATH = '/signalk/v2/api/resources/flags';
|
|
10
|
+
let IMG_BASE_PATH = '';
|
|
11
|
+
const initFlags = (app, id) => {
|
|
12
|
+
server = app;
|
|
13
|
+
pluginId = id;
|
|
14
|
+
initFs();
|
|
15
|
+
initFlagsEndpoints();
|
|
16
|
+
};
|
|
17
|
+
exports.initFlags = initFlags;
|
|
18
|
+
// check path to flag resources
|
|
19
|
+
const initFs = async () => {
|
|
20
|
+
const p = __dirname.split('/');
|
|
21
|
+
const sp = p.slice(0, p.indexOf('plugin')).join('/');
|
|
22
|
+
IMG_BASE_PATH = `${sp}/node_modules/flag-icons/flags`;
|
|
23
|
+
try {
|
|
24
|
+
// check path exists
|
|
25
|
+
await (0, promises_1.access)(IMG_BASE_PATH, fs_1.constants.R_OK);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
server.setPluginError(`Flags path NOT found!`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const initFlagsEndpoints = () => {
|
|
32
|
+
server.debug(`** Registering Flag resources endpoint(s) **`);
|
|
33
|
+
server.get(`${FLAGS_API_PATH}`, async (req, res) => {
|
|
34
|
+
server.debug(`** ${req.method} ${req.path}`);
|
|
35
|
+
try {
|
|
36
|
+
const list = await listResponse();
|
|
37
|
+
res.status(200).json({
|
|
38
|
+
aspects: ['1x1', '4x3'],
|
|
39
|
+
flags: list
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
res.status(400).json({
|
|
44
|
+
state: 'FAILED',
|
|
45
|
+
statusCode: 400,
|
|
46
|
+
message: e.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
server.get(`${FLAGS_API_PATH}/mid/:mid`, (req, res) => {
|
|
51
|
+
server.debug(`** ${req.method} ${req.path}`);
|
|
52
|
+
iconByMid(req.params.mid, req.params.aspect, res);
|
|
53
|
+
});
|
|
54
|
+
server.get(`${FLAGS_API_PATH}/:aspect/:icon`, (req, res) => {
|
|
55
|
+
server.debug(`** ${req.method} ${req.path}`);
|
|
56
|
+
iconResponse(req.params.icon, req.params.aspect, res);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Build list of flag ids
|
|
61
|
+
* @param aspect Aspect ratio '1x1' or '4x3'
|
|
62
|
+
* @returns array of flag ids
|
|
63
|
+
*/
|
|
64
|
+
const listResponse = async (aspect = '1x1') => {
|
|
65
|
+
const entries = await (0, promises_1.readdir)(`${IMG_BASE_PATH}/${aspect}`, {
|
|
66
|
+
withFileTypes: true
|
|
67
|
+
});
|
|
68
|
+
return entries.map((entry) => {
|
|
69
|
+
if (entry.isFile()) {
|
|
70
|
+
return entry.name.split('.')[0];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Send file response for the specified flag id
|
|
76
|
+
* @param aspect Aspect ratio '1x1' or '4x3'
|
|
77
|
+
* @returns svg file contents
|
|
78
|
+
*/
|
|
79
|
+
const iconResponse = async (id, aspect = '1x1', res) => {
|
|
80
|
+
const flag = `${IMG_BASE_PATH}/${aspect}/${id}.svg`;
|
|
81
|
+
try {
|
|
82
|
+
// check path exists
|
|
83
|
+
await (0, promises_1.access)(flag, fs_1.constants.R_OK);
|
|
84
|
+
res.sendFile(flag, (err) => {
|
|
85
|
+
if (err) {
|
|
86
|
+
res.status(400).json({
|
|
87
|
+
state: 'FAILED',
|
|
88
|
+
statusCode: 400,
|
|
89
|
+
message: err.message
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
res.status(400).json({
|
|
96
|
+
state: 'FAILED',
|
|
97
|
+
statusCode: 400,
|
|
98
|
+
message: `Flag (${id}) NOT found!`
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Send file response for the supplied mid
|
|
105
|
+
* @param aspect Aspect ratio '1x1' or '4x3'
|
|
106
|
+
* @returns svg file contents
|
|
107
|
+
*/
|
|
108
|
+
const iconByMid = async (mid, aspect = '4x3', res) => {
|
|
109
|
+
const code = mid_1.MID[mid][0]?.toLowerCase();
|
|
110
|
+
const flag = `${IMG_BASE_PATH}/${aspect}/${code}.svg`;
|
|
111
|
+
try {
|
|
112
|
+
// check path exists
|
|
113
|
+
await (0, promises_1.access)(flag, fs_1.constants.R_OK);
|
|
114
|
+
res.sendFile(flag, (err) => {
|
|
115
|
+
if (err) {
|
|
116
|
+
res.status(400).json({
|
|
117
|
+
state: 'FAILED',
|
|
118
|
+
statusCode: 400,
|
|
119
|
+
message: err.message
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
res.status(400).json({
|
|
126
|
+
state: 'FAILED',
|
|
127
|
+
statusCode: 400,
|
|
128
|
+
message: `Flag (${mid}) NOT found!`
|
|
129
|
+
});
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
};
|