@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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
The robot table: server-side pages (never every robot at once), sortable
|
|
4
|
+
columns, optional grouping, skeleton rows while loading and a plain empty
|
|
5
|
+
state. Every v-data-table-server prop, event and item slot passes through.
|
|
6
|
+
-->
|
|
7
|
+
<div class="hero-table" :class="{ 'hero-table--compact': compact }">
|
|
8
|
+
<v-data-table-server
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
:headers="columns"
|
|
11
|
+
:items="loading ? [] : items"
|
|
12
|
+
:items-length="itemsLength"
|
|
13
|
+
:page="range.page"
|
|
14
|
+
:items-per-page="itemsPerPage"
|
|
15
|
+
:loading="loading"
|
|
16
|
+
:group-by="groupBy"
|
|
17
|
+
hide-default-footer
|
|
18
|
+
@update:page="emit('update:page', $event)"
|
|
19
|
+
>
|
|
20
|
+
<template v-for="name in passSlots" #[name]="scope">
|
|
21
|
+
<slot :name="name" v-bind="scope ?? {}" />
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<template #loading>
|
|
25
|
+
<div class="hero-skel" aria-label="Loading robots">
|
|
26
|
+
<div v-for="i in skeletonRows" :key="i" class="hero-skel__row" />
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<template #no-data>
|
|
31
|
+
<slot name="no-data">
|
|
32
|
+
<div class="hero-empty">
|
|
33
|
+
<div class="hero-empty__title">{{ emptyTitle }}</div>
|
|
34
|
+
<div v-if="emptyHint" class="hero-empty__hint">{{ emptyHint }}</div>
|
|
35
|
+
</div>
|
|
36
|
+
</slot>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template #group-header="scope">
|
|
40
|
+
<slot name="group-header" v-bind="scope">
|
|
41
|
+
<tr class="hero-table__group" @vue:mounted="openOnMount(scope)">
|
|
42
|
+
<td :colspan="scope.columns.length">
|
|
43
|
+
<button type="button" :aria-expanded="scope.isGroupOpen(scope.item)" @click="scope.toggleGroup(scope.item)">
|
|
44
|
+
{{ scope.item.value }} <span class="hero-muted">· {{ scope.item.items.length }} {{ noun }}</span>
|
|
45
|
+
</button>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</slot>
|
|
49
|
+
</template>
|
|
50
|
+
</v-data-table-server>
|
|
51
|
+
|
|
52
|
+
<div v-if="!loading && range.total" class="hero-table__foot">
|
|
53
|
+
<span>{{ range.text }}</span>
|
|
54
|
+
<div v-if="range.pages > 1" class="hero-table__pager">
|
|
55
|
+
<v-btn variant="outlined" :disabled="!range.hasPrev" @click="emit('update:page', range.page - 1)">Prev</v-btn>
|
|
56
|
+
<v-btn variant="outlined" :disabled="!range.hasNext" @click="emit('update:page', range.page + 1)">Next</v-btn>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { computed, useSlots } from "vue";
|
|
64
|
+
import { pageRange } from "../../utils/robot-display";
|
|
65
|
+
|
|
66
|
+
defineOptions({ inheritAttrs: false });
|
|
67
|
+
|
|
68
|
+
const props = withDefaults(
|
|
69
|
+
defineProps<{
|
|
70
|
+
headers: any[];
|
|
71
|
+
items: any[];
|
|
72
|
+
/** The server's total, not the page's length. */
|
|
73
|
+
itemsLength: number;
|
|
74
|
+
/** 1-based, like Vuetify. */
|
|
75
|
+
page?: number;
|
|
76
|
+
itemsPerPage?: number;
|
|
77
|
+
loading?: boolean;
|
|
78
|
+
groupBy?: Array<{ key: string; order?: "asc" | "desc" }>;
|
|
79
|
+
noun?: string;
|
|
80
|
+
emptyTitle?: string;
|
|
81
|
+
emptyHint?: string;
|
|
82
|
+
skeletonRows?: number;
|
|
83
|
+
/** 12.5px rows, for the Network table. */
|
|
84
|
+
compact?: boolean;
|
|
85
|
+
}>(),
|
|
86
|
+
{
|
|
87
|
+
page: 1,
|
|
88
|
+
itemsPerPage: 25,
|
|
89
|
+
loading: false,
|
|
90
|
+
groupBy: () => [],
|
|
91
|
+
noun: "robots",
|
|
92
|
+
emptyTitle: "No robots match",
|
|
93
|
+
emptyHint: "",
|
|
94
|
+
skeletonRows: 6,
|
|
95
|
+
compact: false,
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
const emit = defineEmits<{ "update:page": [page: number] }>();
|
|
99
|
+
|
|
100
|
+
const OWN = new Set(["loading", "no-data", "group-header"]);
|
|
101
|
+
const slots = useSlots();
|
|
102
|
+
const passSlots = computed(() => Object.keys(slots).filter((n) => !OWN.has(n)));
|
|
103
|
+
|
|
104
|
+
// Vuetify adds its own "Group" column when grouping; the handoff has none, so
|
|
105
|
+
// an empty, zero-width one is supplied in its place.
|
|
106
|
+
const GROUP_COL = { key: "data-table-group", title: "", sortable: false, headerProps: { class: "hero-table__groupcol" }, cellProps: { class: "hero-table__groupcol" } };
|
|
107
|
+
const columns = computed(() => (props.groupBy.length ? [GROUP_COL, ...props.headers] : props.headers));
|
|
108
|
+
|
|
109
|
+
// The handoff lists grouped rows under their header, so a group starts open.
|
|
110
|
+
function openOnMount(scope: any) {
|
|
111
|
+
if (!scope.isGroupOpen(scope.item)) scope.toggleGroup(scope.item);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const range = computed(() => pageRange(props.page, props.itemsPerPage, props.itemsLength, props.noun));
|
|
115
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="modelValue" class="hero-toast" role="status" aria-live="polite">
|
|
3
|
+
<span class="hero-toast__square" aria-hidden="true" />{{ modelValue }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { onBeforeUnmount, watch } from "vue";
|
|
9
|
+
|
|
10
|
+
/** The message; the toast clears it after `timeout` ms (2.6s, the handoff's). */
|
|
11
|
+
const props = withDefaults(defineProps<{ modelValue?: string; timeout?: number }>(), {
|
|
12
|
+
modelValue: "",
|
|
13
|
+
timeout: 2600,
|
|
14
|
+
});
|
|
15
|
+
const emit = defineEmits<{ "update:modelValue": [value: string] }>();
|
|
16
|
+
|
|
17
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
18
|
+
watch(
|
|
19
|
+
() => props.modelValue,
|
|
20
|
+
(msg) => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
if (msg && props.timeout > 0) timer = setTimeout(() => emit("update:modelValue", ""), props.timeout);
|
|
23
|
+
},
|
|
24
|
+
{ immediate: true },
|
|
25
|
+
);
|
|
26
|
+
onBeforeUnmount(() => clearTimeout(timer));
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { onBeforeUnmount, ref, watch, type Ref } from "vue";
|
|
2
|
+
import { mergeLiveStates, type TLiveRobotState } from "../utils/robot-display";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Live robot state for the robots ON SCREEN - one store, one swappable feed.
|
|
6
|
+
*
|
|
7
|
+
* ## The interface a feed implements
|
|
8
|
+
*
|
|
9
|
+
* type TRobotLiveFeed = {
|
|
10
|
+
* // Start delivering states for these robot ids. `push` may be called any
|
|
11
|
+
* // number of times with any subset; each item is a `TLiveRobotState`
|
|
12
|
+
* // (`{ id, ok: false }` = "no answer, show Reconnecting").
|
|
13
|
+
* // `connected(false)` = the feed itself is down ("Connection lost").
|
|
14
|
+
* // Returns a stop function.
|
|
15
|
+
* watch(ids: string[], push: (items) => void, connected: (up: boolean) => void): () => void;
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* Today's feed is `robotPollingFeed`: `GET /api/robots/network/states?ids=...`
|
|
19
|
+
* every 4 s, paused while the tab is hidden (owner decision 2026-09-23: poll
|
|
20
|
+
* on-screen robots 3-5 s). A site-wide push feed (socket.io room per site - a
|
|
21
|
+
* backend follow-up) only has to implement `watch` the same way; components
|
|
22
|
+
* read `states[id]` / `connected` and never know which feed is behind them.
|
|
23
|
+
*/
|
|
24
|
+
export type TRobotLiveFeed = {
|
|
25
|
+
watch(
|
|
26
|
+
ids: string[],
|
|
27
|
+
push: (items: Array<Partial<TLiveRobotState> & { id: string }>) => void,
|
|
28
|
+
connected: (up: boolean) => void,
|
|
29
|
+
): () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The polling feed. `fetchStates` returns `{ items }` for up to 50 ids.
|
|
34
|
+
* One request in flight at a time; a failed request marks the feed down (the
|
|
35
|
+
* robots' last states are replaced by "Reconnecting" - never left frozen).
|
|
36
|
+
*/
|
|
37
|
+
export function robotPollingFeed(
|
|
38
|
+
fetchStates: (ids: string[]) => Promise<{ items?: Array<Partial<TLiveRobotState> & { id: string }> }>,
|
|
39
|
+
intervalMs = 4000,
|
|
40
|
+
): TRobotLiveFeed {
|
|
41
|
+
return {
|
|
42
|
+
watch(ids, push, connected) {
|
|
43
|
+
let stopped = false;
|
|
44
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
45
|
+
const hidden = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
46
|
+
|
|
47
|
+
async function tick() {
|
|
48
|
+
if (stopped) return;
|
|
49
|
+
if (!hidden() && ids.length) {
|
|
50
|
+
try {
|
|
51
|
+
const res = await fetchStates(ids);
|
|
52
|
+
if (stopped) return;
|
|
53
|
+
push(res?.items ?? []);
|
|
54
|
+
connected(true);
|
|
55
|
+
} catch {
|
|
56
|
+
if (stopped) return;
|
|
57
|
+
push(ids.map((id) => ({ id, ok: false })));
|
|
58
|
+
connected(false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!stopped) timer = setTimeout(tick, intervalMs);
|
|
62
|
+
}
|
|
63
|
+
// Coming back to the tab refreshes at once instead of waiting a tick.
|
|
64
|
+
const onVisible = () => {
|
|
65
|
+
if (hidden() || stopped) return;
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
tick();
|
|
68
|
+
};
|
|
69
|
+
if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVisible);
|
|
70
|
+
tick();
|
|
71
|
+
return () => {
|
|
72
|
+
stopped = true;
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisible);
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The Super Admin network feed: `/api/robots/network/states`. */
|
|
81
|
+
export function networkStatesFeed(intervalMs = 4000): TRobotLiveFeed {
|
|
82
|
+
return robotPollingFeed(
|
|
83
|
+
(ids) =>
|
|
84
|
+
useNuxtApp().$api<{ items: any[] }>("/api/robots/network/states", {
|
|
85
|
+
method: "GET",
|
|
86
|
+
query: { ids: ids.join(",") },
|
|
87
|
+
}),
|
|
88
|
+
intervalMs,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* `states[id]` for every robot in `ids`, kept live by `feed`. Re-watches when
|
|
94
|
+
* the ids change (a new page, a new filter); stops on unmount.
|
|
95
|
+
*/
|
|
96
|
+
export default function useRobotLive(ids: Ref<string[]>, feed: TRobotLiveFeed) {
|
|
97
|
+
const states = ref<Record<string, TLiveRobotState>>({});
|
|
98
|
+
const connected = ref(true);
|
|
99
|
+
const lastAt = ref<Date | null>(null);
|
|
100
|
+
let stop: (() => void) | null = null;
|
|
101
|
+
|
|
102
|
+
watch(
|
|
103
|
+
() => ids.value.join(","),
|
|
104
|
+
() => {
|
|
105
|
+
stop?.();
|
|
106
|
+
const list = [...ids.value];
|
|
107
|
+
stop = feed.watch(
|
|
108
|
+
list,
|
|
109
|
+
(items) => {
|
|
110
|
+
states.value = mergeLiveStates(states.value, items);
|
|
111
|
+
lastAt.value = new Date();
|
|
112
|
+
},
|
|
113
|
+
(up) => (connected.value = up),
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
{ immediate: true },
|
|
117
|
+
);
|
|
118
|
+
onBeforeUnmount(() => stop?.());
|
|
119
|
+
|
|
120
|
+
return { states, connected, lastAt };
|
|
121
|
+
}
|
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.28.1-staging.
|
|
5
|
+
"version": "4.28.1-staging.361",
|
|
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.",
|
package/plugins/vuetify.ts
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
} from "vuetify-pro-tiptap";
|
|
43
43
|
import "vuetify-pro-tiptap/style.css";
|
|
44
44
|
|
|
45
|
-
import { LIGHT_THEME, DARK_THEME } from "../utils/theme";
|
|
45
|
+
import { LIGHT_THEME, DARK_THEME, HERO_LIGHT_THEME, HERO_DARK_THEME } from "../utils/theme";
|
|
46
46
|
import { MDI_TO_SYMBOL } from "../utils/materialSymbols";
|
|
47
47
|
import { THEME_COOKIE } from "../composables/useThemePreference";
|
|
48
48
|
import type { CookieOptions } from "#app";
|
|
@@ -175,6 +175,13 @@ export default defineNuxtPlugin((app) => {
|
|
|
175
175
|
* theme rather than a blank one.
|
|
176
176
|
*/
|
|
177
177
|
iservice365: LIGHT_THEME,
|
|
178
|
+
/**
|
|
179
|
+
* The robot fleet's HERO look (owner decision 2026-09-23). Never a
|
|
180
|
+
* default: only `components/Robot/Hero.vue` asks for these, through a
|
|
181
|
+
* `v-theme-provider`, so every other screen keeps the themes above.
|
|
182
|
+
*/
|
|
183
|
+
"hero-light": HERO_LIGHT_THEME,
|
|
184
|
+
"hero-dark": HERO_DARK_THEME,
|
|
178
185
|
},
|
|
179
186
|
},
|
|
180
187
|
icons: {
|