@7365admin1/layer-common 4.28.1-staging.361 → 4.28.1-staging.362

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.
@@ -0,0 +1,445 @@
1
+ <template>
2
+ <!-- Robot detail (README §3). -->
3
+ <div>
4
+ <button type="button" class="hero-back hero-back--sm" @click="emit('back')">‹ {{ backLabel || `${record?.site?.name || "Site"} fleet` }}</button>
5
+ <div class="hero-detail__title">
6
+ <h2>{{ record?.name ?? "Robot" }}</h2>
7
+ <template v-if="statusMode">
8
+ <RobotStatusChip :mode="statusMode" :type="robotType" />
9
+ </template>
10
+ <span v-else-if="live && !live.ok" class="hero-tag hero-tag--neutral">Reconnecting</span>
11
+ <span v-if="caps" class="hero-tag hero-tag--neutral">{{ capabilityLabel(caps) }}</span>
12
+ <span class="hero-tag hero-tag--neutral">{{ typeLabel(robotType) }}</span>
13
+ <span v-if="record" class="hero-detail__where">{{ record.client?.name }} · {{ record.site?.name }}</span>
14
+ <span class="hero-head__spacer" />
15
+ <template v-if="record">
16
+ <v-btn v-if="canEdit" variant="outlined" @click="editOpen = true">Edit</v-btn>
17
+ <v-btn v-if="canDelete" variant="text" class="hero-ghost" @click="removeOpen = true">Remove</v-btn>
18
+ </template>
19
+ </div>
20
+ </div>
21
+
22
+ <div v-if="error" class="hero-notice" role="alert">{{ error }}</div>
23
+
24
+ <div v-if="fault" class="hero-faultbar" role="alert">
25
+ <span class="hero-faultbar__code">{{ fault.code }}</span>
26
+ <div>
27
+ <div class="hero-faultbar__msg">{{ fault.message || fault.code }}</div>
28
+ <div class="hero-faultbar__since">Since {{ faultSince }} · notified once</div>
29
+ </div>
30
+ <span class="hero-faultbar__badge">FAULT</span>
31
+ </div>
32
+
33
+ <RobotNoMonitoring v-if="noInterface" :brand-name="brand" :model="live?.model || undefined" />
34
+
35
+ <div class="hero-facts" role="list" aria-label="Robot facts">
36
+ <div v-for="f in facts" :key="f.label" class="hero-fact" role="listitem">
37
+ <div class="hero-fact__label">{{ f.label }}</div>
38
+ <div class="hero-fact__value" :class="{ 'hero-fact__value--dim': f.dim }">{{ f.value }}</div>
39
+ </div>
40
+ </div>
41
+ <div v-if="notReported" class="hero-notreported">{{ notReported }}</div>
42
+
43
+ <div v-if="commands.length">
44
+ <div class="hero-section__title">Command bar</div>
45
+ <RobotCommandBar
46
+ :capabilities="caps"
47
+ :can-command="canCommand"
48
+ :online="live?.ok === true && live.online === true"
49
+ :mode="statusMode"
50
+ :type="robotType"
51
+ :busy="busy"
52
+ @command="send"
53
+ />
54
+ </div>
55
+ <RobotViewOnlyNotice v-if="!canCommand && !noInterface" />
56
+
57
+ <div class="hero-detail__grid">
58
+ <div>
59
+ <div class="hero-aside__head">
60
+ <span class="hero-aside__title">{{ robotType === "security" ? "Patrol schedule" : "Cleaning schedule" }}</span>
61
+ <span class="hero-aside__hint">{{
62
+ robotType === "security" ? "days · start–end · floor · checkpoints × rounds" : "days · start–end · jobs per floor · passes"
63
+ }}</span>
64
+ </div>
65
+ <div v-if="!schedule.length" class="hero-sched__empty">No schedule yet.</div>
66
+ <div v-for="p in schedule" :key="p.key" class="hero-sched__row">
67
+ <b>{{ p.days }}</b><span>{{ p.time }}</span><span>{{ p.jobs }}</span>
68
+ </div>
69
+ </div>
70
+
71
+ <div>
72
+ <div class="hero-aside__head">
73
+ <span class="hero-aside__title">{{ planTitle }}</span>
74
+ <span class="hero-aside__hint" style="flex-shrink: 0">{{ planHint }}</span>
75
+ </div>
76
+ <RobotLivePlan
77
+ :name="record?.name"
78
+ :status-label="statusLabel"
79
+ :point="posLive ? point : null"
80
+ :heading="headingDeg(shown)"
81
+ :trail="trail"
82
+ :readout="readout"
83
+ :lost="posLost"
84
+ :route="route"
85
+ :route-moving="statusMode === 'WORKING'"
86
+ :spot="spot"
87
+ :pick="spotOn"
88
+ :tick-ms="tickMs"
89
+ @pick="(p) => spot.push(p)"
90
+ />
91
+ <div v-if="spotOn" class="hero-spotbar">
92
+ <v-btn color="primary" variant="flat" :disabled="!spot.length || busy === 'spot'" :loading="busy === 'spot'" @click="sendSpot">
93
+ Send spot clean · {{ spot.length }} points
94
+ </v-btn>
95
+ <v-btn variant="outlined" @click="spot = []">Clear</v-btn>
96
+ </div>
97
+ </div>
98
+ </div>
99
+
100
+ <v-dialog v-model="editOpen" width="460" persistent>
101
+ <RobotForm
102
+ v-if="editOpen && record"
103
+ :key="record._id"
104
+ :organization="String(record.client?._id ?? '')"
105
+ :site="String(record.site?._id ?? '')"
106
+ :type="robotType"
107
+ :robot="record"
108
+ @cancel="editOpen = false"
109
+ @saved="onSaved"
110
+ />
111
+ </v-dialog>
112
+
113
+ <v-dialog v-model="removeOpen" width="520">
114
+ <div class="hero-dialog" role="alertdialog" aria-labelledby="hero-remove-title">
115
+ <div id="hero-remove-title" class="hero-dialog__title">Remove {{ record?.name }}?</div>
116
+ <div class="hero-dialog__body">
117
+ It stops appearing here and can no longer be monitored or commanded. To use it again, add it back with its app key and token.
118
+ </div>
119
+ <div class="hero-dialog__actions">
120
+ <v-btn variant="outlined" :disabled="removing" @click="removeOpen = false">Keep robot</v-btn>
121
+ <v-btn color="primary" variant="flat" :loading="removing" @click="confirmRemove">Remove robot</v-btn>
122
+ </div>
123
+ </div>
124
+ </v-dialog>
125
+
126
+ <RobotToast v-model="toast" />
127
+ </template>
128
+
129
+ <script setup lang="ts">
130
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
131
+ import RobotStatusChip from "./StatusChip.vue";
132
+ import RobotNoMonitoring from "./NoMonitoring.vue";
133
+ import RobotCommandBar from "./CommandBar.vue";
134
+ import RobotViewOnlyNotice from "./ViewOnlyNotice.vue";
135
+ import RobotLivePlan from "./LivePlan.vue";
136
+ import RobotToast from "./Toast.vue";
137
+ import RobotForm from "./Form.vue";
138
+ import useRobotLive, { siteStatesFeed } from "../../composables/useRobotLive";
139
+ import {
140
+ brandName,
141
+ capabilityLabel,
142
+ cleaningScheduleRows,
143
+ commandBody,
144
+ commandLabel,
145
+ headingDeg,
146
+ isMoving,
147
+ mergePose,
148
+ notReportedLine,
149
+ optimisticMode,
150
+ patrolScheduleRows,
151
+ planPoint,
152
+ positionText,
153
+ robotErrorMessage,
154
+ robotFacts,
155
+ robotStatus,
156
+ showSpotClean,
157
+ sinceText,
158
+ speedText,
159
+ spotPixels,
160
+ trailPush,
161
+ typeLabel,
162
+ visibleCommands,
163
+ type TLiveRobotState,
164
+ type TPatrolRouteView,
165
+ type TRobotCommandKind,
166
+ } from "../../utils/robot-display";
167
+
168
+ const props = withDefaults(
169
+ defineProps<{
170
+ robotId: string;
171
+ /** "‹ {site} fleet". */
172
+ backLabel?: string;
173
+ /** Rename / set the serial (the API gates it as update-robot). */
174
+ canEdit?: boolean;
175
+ canCommand?: boolean;
176
+ canDelete?: boolean;
177
+ tickMs?: number;
178
+ }>(),
179
+ { backLabel: "", canEdit: false, canCommand: false, canDelete: false, tickMs: 1200 },
180
+ );
181
+ const emit = defineEmits<{
182
+ back: [];
183
+ removed: [name: string];
184
+ saved: [];
185
+ status: [status: { connected: boolean }];
186
+ }>();
187
+
188
+ const { getRobot, getRobotBrands, getRobotPlans, getPatrolRoutes, sendRobotCommand, trackRobot, deleteRobot, getRobotMaps, getRobotMapImages } =
189
+ useRobots();
190
+
191
+ const record = ref<Record<string, any> | null>(null);
192
+ const brands = ref<Array<Record<string, any>>>([]);
193
+ const error = ref("");
194
+ const toast = ref("");
195
+ const editOpen = ref(false);
196
+ const removeOpen = ref(false);
197
+ const removing = ref(false);
198
+ const now = ref(Date.now());
199
+
200
+ const robotType = computed<"cleaning" | "security">(() => (record.value?.type === "security" ? "security" : "cleaning"));
201
+ const brand = computed(() => brandName(record.value?.brand, brands.value));
202
+
203
+ /* ---- live: the 4 s poll (swappable feed) + the per-robot position stream ---- */
204
+ const ids = computed(() => (props.robotId ? [props.robotId] : []));
205
+ const { states, connected, lastAt } = useRobotLive(ids, siteStatesFeed());
206
+ const polled = computed<TLiveRobotState | null>(() => states.value[props.robotId] ?? null);
207
+
208
+ const lastPose = ref<{ event: any; at: number } | null>(null);
209
+ const prevPose = ref<{ x: number; y: number; at: number } | null>(null);
210
+ const nextPose = ref<{ x: number; y: number; at: number } | null>(null);
211
+ const streamLost = ref(false);
212
+ let stream: { stop: () => void } | null = null;
213
+
214
+ /** The robot as shown: the poll, moved by a newer stream pose, with the command's optimistic status. */
215
+ const optimistic = ref<{ mode: string; after: number } | null>(null);
216
+ const live = computed<TLiveRobotState | null>(() => {
217
+ let s = polled.value;
218
+ if (s?.ok && lastPose.value && lastPose.value.at > (lastAt.value?.getTime() ?? 0)) s = mergePose(s, lastPose.value.event);
219
+ if (s?.ok && optimistic.value) s = { ...s, mode: optimistic.value.mode };
220
+ return s;
221
+ });
222
+ const shown = computed(() => live.value);
223
+ watch(lastAt, (at) => {
224
+ // The first reading made after the command settled replaces the optimistic status.
225
+ if (optimistic.value && at && at.getTime() > optimistic.value.after) optimistic.value = null;
226
+ });
227
+
228
+ const noInterface = computed(() => live.value?.monitorable === false);
229
+ const caps = computed<Record<string, unknown> | null>(() => (noInterface.value ? {} : live.value?.ok ? live.value.capabilities ?? {} : null));
230
+ const statusMode = computed(() => {
231
+ const s = live.value;
232
+ if (!s) return null;
233
+ if (s.monitorable === false) return "UNKNOWN";
234
+ if (!s.ok) return null;
235
+ return s.online === false ? "UNAVAILABLE" : s.mode ?? "UNKNOWN";
236
+ });
237
+ const statusLabel = computed(() => robotStatus(statusMode.value, robotType.value).label);
238
+
239
+ const fault = computed(() => (live.value?.ok ? live.value.fault ?? null : record.value?.fault ?? null));
240
+ const faultSince = computed(() => sinceText(fault.value?.since, now.value));
241
+
242
+ const facts = computed(() => robotFacts({ record: record.value, live: live.value as any, now: now.value }));
243
+ const notReported = computed(() => (caps.value ? notReportedLine(brand.value, caps.value, robotType.value) : null));
244
+
245
+ const online = computed(() => live.value?.ok === true && live.value.online === true);
246
+ const commands = computed(() =>
247
+ visibleCommands({ capabilities: caps.value, canCommand: props.canCommand, online: online.value, mode: statusMode.value, type: robotType.value }),
248
+ );
249
+
250
+ /* ---- the plan ---- */
251
+ const reportsPosition = computed(() => caps.value?.readLocation === true);
252
+ const point = computed(() => planPoint(shown.value as any));
253
+ const posLive = computed(() => reportsPosition.value && online.value && !streamLost.value && !!point.value);
254
+ const posLost = computed(() => reportsPosition.value && !!live.value && (!live.value.ok || live.value.online === false || streamLost.value));
255
+ const trail = ref<Array<{ x: number; y: number }>>([]);
256
+ watch(
257
+ () => shown.value?.planPosition,
258
+ (p) => {
259
+ if (p && posLive.value && isMoving(statusMode.value)) trail.value = trailPush(trail.value, p);
260
+ },
261
+ );
262
+ const readout = computed(() => `${positionText(live.value, caps.value)} · ${speedText(prevPose.value, nextPose.value, statusMode.value)}`);
263
+
264
+ const spot = ref<Array<{ x: number; y: number }>>([]);
265
+ const spotOn = computed(() => showSpotClean({ canCommand: props.canCommand, capabilities: caps.value, online: online.value, type: robotType.value }));
266
+
267
+ const route = computed<TPatrolRouteView | null>(() => patrol.value?.routes?.[0] ?? null);
268
+ const floorText = computed(() => facts.value[2]?.value ?? "");
269
+ const planTitle = computed(() => (spotOn.value ? "Spot clean" : route.value ? `Live position · ${route.value.name}` : "Live position"));
270
+ const planHint = computed(() => {
271
+ if (spotOn.value) return "Click points on the plan, then send";
272
+ if (noInterface.value) return "No position feed for this model";
273
+ if (route.value) return `${route.value.checkpoints.length} checkpoints · ${floorText.value}`;
274
+ return floorText.value;
275
+ });
276
+
277
+ /* ---- schedule: cleaning plans from the brand, or the patrol contract ---- */
278
+ const plans = ref<Array<Record<string, any>>>([]);
279
+ const patrol = ref<{ supported?: boolean; routes?: TPatrolRouteView[]; schedule?: any[] } | null>(null);
280
+ const schedule = computed(() => (robotType.value === "security" ? patrolScheduleRows(patrol.value) : cleaningScheduleRows(plans.value)));
281
+
282
+ async function loadSchedule() {
283
+ if (!record.value || noInterface.value) return;
284
+ try {
285
+ if (robotType.value === "security") patrol.value = await getPatrolRoutes(props.robotId);
286
+ else plans.value = (await getRobotPlans(props.robotId))?.items ?? [];
287
+ } catch {
288
+ // A schedule the brand cannot serve reads "No schedule yet"; the facts still show.
289
+ }
290
+ }
291
+
292
+ /* ---- the position stream: only for a brand that reports one ---- */
293
+ function startStream() {
294
+ stream?.stop();
295
+ stream = null;
296
+ if (!reportsPosition.value || !online.value) return;
297
+ stream = trackRobot(props.robotId, (event) => {
298
+ if (event?.type === "pose" && event.pose) {
299
+ streamLost.value = false;
300
+ const at = Date.now();
301
+ lastPose.value = { event, at };
302
+ prevPose.value = nextPose.value;
303
+ nextPose.value = { x: event.pose.x, y: event.pose.y, at };
304
+ } else if (event?.type === "lost") {
305
+ streamLost.value = true;
306
+ } else if (event?.type === "reconnected") {
307
+ streamLost.value = false;
308
+ }
309
+ });
310
+ }
311
+ watch([reportsPosition, online], ([r, o], old) => {
312
+ if (!old || r !== old[0] || o !== old[1]) startStream();
313
+ });
314
+
315
+ /* ---- commands ---- */
316
+ const busy = ref<TRobotCommandKind | "spot" | null>(null);
317
+ async function run(kind: TRobotCommandKind | "spot", body: Record<string, unknown>) {
318
+ const name = record.value?.name ?? "the robot";
319
+ const before = statusMode.value;
320
+ busy.value = kind;
321
+ optimistic.value = { mode: optimisticMode(kind, before), after: Number.POSITIVE_INFINITY };
322
+ toast.value = `${commandLabel(kind)} → ${name}`;
323
+ try {
324
+ await sendRobotCommand(props.robotId, body as any);
325
+ // A poll already in flight may still carry the old status; wait past it.
326
+ optimistic.value = optimistic.value ? { ...optimistic.value, after: Date.now() + 300 } : null;
327
+ return true;
328
+ } catch (e) {
329
+ optimistic.value = null;
330
+ toast.value = robotErrorMessage(e);
331
+ return false;
332
+ } finally {
333
+ busy.value = null;
334
+ }
335
+ }
336
+ function send(kind: TRobotCommandKind) {
337
+ const body = commandBody(kind, live.value);
338
+ if (!body) {
339
+ toast.value = `${commandLabel(kind)}: the robot's position is not known yet.`;
340
+ return;
341
+ }
342
+ run(kind, body);
343
+ }
344
+
345
+ /** The robot's plan image size for its floor, for turning plan clicks into pixels. */
346
+ async function planSize(): Promise<{ width: number; height: number } | null> {
347
+ const maps = (await getRobotMaps(props.robotId))?.items ?? [];
348
+ const floorNo = live.value?.floorNo;
349
+ const map = maps.find((m: any) => m.floorNo === floorNo) ?? maps[0];
350
+ if (!map?.backgroundFileKey) return null;
351
+ const files = await getRobotMapImages(props.robotId, [map.backgroundFileKey]);
352
+ const url = files?.items?.find((f: any) => f.fileKey === map.backgroundFileKey)?.url;
353
+ if (!url) return null;
354
+ return new Promise((resolve) => {
355
+ const img = new Image();
356
+ img.onload = () => resolve({ width: img.naturalWidth, height: img.naturalHeight });
357
+ img.onerror = () => resolve(null);
358
+ img.src = url;
359
+ });
360
+ }
361
+ async function sendSpot() {
362
+ const n = spot.value.length;
363
+ let size: { width: number; height: number } | null = null;
364
+ try {
365
+ size = await planSize();
366
+ } catch {
367
+ size = null;
368
+ }
369
+ if (!size) {
370
+ toast.value = "This robot has no floor plan image, so a spot cannot be sent.";
371
+ return;
372
+ }
373
+ if (await run("spot", { kind: "spot", points: spotPixels(spot.value, size) })) {
374
+ toast.value = `Spot clean · ${n} points → ${record.value?.name ?? "the robot"}`;
375
+ spot.value = [];
376
+ }
377
+ }
378
+
379
+ /* ---- edit / remove ---- */
380
+ function onSaved() {
381
+ editOpen.value = false;
382
+ toast.value = "Robot saved · credentials hidden";
383
+ loadRecord();
384
+ emit("saved");
385
+ }
386
+ async function confirmRemove() {
387
+ if (!record.value) return;
388
+ removing.value = true;
389
+ try {
390
+ await deleteRobot(props.robotId);
391
+ removeOpen.value = false;
392
+ emit("removed", record.value.name);
393
+ } catch (e) {
394
+ toast.value = robotErrorMessage(e, "Could not remove the robot.");
395
+ } finally {
396
+ removing.value = false;
397
+ }
398
+ }
399
+
400
+ /* ---- load ---- */
401
+ async function loadRecord() {
402
+ error.value = "";
403
+ try {
404
+ record.value = await getRobot(props.robotId);
405
+ } catch (e) {
406
+ error.value = robotErrorMessage(e, "Could not load this robot.");
407
+ }
408
+ }
409
+ watch(
410
+ () => props.robotId,
411
+ async () => {
412
+ record.value = null;
413
+ plans.value = [];
414
+ patrol.value = null;
415
+ trail.value = [];
416
+ spot.value = [];
417
+ lastPose.value = null;
418
+ prevPose.value = nextPose.value = null;
419
+ streamLost.value = false;
420
+ await loadRecord();
421
+ loadSchedule();
422
+ },
423
+ { immediate: true },
424
+ );
425
+ // The first live reading says whether there is a schedule to ask for (no interface = none).
426
+ watch(noInterface, () => loadSchedule());
427
+ getRobotBrands().then(
428
+ (res) => (brands.value = res?.items ?? []),
429
+ () => undefined,
430
+ );
431
+
432
+ // The patrol's current checkpoint moves: re-read the plan every 8 s; the clock ticks each second.
433
+ let ticks = 0;
434
+ const timer = setInterval(() => {
435
+ now.value = Date.now();
436
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
437
+ if (++ticks % 8 === 0 && robotType.value === "security") loadSchedule();
438
+ }, 1000);
439
+ onBeforeUnmount(() => {
440
+ clearInterval(timer);
441
+ stream?.stop();
442
+ });
443
+
444
+ watch(connected, (up) => emit("status", { connected: up }), { immediate: true });
445
+ </script>
@@ -370,6 +370,7 @@ import {
370
370
  canRecall,
371
371
  canSpotClean,
372
372
  floorLabel,
373
+ listMeta,
373
374
  robotDisplay,
374
375
  robotErrorMessage,
375
376
  robotFaultText,
@@ -625,7 +626,8 @@ async function load() {
625
626
  type: props.robotType,
626
627
  });
