@7365admin1/layer-common 4.121.0 → 4.122.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.122.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0a37446: Lift queue: each lift card shows its real lift gateway (Connected / Offline / lift not answering, floor and door once decoded, raw readings), and Seven365 Super Admin can create a gateway code (shown once), make a new one, or disconnect. At a HERO Fleet Core site the gateway is read from the saved map's lift of the same name.
8
+
9
+ ### Patch Changes
10
+
11
+ - 5df1cfd: A Security Ops client meeting notification is now clickable on the web. `client-meeting` joins `SITE_PAGES` and opens the site's Ops Review page, where the meetings are listed. Without the entry `notificationTarget` answered null for the kind and the row opened nothing at all, the same dead end the `security-ops` entry fixed for action alerts. Its own kind rather than `security-ops`, because the phone opens the meeting record itself while the web has no per-meeting page.
12
+
3
13
  ## 4.121.0
4
14
 
5
15
  ### Minor Changes
@@ -3218,11 +3228,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3218
3228
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3219
3229
  own rule from two endpoints the console already calls, unprojected:
3220
3230
 
3221
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3222
- GET /api/roles/id/:role that membership's role document
3231
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
3232
+ GET /api/roles/id/:role that membership's role document
3223
3233
 
3224
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3225
- staff = member.type === "admin" && role.type === "admin"
3234
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
3235
+ staff = member.type === "admin" && role.type === "admin"
3226
3236
 
3227
3237
  `role.default` is the marker because it is the only property of a platform
3228
3238
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -1264,6 +1264,15 @@ div.hero-editor__wp.hero-editor__sel, div.hero-editor__fid.hero-editor__sel { ou
1264
1264
  .hero .hero-lift-row__release { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--hero-accent); cursor: pointer; white-space: nowrap; }
