@7365admin1/layer-common 4.28.1-staging.359 → 4.28.1-staging.361
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/assets/css/robot-hero.css +614 -0
- package/components/Robot/AlertsTable.vue +72 -0
- package/components/Robot/Battery.vue +18 -0
- package/components/Robot/Bell.vue +21 -0
- package/components/Robot/CapabilityTag.vue +14 -0
- package/components/Robot/Card.vue +56 -0
- package/components/Robot/ClientDrill.vue +36 -0
- package/components/Robot/CommandBar.vue +47 -0
- package/components/Robot/CredentialField.vue +37 -0
- package/components/Robot/FaultBadge.vue +26 -0
- package/components/Robot/FloorLabel.vue +12 -0
- package/components/Robot/Hero.vue +32 -0
- package/components/Robot/LiftQueueRow.vue +28 -0
- package/components/Robot/LiveIndicator.vue +18 -0
- package/components/Robot/MapToolbar.vue +53 -0
- package/components/Robot/NeedsAttention.vue +56 -0
- package/components/Robot/NoMonitoring.vue +14 -0
- package/components/Robot/Reconnecting.vue +7 -0
- package/components/Robot/StatusChip.vue +15 -0
- package/components/Robot/SummaryCell.vue +66 -0
- package/components/Robot/SummaryStrip.vue +19 -0
- package/components/Robot/Table.vue +115 -0
- package/components/Robot/Toast.vue +27 -0
- package/components/Robot/ViewOnlyNotice.vue +3 -0
- package/composables/useRobotLive.ts +121 -0
- package/package.json +1 -1
- package/plugins/vuetify.ts +8 -1
- package/utils/robot-display.ts +393 -0
- package/utils/theme.ts +152 -0
package/utils/robot-display.ts
CHANGED
|
@@ -210,3 +210,396 @@ export function planSummary(plan: Record<string, any> | null | undefined) {
|
|
|
210
210
|
jobs,
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
+
|
|
214
|
+
/* ==========================================================================
|
|
215
|
+
* HERO robot fleet - the rules behind the shared components in
|
|
216
|
+
* `components/Robot/`. Every decision a HERO component makes is one of these
|
|
217
|
+
* functions; the components only call them and draw the answer.
|
|
218
|
+
*
|
|
219
|
+
* Colours are named as HERO theme colours (`utils/theme.ts`), never hexes.
|
|
220
|
+
* ======================================================================== */
|
|
221
|
+
|
|
222
|
+
export type TRobotType = "cleaning" | "security";
|
|
223
|
+
|
|
224
|
+
/** A HERO theme colour a status or state is drawn in. `ink` = text as a fill. */
|
|
225
|
+
export type THeroTone = "success" | "warning" | "info" | "error" | "ink" | "accent";
|
|
226
|
+
|
|
227
|
+
export type THeroStatus = {
|
|
228
|
+
label: string;
|
|
229
|
+
tone: THeroTone;
|
|
230
|
+
/** The chip's dot blinks while the robot is doing something. */
|
|
231
|
+
blink: boolean;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/** Modes during which the robot is moving or changing state on its own. */
|
|
235
|
+
const BLINKING: ReadonlySet<string> = new Set(["WORKING", "IN_TRANSIT", "CHARGING_CYCLE", "MANUAL"]);
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The status chip: the exact label, its tone and whether its dot blinks.
|
|
239
|
+
*
|
|
240
|
+
* Built on `robotDisplay` so the words can never drift from the existing
|
|
241
|
+
* screens. One HERO rule on top: a SECURITY robot that is working is
|
|
242
|
+
* "Patrolling", not "Cleaning". The tone is `robotDisplay`'s colour with the
|
|
243
|
+
* handoff's one substitution - its "primary" (Cleaning/Patrolling) is ink.
|
|
244
|
+
*/
|
|
245
|
+
export function robotStatus(mode: unknown, type?: unknown): THeroStatus {
|
|
246
|
+
const d = robotDisplay(mode);
|
|
247
|
+
return {
|
|
248
|
+
label: mode === "WORKING" && type === "security" ? "Patrolling" : d.label,
|
|
249
|
+
tone: d.color === "primary" ? "ink" : (d.color as THeroTone),
|
|
250
|
+
blink: typeof mode === "string" && BLINKING.has(mode),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The battery reading, or null - and null means RENDER NOTHING.
|
|
256
|
+
*
|
|
257
|
+
* A brand that cannot measure its battery must not show "0%", which reads as
|
|
258
|
+
* flat. Only a finite number counts; it is clamped to 0-100 and rounded.
|
|
259
|
+
* Fill: >=45 success, 20-44 warning, <20 accent.
|
|
260
|
+
*/
|
|
261
|
+
export function batteryReading(value: unknown): { pct: number; tone: THeroTone; text: string } | null {
|
|
262
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
263
|
+
const pct = Math.round(Math.min(Math.max(value, 0), 100));
|
|
264
|
+
const tone: THeroTone = pct >= 45 ? "success" : pct >= 20 ? "warning" : "accent";
|
|
265
|
+
return { pct, tone, text: `${pct}%` };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Every command the platform can send, and the brand capability it needs - a
|
|
270
|
+
* copy of core's `COMMAND_NEEDS` (`robot-adapter.util.ts`). The capability
|
|
271
|
+
* badge is measured against THIS list: it is about what a robot will DO when
|
|
272
|
+
* told, never about what it reports.
|
|
273
|
+
*/
|
|
274
|
+
const COMMAND_NEEDS: Readonly<Record<string, string>> = {
|
|
275
|
+
full: "startProcess",
|
|
276
|
+
area: "startProcess",
|
|
277
|
+
spot: "spotClean",
|
|
278
|
+
return: "sendToDock",
|
|
279
|
+
pause: "pauseProcess",
|
|
280
|
+
resume: "pauseProcess",
|
|
281
|
+
cancel: "pauseProcess",
|
|
282
|
+
navigate: "navigateToPoint",
|
|
283
|
+
relocalize: "relocalize",
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/** Telemetry a brand may declare - reporting only, never a command. */
|
|
287
|
+
const TELEMETRY = ["readLocation", "battery", "floorReporting", "pathAndEta", "processCompletion"];
|
|
288
|
+
|
|
289
|
+
export type TCapabilityLevel = "Full control" | "Basic control" | "Read-only" | "No interface";
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The capability badge (owner rule, 2026-09-23): COMMAND level, never telemetry.
|
|
293
|
+
*
|
|
294
|
+
* - Full control: accepts every command (Demo);
|
|
295
|
+
* - Basic control: accepts some commands but not all (Ounitech: clean all / area, dock);
|
|
296
|
+
* - Read-only: reports telemetry but accepts no command;
|
|
297
|
+
* - No interface: no connection at all - nothing declared (the security robot today).
|
|
298
|
+
*
|
|
299
|
+
* Derived from the brand's declared capabilities (`/robots/:id/state` or
|
|
300
|
+
* `/robots/brands`), NOT core's Open-RMF `robotTier`, which weighs telemetry.
|
|
301
|
+
* Missing / unknown capabilities claim the least.
|
|
302
|
+
*/
|
|
303
|
+
export function capabilityLabel(capabilities: Record<string, unknown> | null | undefined): TCapabilityLevel {
|
|
304
|
+
const caps = capabilities && typeof capabilities === "object" ? capabilities : {};
|
|
305
|
+
const kinds = Object.keys(COMMAND_NEEDS);
|
|
306
|
+
const accepted = kinds.filter((k) => caps[COMMAND_NEEDS[k]!] === true).length;
|
|
307
|
+
if (accepted === kinds.length) return "Full control";
|
|
308
|
+
if (accepted > 0) return "Basic control";
|
|
309
|
+
return TELEMETRY.some((t) => caps[t] === true) ? "Read-only" : "No interface";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** The badge: Full control is outlined accent; the rest neutral; No interface struck through. */
|
|
313
|
+
export function capabilityBadge(capabilities: Record<string, unknown> | null | undefined): {
|
|
314
|
+
label: TCapabilityLevel;
|
|
315
|
+
variant: "outline" | "neutral" | "struck";
|
|
316
|
+
} {
|
|
317
|
+
const label = capabilityLabel(capabilities);
|
|
318
|
+
const variant = label === "Full control" ? "outline" : label === "No interface" ? "struck" : "neutral";
|
|
319
|
+
return { label, variant };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** The facts a brand may or may not report, in the order the "Not reported" line lists them. */
|
|
323
|
+
const REPORTED_FACTS: ReadonlyArray<{ fact: "battery" | "floor" | "position"; needs: string }> = [
|
|
324
|
+
{ fact: "battery", needs: "battery" },
|
|
325
|
+
{ fact: "floor", needs: "floorReporting" },
|
|
326
|
+
{ fact: "position", needs: "readLocation" },
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
/** Which facts this brand reports - a fact cell it cannot fill says "Not reported". */
|
|
330
|
+
export function reportedFacts(capabilities: Record<string, unknown> | null | undefined) {
|
|
331
|
+
const caps = capabilities ?? {};
|
|
332
|
+
return Object.fromEntries(REPORTED_FACTS.map((f) => [f.fact, caps[f.needs] === true])) as Record<
|
|
333
|
+
"battery" | "floor" | "position",
|
|
334
|
+
boolean
|
|
335
|
+
>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* "Not reported by Ounitech: battery, floor" - shown on robot detail so a
|
|
340
|
+
* missing fact reads as the brand's limit, not a fault. The brand's trailing
|
|
341
|
+
* model list ("Ounitech (Q3-G / Q3-W)") is dropped. Null when nothing is missing.
|
|
342
|
+
*/
|
|
343
|
+
export function notReportedLine(brand: unknown, capabilities: Record<string, unknown> | null | undefined): string | null {
|
|
344
|
+
const facts = reportedFacts(capabilities);
|
|
345
|
+
const missing = REPORTED_FACTS.filter((f) => !facts[f.fact]).map((f) => f.fact);
|
|
346
|
+
if (!missing.length) return null;
|
|
347
|
+
const name = (typeof brand === "string" ? brand : "").replace(/\s*\([^)]*\)\s*$/, "").trim() || "this brand";
|
|
348
|
+
return `Not reported by ${name}: ${missing.join(", ")}`;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export type TRobotCommandKind =
|
|
352
|
+
| "full"
|
|
353
|
+
| "area"
|
|
354
|
+
| "return"
|
|
355
|
+
| "pause"
|
|
356
|
+
| "resume"
|
|
357
|
+
| "cancel"
|
|
358
|
+
| "navigate"
|
|
359
|
+
| "relocalize";
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The command bar's buttons, in bar order; each needs `COMMAND_NEEDS[kind]`.
|
|
363
|
+
* `spot` is not here: spot clean is the plan's own control (`SpotClean.vue`).
|
|
364
|
+
*/
|
|
365
|
+
const COMMANDS: ReadonlyArray<{ kind: TRobotCommandKind; label: string }> = [
|
|
366
|
+
{ kind: "full", label: "Clean all" },
|
|
367
|
+
{ kind: "area", label: "Clean area" },
|
|
368
|
+
{ kind: "return", label: "Return to dock" },
|
|
369
|
+
{ kind: "pause", label: "Pause" },
|
|
370
|
+
{ kind: "resume", label: "Resume" },
|
|
371
|
+
{ kind: "cancel", label: "Cancel" },
|
|
372
|
+
{ kind: "navigate", label: "Go to point" },
|
|
373
|
+
{ kind: "relocalize", label: "Set position" },
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
export type TRobotCommand = { kind: TRobotCommandKind; label: string; primary: boolean };
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* The command bar's buttons - HIDDEN, never greyed, when any rule says no.
|
|
380
|
+
*
|
|
381
|
+
* - brand: only commands its declared capabilities support;
|
|
382
|
+
* - role: only a Manager (`canCommand`, i.e. the app's command permission);
|
|
383
|
+
* - online: only a robot confirmed online (`online === true`);
|
|
384
|
+
* - context: Pause only while working, Resume only while paused;
|
|
385
|
+
* - type: a security robot has no cleaning jobs, so no Clean all / Clean area.
|
|
386
|
+
*
|
|
387
|
+
* Returns [] whenever the bar should not render at all.
|
|
388
|
+
*/
|
|
389
|
+
export function visibleCommands(input: {
|
|
390
|
+
capabilities?: Record<string, unknown> | null;
|
|
391
|
+
canCommand?: unknown;
|
|
392
|
+
online?: unknown;
|
|
393
|
+
mode?: unknown;
|
|
394
|
+
type?: unknown;
|
|
395
|
+
} | null | undefined): TRobotCommand[] {
|
|
396
|
+
if (!input || input.canCommand !== true || input.online !== true) return [];
|
|
397
|
+
const caps = input.capabilities ?? {};
|
|
398
|
+
return COMMANDS.filter((c) => {
|
|
399
|
+
if (caps[COMMAND_NEEDS[c.kind]!] !== true) return false;
|
|
400
|
+
if (c.kind === "pause" && input.mode !== "WORKING") return false;
|
|
401
|
+
if (c.kind === "resume" && input.mode !== "PAUSED") return false;
|
|
402
|
+
if ((c.kind === "full" || c.kind === "area") && input.type === "security") return false;
|
|
403
|
+
return true;
|
|
404
|
+
}).map((c) => ({ kind: c.kind, label: c.label, primary: c.kind === "full" }));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* One key per fault OCCURRENCE, so an alert fires once per occurrence.
|
|
409
|
+
*
|
|
410
|
+
* The same code clearing and coming back later is a new occurrence (a new
|
|
411
|
+
* `since`), so it alerts again; the same fault seen on every poll is not.
|
|
412
|
+
* With no `since`, the message stands in. No fault -> null (nothing to alert).
|
|
413
|
+
*/
|
|
414
|
+
export function faultKey(
|
|
415
|
+
robotId: unknown,
|
|
416
|
+
fault: { code?: unknown; message?: unknown; since?: unknown } | null | undefined,
|
|
417
|
+
): string | null {
|
|
418
|
+
if (!fault || (robotId !== 0 && !robotId)) return null;
|
|
419
|
+
const code = typeof fault.code === "string" ? fault.code.trim() : "";
|
|
420
|
+
const message = typeof fault.message === "string" ? fault.message.trim() : "";
|
|
421
|
+
if (!code && !message) return null;
|
|
422
|
+
const since = fault.since instanceof Date ? fault.since.toISOString() : fault.since;
|
|
423
|
+
const when = typeof since === "string" || typeof since === "number" ? String(since) : message;
|
|
424
|
+
return `${robotId}|${code}|${when}`;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** True the first time a fault occurrence is seen; records it in `seen`. */
|
|
428
|
+
export function shouldNotifyFault(key: string | null, seen: Set<string>): boolean {
|
|
429
|
+
if (!key || seen.has(key)) return false;
|
|
430
|
+
seen.add(key);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The table footer. `page` is 1-based (Vuetify's); out-of-range pages clamp.
|
|
436
|
+
* "Showing 1–10 of 60 robots"; nothing to show reads "No robots".
|
|
437
|
+
*/
|
|
438
|
+
export function pageRange(page: unknown, perPage: unknown, total: unknown, noun = "robots") {
|
|
439
|
+
const size = typeof perPage === "number" && perPage > 0 ? Math.floor(perPage) : 10;
|
|
440
|
+
const count = typeof total === "number" && total > 0 ? Math.floor(total) : 0;
|
|
441
|
+
const pages = Math.max(1, Math.ceil(count / size));
|
|
442
|
+
const asked = typeof page === "number" && page >= 1 ? Math.floor(page) : 1;
|
|
443
|
+
const p = Math.min(asked, pages);
|
|
444
|
+
const from = count ? (p - 1) * size + 1 : 0;
|
|
445
|
+
const to = Math.min(p * size, count);
|
|
446
|
+
return {
|
|
447
|
+
page: p,
|
|
448
|
+
pages,
|
|
449
|
+
from,
|
|
450
|
+
to,
|
|
451
|
+
total: count,
|
|
452
|
+
hasPrev: p > 1,
|
|
453
|
+
hasNext: p < pages,
|
|
454
|
+
text: count ? `Showing ${from}–${to} of ${count} ${noun}` : `No ${noun}`,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** How many of a summary cell's tick segments are filled: value/total of 20. */
|
|
459
|
+
export function summaryTicks(value: unknown, total: unknown, segments = 20): number {
|
|
460
|
+
const v = typeof value === "number" && value > 0 ? value : 0;
|
|
461
|
+
const t = typeof total === "number" && total > 0 ? total : 0;
|
|
462
|
+
if (!t) return 0;
|
|
463
|
+
return Math.round(Math.min(1, v / t) * segments);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Faults and Offline turn accent (and blink) when there are any; all else is ink. */
|
|
467
|
+
export function summaryAlert(kind: unknown, value: unknown): boolean {
|
|
468
|
+
return (kind === "faults" || kind === "offline") && typeof value === "number" && value > 0;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* The count-up: `target` after `elapsed` of `duration` ms, ease-out cubic.
|
|
473
|
+
* Whole numbers only - a robot count is never 12.4.
|
|
474
|
+
*/
|
|
475
|
+
export function countUpValue(target: number, elapsed: number, duration = 900): number {
|
|
476
|
+
if (!(duration > 0) || elapsed >= duration) return target;
|
|
477
|
+
const t = Math.max(0, elapsed) / duration;
|
|
478
|
+
return Math.round(target * (1 - Math.pow(1 - t, 3)));
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export type TLiftState = "requested" | "riding" | "released" | "timed out";
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* A lift-queue row's chip tone and its bottom progress stripe:
|
|
485
|
+
* riding = fast moving stripe, requested = slow, timed out = solid accent,
|
|
486
|
+
* released = none.
|
|
487
|
+
*/
|
|
488
|
+
export function liftState(state: unknown): { label: string; tone: THeroTone; stripe: "fast" | "slow" | "solid" | "none" } {
|
|
489
|
+
switch (state) {
|
|
490
|
+
case "requested": return { label: "requested", tone: "info", stripe: "slow" };
|
|
491
|
+
case "riding": return { label: "riding", tone: "ink", stripe: "fast" };
|
|
492
|
+
case "released": return { label: "released", tone: "success", stripe: "none" };
|
|
493
|
+
case "timed out": return { label: "timed out", tone: "error", stripe: "solid" };
|
|
494
|
+
default: return { label: "unknown", tone: "error", stripe: "none" };
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** The map editor's tools, in toolbar order. */
|
|
499
|
+
export const MAP_TOOLS = [
|
|
500
|
+
{ id: "wall", label: "Wall" },
|
|
501
|
+
{ id: "zone", label: "Zone" },
|
|
502
|
+
{ id: "door", label: "Door" },
|
|
503
|
+
{ id: "lift", label: "Lift shaft" },
|
|
504
|
+
{ id: "move", label: "Move" },
|
|
505
|
+
{ id: "delete", label: "Delete" },
|
|
506
|
+
] as const;
|
|
507
|
+
|
|
508
|
+
/** A write-only credential's placeholder: once saved it is acknowledged, never shown. */
|
|
509
|
+
export function credentialPlaceholder(saved: unknown): string {
|
|
510
|
+
return saved === true ? "Saved · hidden. Enter to replace" : "Paste from the brand portal";
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** The HERO theme for the app's current light/dark setting. */
|
|
514
|
+
export function heroThemeName(appThemeIsDark: unknown): "hero-dark" | "hero-light" {
|
|
515
|
+
return appThemeIsDark === true ? "hero-dark" : "hero-light";
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/* ============================================ network view (HERO phase b) */
|
|
519
|
+
|
|
520
|
+
/** "43 cleaning · 16 security" from `[{ key, count }]`; empty classes are left out. */
|
|
521
|
+
export function splitLine(byType: Array<{ key?: unknown; count?: unknown }> | null | undefined): string {
|
|
522
|
+
return (byType ?? [])
|
|
523
|
+
.filter((t) => typeof t?.count === "number" && (t.count as number) > 0)
|
|
524
|
+
.map((t) => `${t.count} ${t.key}`)
|
|
525
|
+
.join(" · ");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** "0 s ago" / "12 min ago" / "21 h ago" / "3 d ago"; "" when unknown. */
|
|
529
|
+
export function agoText(at: unknown, now: number = Date.now()): string {
|
|
530
|
+
const t = at instanceof Date ? at.getTime() : typeof at === "string" || typeof at === "number" ? new Date(at).getTime() : NaN;
|
|
531
|
+
if (!Number.isFinite(t)) return "";
|
|
532
|
+
const s = Math.max(0, Math.round((now - t) / 1000));
|
|
533
|
+
if (s < 60) return `${s} s ago`;
|
|
534
|
+
if (s < 3600) return `${Math.floor(s / 60)} min ago`;
|
|
535
|
+
if (s < 86400) return `${Math.floor(s / 3600)} h ago`;
|
|
536
|
+
return `${Math.floor(s / 86400)} d ago`;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** "15:58 · 20 min" - when a fault started and how long it has stood (the handoff's Since). */
|
|
540
|
+
export function sinceText(at: unknown, now: number = Date.now()): string {
|
|
541
|
+
const t = at instanceof Date ? at.getTime() : typeof at === "string" || typeof at === "number" ? new Date(at).getTime() : NaN;
|
|
542
|
+
if (!Number.isFinite(t)) return "";
|
|
543
|
+
const clock = new Date(t).toTimeString().slice(0, 5);
|
|
544
|
+
const ago = agoText(t, now).replace(/ ago$/, "").replace(/^(\d+) s$/, "now");
|
|
545
|
+
return `${clock} · ${ago}`;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/** A Needs attention / alerts row's code and words: an OFFLINE record reads "Not reporting". */
|
|
549
|
+
export function attentionText(item: { code?: unknown; message?: unknown; offline?: unknown } | null | undefined) {
|
|
550
|
+
if (!item) return { code: "", message: "" };
|
|
551
|
+
if (item.offline === true || item.code === "OFFLINE") return { code: "OFFLINE", message: "Not reporting" };
|
|
552
|
+
return { code: String(item.code ?? ""), message: String(item.message || item.code || "") };
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export type TLiveRobotState = {
|
|
556
|
+
id: string;
|
|
557
|
+
/** false = the robot's cloud did not answer this poll: show "Reconnecting", never old facts. */
|
|
558
|
+
ok: boolean;
|
|
559
|
+
/** false = its brand has no interface: nothing to show, ever. */
|
|
560
|
+
monitorable?: boolean;
|
|
561
|
+
online?: boolean;
|
|
562
|
+
mode?: string;
|
|
563
|
+
batteryPercent?: number | null;
|
|
564
|
+
floorNo?: number | null;
|
|
565
|
+
floorKnown?: boolean;
|
|
566
|
+
position?: { x: number; y: number; theta: number } | null;
|
|
567
|
+
fault?: { code: string; message?: string; since?: number } | null;
|
|
568
|
+
capabilities?: Record<string, unknown>;
|
|
569
|
+
lastSeenAt?: string | null;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Fold one poll's answer into the live map. A robot that did not answer
|
|
574
|
+
* REPLACES its old state with `{ ok: false }`: a stale battery or position
|
|
575
|
+
* must never stay on screen as if live. Robots not in this answer keep theirs.
|
|
576
|
+
*/
|
|
577
|
+
export function mergeLiveStates(
|
|
578
|
+
prev: Record<string, TLiveRobotState>,
|
|
579
|
+
items: Array<Partial<TLiveRobotState> & { id?: unknown }> | null | undefined,
|
|
580
|
+
): Record<string, TLiveRobotState> {
|
|
581
|
+
const next = { ...prev };
|
|
582
|
+
for (const item of items ?? []) {
|
|
583
|
+
if (!item || typeof item.id !== "string") continue;
|
|
584
|
+
next[item.id] = item.ok === true ? ({ ...item, ok: true } as TLiveRobotState) : { id: item.id, ok: false, monitorable: item.monitorable !== false };
|
|
585
|
+
}
|
|
586
|
+
return next;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* What the Status cell says for a row: the live mode when read; "Reconnecting"
|
|
591
|
+
* when the last poll got no answer; "Offline" from the stored record while no
|
|
592
|
+
* live answer exists; UNKNOWN (error tone) for a brand with nothing to read -
|
|
593
|
+
* "No interface" is the capability badge's word, never a status; null while
|
|
594
|
+
* still checking. One state per chip.
|
|
595
|
+
*/
|
|
596
|
+
export function rowStatus(
|
|
597
|
+
row: { offline?: unknown } | null | undefined,
|
|
598
|
+
live: TLiveRobotState | null | undefined,
|
|
599
|
+
): { kind: "live" | "reconnecting" | "offline" | "none" | "checking"; mode?: string } {
|
|
600
|
+
if (live?.ok) return live.online === false ? { kind: "live", mode: "UNAVAILABLE" } : { kind: "live", mode: live.mode };
|
|
601
|
+
if (live && live.monitorable === false) return { kind: "none", mode: "UNKNOWN" };
|
|
602
|
+
if (live && !live.ok) return { kind: "reconnecting" };
|
|
603
|
+
if (row?.offline === true) return { kind: "offline" };
|
|
604
|
+
return { kind: "checking" };
|
|
605
|
+
}
|
package/utils/theme.ts
CHANGED
|
@@ -319,3 +319,155 @@ const theme = (dark: boolean, p: Palette) => ({
|
|
|
319
319
|
export const LIGHT_THEME = theme(false, PALETTE.light);
|
|
320
320
|
|
|
321
321
|
export const DARK_THEME = theme(true, PALETTE.dark);
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* HERO - THE ROBOT FLEET'S OWN LOOK, AND ONLY THE ROBOT FLEET'S.
|
|
325
|
+
*
|
|
326
|
+
* Owner decision, 2026-09-23: the HERO handoff (Archivo, square corners, a red
|
|
327
|
+
* accent) applies on robot pages only. Everything above this line - the
|
|
328
|
+
* product's light/dark/iservice365 themes, Manrope, the rounded radii - is
|
|
329
|
+
* untouched. These two themes are only ever reached through a
|
|
330
|
+
* `v-theme-provider` (`components/Robot/Hero.vue`), never as a default.
|
|
331
|
+
*
|
|
332
|
+
* Every value is the handoff's token sheet (`design_handoff_robot_fleet/_ds/
|
|
333
|
+
* .../styles.css` plus the dark overrides in the prototype) or the README's
|
|
334
|
+
* added status tones. The three tones are specified in OKLCH; Vuetify needs a
|
|
335
|
+
* hex, so they are resolved here (sRGB, clipped as a browser clips):
|
|
336
|
+
*
|
|
337
|
+
* success oklch(0.52 0.15 150) -> #007f35 white label
|
|
338
|
+
* warning oklch(0.8 0.16 80) -> #f3b01d ink label
|
|
339
|
+
* info oklch(0.55 0.13 240) -> #0079b5 white label
|
|
340
|
+
*
|
|
341
|
+
* `primary` is the accent (the one primary action, e.g. "Clean all"), and its
|
|
342
|
+
* label is the page background, exactly as the prototype's `.btn-primary`.
|
|
343
|
+
* A status whose tone is "primary" in the handoff (Cleaning / Patrolling) is
|
|
344
|
+
* drawn as "ink" - text colour as a fill, `assets/css/robot-hero.css` - so red
|
|
345
|
+
* stays reserved for errors and the one primary action.
|
|
346
|
+
*/
|
|
347
|
+
export const HERO_PALETTE = {
|
|
348
|
+
light: {
|
|
349
|
+
bg: "#f3f2f2",
|
|
350
|
+
surface: "#eae9e9",
|
|
351
|
+
text: "#201e1d",
|
|
352
|
+
accent: "#ec3013",
|
|
353
|
+
accent600: "#dd2b0f",
|
|
354
|
+
accent700: "#ae1800",
|
|
355
|
+
accent100: "#fff2ef",
|
|
356
|
+
accent800: "#7c1405",
|
|
357
|
+
neutral100: "#f8f4f4",
|
|
358
|
+
neutral300: "#d7d3d3",
|
|
359
|
+
neutral800: "#444141",
|
|
360
|
+
neutral900: "#2d2b2b",
|
|
361
|
+
/** Text at 60% / 40% over bg, resolved - Vuetify needs an opaque colour. */
|
|
362
|
+
muted: "#747372",
|
|
363
|
+
border: "#9f9d9d",
|
|
364
|
+
/** Divider = text at this alpha (`--color-divider`). */
|
|
365
|
+
dividerOpacity: 0.4,
|
|
366
|
+
shadowSm: "0 1px 2px rgba(45, 43, 43, 0.14)",
|
|
367
|
+
shadowLg: "0 12px 32px rgba(45, 43, 43, 0.22)",
|
|
368
|
+
},
|
|
369
|
+
dark: {
|
|
370
|
+
bg: "#141313",
|
|
371
|
+
surface: "#1e1c1c",
|
|
372
|
+
text: "#f3f2f2",
|
|
373
|
+
accent: "#ec3013",
|
|
374
|
+
accent600: "#dd2b0f",
|
|
375
|
+
accent700: "#ae1800",
|
|
376
|
+
accent100: "#4d170e",
|
|
377
|
+
accent800: "#ffc4b8",
|
|
378
|
+
neutral100: "#2a2828",
|
|
379
|
+
neutral300: "#444141",
|
|
380
|
+
neutral800: "#d7d3d3",
|
|
381
|
+
neutral900: "#f3f2f2",
|
|
382
|
+
muted: "#9a9999",
|
|
383
|
+
border: "#5b5a5a",
|
|
384
|
+
dividerOpacity: 0.32,
|
|
385
|
+
shadowSm: "0 0 0 1px rgba(255, 255, 255, 0.08)",
|
|
386
|
+
shadowLg: "0 0 0 1px rgba(255, 255, 255, 0.12), 0 20px 50px rgba(0, 0, 0, 0.7)",
|
|
387
|
+
},
|
|
388
|
+
tones: {
|
|
389
|
+
success: "#007f35",
|
|
390
|
+
warning: "#f3b01d",
|
|
391
|
+
info: "#0079b5",
|
|
392
|
+
onSuccess: "#ffffff",
|
|
393
|
+
onWarning: "#201e1d",
|
|
394
|
+
onInfo: "#ffffff",
|
|
395
|
+
onError: "#ffffff",
|
|
396
|
+
},
|
|
397
|
+
} as const;
|
|
398
|
+
|
|
399
|
+
/** Widened back from the literals, for the same reason as `TPalette`. */
|
|
400
|
+
type THeroPalette = {
|
|
401
|
+
readonly [K in keyof (typeof HERO_PALETTE)["light"]]: (typeof HERO_PALETTE)["light"][K] extends number ? number : string;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Only colour NAMES the product's own themes already have. Vuetify emits a
|
|
406
|
+
* global `.bg-*` / `.text-*` utility class for every colour name in any theme,
|
|
407
|
+
* so a new name here would be a new global class; reusing the existing names
|
|
408
|
+
* means the only global CSS these themes add is their own
|
|
409
|
+
* `.v-theme--hero-light` / `.v-theme--hero-dark` variable blocks. The handoff's
|
|
410
|
+
* extra shades (accent-600, neutral-100 ...) are theme VARIABLES instead
|
|
411
|
+
* (`--v-hero-*`), which Vuetify emits inside those blocks only.
|
|
412
|
+
*/
|
|
413
|
+
const heroTheme = (dark: boolean, p: THeroPalette) => {
|
|
414
|
+
const t = HERO_PALETTE.tones;
|
|
415
|
+
return {
|
|
416
|
+
dark,
|
|
417
|
+
colors: {
|
|
418
|
+
background: p.bg,
|
|
419
|
+
surface: p.surface,
|
|
420
|
+
"surface-bright": p.surface,
|
|
421
|
+
"surface-light": p.surface,
|
|
422
|
+
"surface-variant": p.neutral300,
|
|
423
|
+
"on-background": p.text,
|
|
424
|
+
"on-surface": p.text,
|
|
425
|
+
"on-surface-variant": p.neutral900,
|
|
426
|
+
primary: p.accent,
|
|
427
|
+
"on-primary": p.bg,
|
|
428
|
+
// The layer's own names, so a shared component dropped inside the scope
|
|
429
|
+
// resolves a HERO colour instead of inheriting the page theme's.
|
|
430
|
+
"primary-button": p.accent,
|
|
431
|
+
"on-primary-button": p.bg,
|
|
432
|
+
"text-primary": p.text,
|
|
433
|
+
"brand-surface": p.surface,
|
|
434
|
+
"on-brand-surface": p.text,
|
|
435
|
+
accent: p.accent,
|
|
436
|
+
"accent-strong": p.accent,
|
|
437
|
+
"accent-text": p.accent,
|
|
438
|
+
text2: p.neutral900,
|
|
439
|
+
muted: p.muted,
|
|
440
|
+
border: p.border,
|
|
441
|
+
sidebar: p.surface,
|
|
442
|
+
success: t.success,
|
|
443
|
+
"on-success": t.onSuccess,
|
|
444
|
+
warning: t.warning,
|
|
445
|
+
"on-warning": t.onWarning,
|
|
446
|
+
info: t.info,
|
|
447
|
+
"on-info": t.onInfo,
|
|
448
|
+
error: p.accent,
|
|
449
|
+
"on-error": t.onError,
|
|
450
|
+
},
|
|
451
|
+
variables: {
|
|
452
|
+
// Vuetify draws its own borders as on-surface at this opacity, so a
|
|
453
|
+
// v-btn outline or a table rule matches the handoff's divider.
|
|
454
|
+
"border-color": p.text,
|
|
455
|
+
"border-opacity": p.dividerOpacity,
|
|
456
|
+
"hero-divider-opacity": p.dividerOpacity,
|
|
457
|
+
"hero-accent-600": p.accent600,
|
|
458
|
+
"hero-accent-700": p.accent700,
|
|
459
|
+
"hero-accent-100": p.accent100,
|
|
460
|
+
"hero-accent-800": p.accent800,
|
|
461
|
+
"hero-neutral-100": p.neutral100,
|
|
462
|
+
"hero-neutral-300": p.neutral300,
|
|
463
|
+
"hero-neutral-800": p.neutral800,
|
|
464
|
+
"hero-neutral-900": p.neutral900,
|
|
465
|
+
"hero-shadow-sm": p.shadowSm,
|
|
466
|
+
"hero-shadow-lg": p.shadowLg,
|
|
467
|
+
},
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
export const HERO_LIGHT_THEME = heroTheme(false, HERO_PALETTE.light);
|
|
472
|
+
|
|
473
|
+
export const HERO_DARK_THEME = heroTheme(true, HERO_PALETTE.dark);
|