627
628
  items.value = res?.items ?? [];
628
- pages.value = Math.max(1, Number(res?.totalPages ?? 1));
629
+ // `pages` is what the API sends (`totalPages` never existed - the page-1 bug).
630
+ pages.value = listMeta(res, limit).pages;
629
631
  // Deliberately not awaited: the table renders from our own database
630
632
  // immediately, and each robot's chip fills in as its cloud call returns.
631
633
  loadStates().then(watchRobots);
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <!--
3
+ The floor plan both the mini-map and robot detail draw on: 4:3, 10% grid,
4
+ wall outlines, the red dock, corner brackets and the scan line. A
5
+ placeholder for the image each robot uploads (README "Assets"). Overlays
6
+ (routes, robots, trail, spot points) go in the default slot.
7
+ -->
8
+ <div ref="root" class="hero-plan" :class="{ 'hero-plan--detail': detail, 'hero-plan--pick': pick }" @click="onClick">
9
+ <span class="hero-plan__corner hero-plan__corner--tl" aria-hidden="true" />
10
+ <span class="hero-plan__corner hero-plan__corner--tr" aria-hidden="true" />
11
+ <span class="hero-plan__corner hero-plan__corner--bl" aria-hidden="true" />
12
+ <span class="hero-plan__corner hero-plan__corner--br" aria-hidden="true" />
13
+ <span class="hero-plan__wall" style="left: 8%; top: 10%; width: 34%; height: 30%" aria-hidden="true" />
14
+ <span class="hero-plan__wall" style="left: 58%; top: 10%; width: 34%; height: 44%" aria-hidden="true" />
15
+ <span class="hero-plan__wall" style="left: 8%; top: 62%; width: 60%; height: 28%" aria-hidden="true" />
16
+ <span class="hero-plan__dock" aria-hidden="true"><span v-if="detail" class="hero-plan__dock-label">Dock</span></span>
17
+ <span class="hero-plan__scan" aria-hidden="true" />
18
+ <slot />
19
+ </div>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { ref } from "vue";
24
+
25
+ const props = defineProps<{ detail?: boolean; pick?: boolean }>();
26
+ const emit = defineEmits<{ pick: [point: { x: number; y: number }] }>();
27
+ const root = ref<HTMLElement | null>(null);
28
+
29
+ /** A click as a share of the plan (0-98, the handoff's clamp), only when picking. */
30
+ function onClick(e: MouseEvent) {
31
+ if (!props.pick || !root.value) return;
32
+ const r = root.value.getBoundingClientRect();
33
+ const clamp = (v: number) => Math.max(0, Math.min(98, v));
34
+ emit("pick", { x: clamp(((e.clientX - r.left) / r.width) * 100), y: clamp(((e.clientY - r.top) / r.height) * 100) });
35
+ }
36
+
37
+ /** Full screen on the plan itself (Fullscreen API); a second press leaves it. */
38
+ function toggleFullscreen() {
39
+ if (document.fullscreenElement) document.exitFullscreen?.();
40
+ else root.value?.requestFullscreen?.();
41
+ }
42
+ defineExpose({ toggleFullscreen });
43
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <!--
3
+ Robot detail's live position / spot-clean plan (README §3): the robot as a
4
+ 16px square with a rotating radar sweep and a ping ring, its name + status
5
+ tag, a fading breadcrumb trail (last 14), dashed crosshair lines that
6
+ follow it and the telemetry readout. Security: its dashed route, numbered
7
+ checkpoints (the one it is heading for filled) and the route tag. Spot
8
+ clean: each click adds a numbered point. "Reconnecting…" when the position
9
+ is lost - never a frozen dot.
10
+ -->
11
+ <RobotFloorPlan detail :pick="pick" @pick="emit('pick', $event)">
12
+ <RobotPatrolRoutes v-if="route" :routes="[route]" :animate="routeMoving" large />
13
+ <template v-if="point">
14
+ <span v-for="t in trailDots(trail)" :key="t.key" class="hero-trail" :style="{ left: t.left, top: t.top, opacity: t.op }" aria-hidden="true" />
15
+ <span class="hero-cross hero-cross--h" :style="{ top: point.top, transition: `top ${tickMs}ms linear` }" aria-hidden="true" />
16
+ <span class="hero-cross hero-cross--v" :style="{ left: point.left, transition: `left ${tickMs}ms linear` }" aria-hidden="true" />
17
+ <div class="hero-readout">{{ readout }}</div>
18
+ <div class="hero-me" :style="{ left: point.left, top: point.top, transition: `left ${tickMs}ms linear, top ${tickMs}ms linear` }">
19
+ <div class="hero-me__tag">{{ name }} <span>{{ statusLabel }}</span></div>
20
+ <div class="hero-me__radar" aria-hidden="true" />
21
+ <div class="hero-me__ping" aria-hidden="true" />
22
+ <div class="hero-me__body" :style="{ transform: `rotate(${heading}deg)` }" aria-hidden="true"><div class="hero-me__tick" /></div>
23
+ </div>
24
+ </template>
25
+ <RobotReconnecting v-if="lost" />
26
+ <div v-for="(p, i) in spot" :key="i" class="hero-spot" :style="{ left: `${p.x}%`, top: `${p.y}%` }">{{ i + 1 }}</div>
27
+ </RobotFloorPlan>
28
+ </template>
29
+
30
+ <script setup lang="ts">
31
+ import RobotFloorPlan from "./FloorPlan.vue";
32
+ import RobotPatrolRoutes from "./PatrolRoutes.vue";
33
+ import RobotReconnecting from "./Reconnecting.vue";
34
+ import { trailDots, type TPatrolRouteView } from "../../utils/robot-display";
35
+
36
+ withDefaults(
37
+ defineProps<{
38
+ name?: string;
39
+ statusLabel?: string;
40
+ /** Where the robot is ({ left, top } in %), or null when it is not live on this plan. */
41
+ point?: { left: string; top: string } | null;
42
+ heading?: number;
43
+ trail?: Array<{ x: number; y: number }>;
44
+ /** "x 17.9 · y 34.1 · 53° · 0.4 m/s". */
45
+ readout?: string;
46
+ /** Position lost: "Reconnecting…" over the plan. */
47
+ lost?: boolean;
48
+ route?: TPatrolRouteView | null;
49
+ /** The route's dash walks only while the robot patrols. */
50
+ routeMoving?: boolean;
51
+ /** Spot-clean points (0-100 shares) and whether clicks add them. */
52
+ spot?: Array<{ x: number; y: number }>;
53
+ pick?: boolean;
54
+ tickMs?: number;
55
+ }>(),
56
+ { name: "", statusLabel: "", point: null, heading: 0, trail: () => [], readout: "", lost: false, route: null, routeMoving: false, spot: () => [], pick: false, tickMs: 1200 },
57
+ );
58
+ const emit = defineEmits<{ pick: [point: { x: number; y: number }] }>();
59
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <!-- The HERO mark: the robot head, outline + red eye (from the supplied logo; swap for the official vector when it exists). -->
3
+ <svg :width="size" :height="size" viewBox="0 0 100 100" fill="none" stroke="currentColor" stroke-width="5" stroke-linejoin="round" aria-hidden="true">
4
+ <path d="M32 10h36l14 12v40l-14 22H32L18 62V22z" />
5
+ <rect x="27" y="24" width="46" height="34" />
6
+ <path d="M34 64h32v12H34z" />
7
+ <path d="M8 30h8v30H8zM84 30h8v30h-8z" />
8
+ <g fill="var(--hero-accent)" stroke="none">
9
+ <circle cx="50" cy="41" r="8" />
10
+ <path d="M30 38h12l-2 6H30zM58 38h12v6H60z" />
11
+ </g>
12
+ </svg>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ withDefaults(defineProps<{ size?: number }>(), { size: 30 });
17
+ </script>