1265
1265
  .hero-lift__ask { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
1266
1266
  .hero-lift__simnote { font-size: 12px; }
1267
+ .hero-lift__gw { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 0 0 10px; font-size: 13px; min-width: 0; }
1268
+ .hero-lift__gwread { font-weight: 700; }
1269
+ .hero-lift__gwhelp { font-size: 12px; flex-basis: 100%; }
1270
+ .hero-lift__gwraw { flex-basis: 100%; font-size: 12px; }
1271
+ .hero-lift__gwraw summary { cursor: pointer; opacity: 0.7; }
1272
+ .hero-lift__gwreg { display: inline-block; margin: 4px 12px 0 0; font-family: monospace; }
1273
+ .hero-lift__gwact { margin-left: auto; display: flex; gap: 6px; }
1274
+ .hero-lift__gwcode { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; border: 1px solid rgb(var(--v-theme-warning)); }
1275
+ .hero-lift__gwcode code { font-family: monospace; word-break: break-all; user-select: all; }
1267
1276
  @media (max-width: 600px) {
1268
1277
  .hero-lift { grid-template-columns: 1fr; }
1269
1278
  .hero-bmap__bar { right: 14px; }
@@ -37,6 +37,33 @@
37
37
  <span class="hero-lift__car"><span class="hero-lift__cardot" :class="[`hero-lift__cardot--${l.carTone}`, { 'hero-lift__cardot--blink': l.riding }]" aria-hidden="true" />{{ l.carText }}</span>
38
38
  </div>
39
39
 
40
+ <!-- The real lift's read-only gateway link (Inovance B0S over RS-485): status, readings, setup. -->
41
+ <div v-if="l.gateway || (canEditMap && setupMapId)" class="hero-lift__gw" :data-status="l.gateway?.status ?? 'none'">
42
+ <template v-if="l.gateway">
43
+ <span class="hero-chip" :class="`hero-tone--${l.gateway.tone}`" role="status">{{ l.gateway.text }}</span>
44
+ <span v-if="l.gateway.decoded" class="hero-lift__gwread">{{ l.gateway.decoded }}</span>
45
+ <span v-else-if="l.gateway.undecoded" class="hero-muted hero-lift__gwread">Real lift answering · floor/door not decoded yet (fill [decode] in the gateway settings)</span>
46
+ <span v-if="l.gateway.help" class="hero-muted hero-lift__gwhelp">{{ l.gateway.help }}</span>
47
+ <details v-if="l.gateway.registers.length" class="hero-lift__gwraw">
48
+ <summary>Raw readings ({{ l.gateway.registers.length }})</summary>
49
+ <span v-for="r in l.gateway.registers" :key="r.reg" class="hero-lift__gwreg">{{ r.reg }} = {{ r.value }}</span>
50
+ </details>
51
+ </template>
52
+ <span v-else class="hero-muted">No real lift connected · the car below is simulated.</span>
53
+ <span v-if="canEditMap && setupMapId" class="hero-lift__gwact">
54
+ <v-btn size="small" variant="outlined" :loading="busy === `gw:${l.name}`" @click="connectGateway(l.name, !!l.gateway)">
55
+ {{ l.gateway ? "New code" : "Connect gateway" }}
56
+ </v-btn>
57
+ <v-btn v-if="l.gateway" size="small" variant="text" :disabled="busy === `gw:${l.name}`" @click="disconnectGateway(l.name)">Disconnect</v-btn>
58
+ </span>
59
+ <div v-if="newCode?.lift === l.name" class="hero-lift__gwcode" role="alert">
60
+ <b>Gateway code (shown once):</b>
61
+ <code>{{ newCode.code }}</code>
62
+ <v-btn size="x-small" variant="tonal" @click="copyCode">Copy</v-btn>
63
+ <span class="hero-muted">Paste it as <code>code =</code> in the gateway's lift-gateway.ini, then start the gateway. This card turns Connected within seconds.</span>
64
+ </div>
65
+ </div>
66
+
40
67
  <div class="hero-lift__shaft" :style="{ height: `${l.shaftH}px` }" :title="l.simulated ? 'Simulated lift - no real lift is controlled yet' : undefined">
41
68
  <div class="hero-lift__labels">
42
69
  <div v-for="f in l.rails" :key="f.floorNo" class="hero-lift__floor" :class="{ 'hero-lift__floor--lit': f.lit }" :style="{ top: `${f.top}px` }">
@@ -139,13 +166,13 @@ const emit = defineEmits<{
139
166
  status: [status: { connected: boolean; faults: number; siteName: string; clientName: string }];
140
167
  }>();
141
168
 
142
- const { rows, all, map, fleet, names, loading: mapLoading, error: mapError } = useRobotBuilding(
169
+ const { rows, all, map, saved, fleet, names, loading: mapLoading, error: mapError } = useRobotBuilding(
143
170
  toRef(props, "organization"),
144
171
  toRef(props, "site"),
145
172
  toRef(props, "type"),
146
173
  );
147
174
  const kicker = computed(() => [props.clientName || names.value.clientName, props.siteName || names.value.siteName].filter(Boolean).join(" · "));
148
- const { getLiftQueue, requestLift, releaseLiftSession } = useRobots();
175
+ const { getLiftQueue, requestLift, releaseLiftSession, connectLiftGateway, disconnectLiftGateway } = useRobots();
149
176
 
150
177
  /* ---- the queue, every 3 s while the page is visible ---- */
151
178
  const items = ref<Array<Record<string, any>>>([]);
@@ -157,7 +184,16 @@ const error = computed(() => mapError.value);
157
184
 
158
185
  async function poll() {
159
186
  // The fleet building has no lift sessions of ours: its lifts come live with the building (5 s refresh).
160
- if (fleet.value) return void (items.value = fleetLiftItems(map.value, all.value), (queueLoading.value = false));
187
+ if (fleet.value) {
188
+ // The fleet building's lifts, plus each real lift's gateway from the saved map (same lift name).
189
+ const list = fleetLiftItems(map.value, all.value);
190
+ const gw = saved.value?._id ? await getLiftQueue(String(saved.value._id)).catch(() => null) : null;
191
+ const byName = new Map<string, any>((gw?.items ?? []).map((x: any) => [String(x.liftName), x.gateway ?? null]));
192
+ items.value = list.map((x: Record<string, any>) => ({ ...x, gateway: byName.get(String(x.liftName)) ?? null }));
193
+ queueLoading.value = false;
194
+ now.value = Date.now();
195
+ return;
196
+ }
161
197
  const id = map.value?._id;
162
198
  if (!id) return void (items.value = []);
163
199
  if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
@@ -217,6 +253,52 @@ watch(cards, (list) => {
217
253
  });
218
254
  const busy = ref("");
219
255
  const toast = ref("");
256
+ /*
257
+ * ---- the real lift's gateway (Seven365 Super Admin = canEditMap) ----
258
+ * Set up on the SAVED map's lift (at a fleet site, the imported Fleet Core building);
259
+ * the server re-checks Super Admin and stores only the code's sha256.
260
+ */
261
+ const setupMapId = computed(() => String((fleet.value ? saved.value?._id : map.value?._id) ?? ""));
262
+ const newCode = ref<{ lift: string; code: string } | null>(null);
263
+ async function connectGateway(lift: string, replacing: boolean) {
264
+ if (replacing && typeof window !== "undefined" && !window.confirm(`Make a new code for ${lift}? The gateway's current code stops working until you paste the new one.`)) return;
265
+ busy.value = `gw:${lift}`;
266
+ try {
267
+ const res = await connectLiftGateway(setupMapId.value, lift);
268
+ newCode.value = { lift, code: res.code };
269
+ await poll();
270
+ } catch (e) {
271
+ toast.value = robotErrorMessage(
272
+ e,
273
+ fleet.value ? "Could not create the code. Import the HERO Fleet Core building on Building map → Edit map first, so this lift is on the saved map." : "Could not create the gateway code.",
274
+ );
275
+ } finally {
276
+ busy.value = "";
277
+ }
278
+ }
279
+ async function disconnectGateway(lift: string) {
280
+ if (typeof window !== "undefined" && !window.confirm(`Disconnect the gateway from ${lift}? Its code stops working.`)) return;
281
+ busy.value = `gw:${lift}`;
282
+ try {
283
+ await disconnectLiftGateway(setupMapId.value, lift);
284
+ if (newCode.value?.lift === lift) newCode.value = null;
285
+ toast.value = `Gateway disconnected · ${lift}`;
286
+ await poll();
287
+ } catch (e) {
288
+ toast.value = robotErrorMessage(e, "The gateway could not be disconnected.");
289
+ } finally {
290
+ busy.value = "";
291
+ }
292
+ }
293
+ async function copyCode() {
294
+ try {
295
+ await navigator.clipboard.writeText(newCode.value?.code ?? "");
296
+ toast.value = "Code copied";
297
+ } catch {
298
+ toast.value = "Select the code and copy it by hand.";
299
+ }
300
+ }
301
+
220
302
  async function ask(l: { name: string }) {
221
303
  const robotId = askRobot.value[l.name];
222
304
  if (!robotId || !map.value?._id) return;
@@ -559,6 +559,25 @@ export default function useRobots() {
559
559
  );
560
560
  }
561
561
 
562
+ /**
563
+ * A real lift's gateway code (Seven365 Super Admin): a new `lgw_...` code,
564
+ * shown ONCE in the answer; asking again replaces it (the old one stops working).
565
+ */
566
+ function connectLiftGateway(mapId: string, liftName: string) {
567
+ return useNuxtApp().$api<{ code: string; codeHint: string }>(
568
+ `/api/robots/building-maps/${mapId}/lifts/${encodeURIComponent(liftName)}/gateway`,
569
+ { method: "POST" },
570
+ );
571
+ }
572
+
573
+ /** The gateway's code stops working; the card goes back to the simulated car. */
574
+ function disconnectLiftGateway(mapId: string, liftName: string) {
575
+ return useNuxtApp().$api<Record<string, any>>(
576
+ `/api/robots/building-maps/${mapId}/lifts/${encodeURIComponent(liftName)}/gateway`,
577
+ { method: "DELETE" },
578
+ );
579
+ }
580
+
562
581
  /** Give the lift back, or leave the queue. */
563
582
  function releaseLiftSession(sessionId: string) {
564
583
  return useNuxtApp().$api<Record<string, any>>(`/api/robots/lift-sessions/${sessionId}/release`, {
@@ -595,6 +614,8 @@ export default function useRobots() {
595
614
  getLiftQueue,
596
615
  requestLift,
597
616
  releaseLiftSession,
617
+ connectLiftGateway,
618
+ disconnectLiftGateway,
598
619
  getRobotLiftSession,
599
620
  getRobots,
600
621
  getSiteFleet,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.121.0",
5
+ "version": "4.122.0",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -214,6 +214,18 @@ const SITE_PAGES: Record<string, TSitePage[]> = {
214
214
  * opened nothing at all. Adding it repairs those too, not only the new alerts.
215
215
  */
216
216
  "security-ops": [{ apps: ["security"], page: () => "security-ops" }],
217
+ /**
218
+ * Security Ops: a client meeting was scheduled, moved or called off, or one
219
+ * is happening today.
220
+ *
221
+ * ITS OWN KIND, NOT `security-ops`, because the two land in different places:
222
+ * an action belongs to the register and a meeting belongs to the meeting
223
+ * record. The web has no per-meeting page, so this opens Ops Review, where
224
+ * the meetings tab lists them; the phone, which does have one, opens the
225
+ * meeting itself. Same kind, different answer per surface, which is what this
226
+ * table is for.
227
+ */
228
+ "client-meeting": [{ apps: ["security"], page: () => "security-ops" }],
217
229
  };
218
230
  SITE_PAGES.myVisitors = SITE_PAGES.visitors;
219
231
 
@@ -18,7 +18,7 @@ import {
18
18
  pushUndo,
19
19
  type TMapPointM,
20
20
  } from "./building-map";
21
- import { floorName } from "./robot-display";
21
+ import { agoText, floorName } from "./robot-display";
22
22
 
23
23
  /* ================================================================ camera */
24
24
 
@@ -1475,5 +1475,64 @@ export function liftCard(lift: Record<string, any>, now = Date.now()) {
1475
1475
  })),
1476
1476
  rows,
1477
1477
  simulated: lift?.simulated === true,
1478
+ gateway: liftGatewayLine(lift?.gateway ?? null),
1479
+ };
1480
+ }
1481
+
1482
+ const DOOR_TEXT = ["Doors closed", "Doors moving", "Doors open"];
1483
+ const MOTION_TEXT = ["Stopped", "Going up", "Going down", "Moving"];
1484
+ const MODE_TEXT = ["Mode unknown", "Normal", "Robot mode", "FIRE mode", "Out of service", "EMERGENCY"];
1485
+
1486
+ /**
1487
+ * The real lift's gateway (read-only link to the Inovance board), in words:
1488
+ * one status line, a tone, and the decoded floor/door/motion/mode once the
1489
+ * gateway's [decode] settings are filled in. `null` = no gateway: the car is simulated.
1490
+ */
1491
+ export function liftGatewayLine(g: Record<string, any> | null) {
1492
+ if (!g) return null;
1493
+ const ago = g.ageS == null ? "" : agoText(0, Number(g.ageS) * 1000);
1494
+ const byStatus: Record<string, { text: string; tone: string; help: string }> = {
1495
+ waiting: {
1496
+ text: `Waiting for the gateway (code …${g.codeHint ?? ""})`,
1497
+ tone: "neutral",
1498
+ help: "Put the code in the gateway's settings and start it. It turns Connected within seconds.",
1499
+ },
1500
+ connected: { text: `Connected · last reading ${ago}`, tone: "success", help: "" },
1501
+ "no-lift": {
1502
+ text: "Gateway online · lift not answering",
1503
+ tone: "warning",
1504
+ help: g.lastError || "Check the RS-485 wiring (A/B), baud, parity and unit address.",
1505
+ },
1506
+ offline: {
1507
+ text: `Offline · last heard ${ago}`,
1508
+ tone: "error",
1509
+ help: "Nothing from the gateway for 30 s: check its power, network, and that the program is running.",
1510
+ },
1511
+ };
1512
+ const line = byStatus[g.status] ?? byStatus.offline!;
1513
+ const st = g.status === "connected" ? g.state : null;
1514
+ const decoded = st
1515
+ ? [
1516
+ st.currentFloor ? `Floor ${st.currentFloor}` : "",
1517
+ st.doorState != null ? DOOR_TEXT[st.doorState] ?? "" : "",
1518
+ st.motionState != null ? MOTION_TEXT[st.motionState] ?? "" : "",
1519
+ st.currentMode != null ? MODE_TEXT[st.currentMode] ?? "" : "",
1520
+ ].filter(Boolean).join(" · ")
1521
+ : "";
1522
+ const registers = Object.entries((g.registers ?? {}) as Record<string, number>)
1523
+ .map(([reg, value]) => ({ reg, value }))
1524
+ .sort((a, b) => Number(a.reg) - Number(b.reg));
1525
+ return {
1526
+ ...line,
1527
+ status: String(g.status ?? "offline"),
1528
+ connected: g.status === "connected",
1529
+ decoded,
1530
+ // Until the Inovance register list is in the gateway's settings, only raw numbers exist.
1531
+ undecoded: g.status === "connected" && !decoded,
1532
+ registers,
1533
+ port: String(g.port ?? ""),
1534
+ version: String(g.gatewayVersion ?? ""),
1535
+ codeHint: String(g.codeHint ?? ""),
1536
+ readings: Number(g.readings ?? 0),
1478
1537
  };
1479
1538
  }