@7365admin1/layer-common 3.2.1 → 3.2.2
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
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 3.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d81dc2e: Camera-fault alerts get their own snackbar instead of riding the visitor one
|
|
8
|
+
|
|
9
|
+
Camera health was being sent through `showTransientMessage`, the same path as
|
|
10
|
+
unregistered-visitor plate alerts. That path returns early when the site has
|
|
11
|
+
the unregistered-visitor snackbar switched off, so **two of the five ANPR sites
|
|
12
|
+
were being told nothing at all when a camera went down** — the setting that
|
|
13
|
+
silenced them has nothing to do with cameras. The old snackbar was also hidden
|
|
14
|
+
whenever the operator was on the Unregistered tab.
|
|
15
|
+
|
|
16
|
+
Camera health is now its own alert, gated only on the permission to view
|
|
17
|
+
visitor data. It cannot be silenced by the unregistered-visitor switch and is
|
|
18
|
+
not hidden on that tab.
|
|
19
|
+
|
|
20
|
+
Several cameras failing at once collapse into a single line — "N cameras at
|
|
21
|
+
this site are not responding … Open Site Settings > Cameras to see which" —
|
|
22
|
+
rather than one snackbar per camera. Faults are keyed by camera id, so a repeat
|
|
23
|
+
for the same camera replaces its line instead of stacking another.
|
|
24
|
+
|
|
25
|
+
When a camera comes back, the operator who was told it was down is told it
|
|
26
|
+
recovered; the alert clears on its own.
|
|
27
|
+
|
|
28
|
+
Reads the optional `event` (`camera-fault` / `camera-recovered`) and `camera`
|
|
29
|
+
fields added to the socket payload in `@7365admin1/core`. Both are optional —
|
|
30
|
+
against an older API-core that sends a bare `message`, this behaves as it does
|
|
31
|
+
today and treats it as a fault.
|
|
32
|
+
|
|
33
|
+
**Expect an alert burst on first release** from the sites that were silent.
|
|
34
|
+
Warn the client before shipping.
|
|
35
|
+
|
|
3
36
|
## 3.2.1
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -66,6 +66,29 @@
|
|
|
66
66
|
</template>
|
|
67
67
|
</v-snackbar>
|
|
68
68
|
|
|
69
|
+
<!--
|
|
70
|
+
Camera health is its own alert, deliberately separate from the plate
|
|
71
|
+
snackbar above: it is not a visitor event, it must not be silenced by the
|
|
72
|
+
unregistered-visitor switch, and it must not be hidden on the unregistered
|
|
73
|
+
tab. Several failing cameras collapse into one line rather than one
|
|
74
|
+
snackbar each.
|
|
75
|
+
-->
|
|
76
|
+
<v-snackbar
|
|
77
|
+
v-if="canViewVisitor"
|
|
78
|
+
v-model="cameraAlert.modal"
|
|
79
|
+
:color="cameraFaults.size ? 'warning' : 'success'"
|
|
80
|
+
:timeout="10000"
|
|
81
|
+
location="top right"
|
|
82
|
+
class="rounded-xl"
|
|
83
|
+
multi-line
|
|
84
|
+
:z-index="100000000"
|
|
85
|
+
>
|
|
86
|
+
<span class="text-1-4rem">{{ cameraAlertText }}</span>
|
|
87
|
+
<template #actions>
|
|
88
|
+
<v-btn icon="mdi-close" variant="text" @click="cameraAlert.modal = false" />
|
|
89
|
+
</template>
|
|
90
|
+
</v-snackbar>
|
|
91
|
+
|
|
69
92
|
<v-dialog v-model="permanentMessageDialog.modal" max-width="480" persistent>
|
|
70
93
|
<v-card>
|
|
71
94
|
<v-card-title class="text-h6">Notice</v-card-title>
|
|
@@ -132,6 +155,36 @@ const permanentMessageDialog = reactive({
|
|
|
132
155
|
text: "",
|
|
133
156
|
});
|
|
134
157
|
|
|
158
|
+
// Outstanding camera faults for this site, keyed by camera id so a repeat for
|
|
159
|
+
// the same camera replaces its line instead of adding another.
|
|
160
|
+
const cameraFaults = reactive(new Map<string, string>());
|
|
161
|
+
const cameraRecovery = ref("");
|
|
162
|
+
const cameraAlert = reactive({ modal: false });
|
|
163
|
+
|
|
164
|
+
const cameraAlertText = computed(
|
|
165
|
+
() => cameraAlertMessage([...cameraFaults.values()]) || cameraRecovery.value
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const handleCameraHealth = (data: TVisitorSocketData) => {
|
|
169
|
+
// Older API-core builds send the fault text with no `event`, so a bare
|
|
170
|
+
// message is a fault.
|
|
171
|
+
if (data?.event === "camera-recovered") {
|
|
172
|
+
// Without a camera id there is no way to tell which fault cleared.
|
|
173
|
+
if (data?.camera) cameraFaults.delete(data.camera);
|
|
174
|
+
else cameraFaults.clear();
|
|
175
|
+
// Alerts are now infrequent, so the operator is told it came back —
|
|
176
|
+
// otherwise the only signal a camera recovered is silence.
|
|
177
|
+
cameraRecovery.value = cameraFaults.size ? "" : data?.message || "";
|
|
178
|
+
cameraAlert.modal = Boolean(cameraAlertText.value);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!data?.message) return;
|
|
183
|
+
cameraRecovery.value = "";
|
|
184
|
+
cameraFaults.set(data?.camera || data.message, data.message);
|
|
185
|
+
cameraAlert.modal = true;
|
|
186
|
+
};
|
|
187
|
+
|
|
135
188
|
watch(
|
|
136
189
|
() => props.siteId,
|
|
137
190
|
async (siteId) => {
|
|
@@ -233,8 +286,9 @@ const connectSocket = () => {
|
|
|
233
286
|
}
|
|
234
287
|
|
|
235
288
|
|
|
236
|
-
|
|
237
|
-
|
|
289
|
+
// Camera health, not a visitor event: its own alert, its own gate.
|
|
290
|
+
if (data?.message || data?.event) {
|
|
291
|
+
handleCameraHealth(data);
|
|
238
292
|
}
|
|
239
293
|
|
|
240
294
|
if (data?.messagePermanent) {
|
|
@@ -5,6 +5,32 @@ export type TVisitorSocketData = {
|
|
|
5
5
|
message?: string;
|
|
6
6
|
messagePermanent?: string;
|
|
7
7
|
reload?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Camera health. Sent alongside `message` by API-core so the client can group
|
|
10
|
+
* or clear an alert per camera instead of matching on the message text.
|
|
11
|
+
* Absent on older API-core builds — treat a bare `message` as a fault.
|
|
12
|
+
*/
|
|
13
|
+
event?: "camera-fault" | "camera-recovered";
|
|
14
|
+
/** The camera the `event` is about. */
|
|
15
|
+
camera?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* One line for however many cameras are currently down.
|
|
20
|
+
*
|
|
21
|
+
* A site with several ANPR cameras could otherwise raise one alert per camera
|
|
22
|
+
* at the same moment. The single-camera case shows the server's own message,
|
|
23
|
+
* which names the camera; beyond that, naming them all in a snackbar is worse
|
|
24
|
+
* than sending the operator to the page that lists them.
|
|
25
|
+
*/
|
|
26
|
+
export const cameraAlertMessage = (messages: string[]): string => {
|
|
27
|
+
if (!messages.length) return "";
|
|
28
|
+
if (messages.length === 1) return messages[0] as string;
|
|
29
|
+
return (
|
|
30
|
+
`${messages.length} cameras at this site are not responding. Plate reads ` +
|
|
31
|
+
`and automatic barrier opening are stopped for them. Open Site Settings > ` +
|
|
32
|
+
`Cameras to see which.`
|
|
33
|
+
);
|
|
8
34
|
};
|
|
9
35
|
|
|
10
36
|
export const useVisitorSocket = () => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.2",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"publishConfig": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"build": "nuxt build .playground",
|
|
15
15
|
"generate": "nuxt generate .playground",
|
|
16
16
|
"preview": "nuxt preview .playground",
|
|
17
|
+
"test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --test \"test/*.test.mjs\"",
|
|
17
18
|
"release": "yarn run build && changeset publish"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
|
|
4
|
+
import { cameraAlertMessage } from "./.build/useVisitorSocket.mjs";
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* The reported symptom was one camera raising a red toast every 10 seconds on
|
|
8
|
+
* an unrelated page. API-core now paces the alert; this side has to make sure
|
|
9
|
+
* several cameras failing at once still cannot become several snackbars.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
test("nothing is shown when no camera is down", () => {
|
|
13
|
+
assert.equal(cameraAlertMessage([]), "");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("one failing camera shows the server's own message, which names it", () => {
|
|
17
|
+
const text = "The entry and exit ANPR camera at Seventh Condominium is not responding.";
|
|
18
|
+
assert.equal(cameraAlertMessage([text]), text);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("several failing cameras collapse into a single line", () => {
|
|
22
|
+
const many = ["camera one is down", "camera two is down", "camera three is down"];
|
|
23
|
+
const text = cameraAlertMessage(many);
|
|
24
|
+
assert.match(text, /^3 cameras at this site are not responding/);
|
|
25
|
+
for (const message of many) assert.doesNotMatch(text, new RegExp(message));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("the collapsed line points at the page that lists them", () => {
|
|
29
|
+
assert.match(cameraAlertMessage(["a", "b"]), /Site Settings > Cameras/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("no camera message tells the operator to deactivate anything", () => {
|
|
33
|
+
for (const messages of [["a camera is down"], ["a", "b"]]) {
|
|
34
|
+
assert.doesNotMatch(cameraAlertMessage(messages), /inactive|deactivat/i);
|
|
35
|
+
}
|
|
36
|
+
});
|