@7365admin1/layer-common 4.32.0 → 4.32.1-staging.365
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 +4 -4
- package/assets/css/robot-hero.css +26 -0
- package/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -3
- package/components/Dialog/DeleteConfirmation.vue +17 -2
- package/components/Dialog/ReusablePrompt.vue +26 -3
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessLogDashboard.vue +41 -8
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +332 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +44 -3
- package/components/HidUserEnrollment.vue +845 -155
- package/components/InvitationClientForm.vue +19 -1
- package/components/NotificationBell.vue +39 -3
- package/components/Robot/ActivityLog.vue +113 -0
- package/components/Robot/AlertsTable.vue +1 -0
- package/components/Robot/Detail.vue +8 -5
- package/components/Robot/Form.vue +170 -214
- package/components/Robot/MiniMap.vue +7 -1
- package/components/Robot/SiteAlerts.vue +117 -0
- package/components/Robot/SiteScreen.vue +69 -5
- package/components/VehicleForm.vue +45 -2
- package/components/VehicleManagement.vue +95 -10
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useCleaningPermission.ts +4 -4
- package/composables/useCommonPermission.ts +16 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +117 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useHidReaderSelection.ts +50 -0
- package/composables/useLandscapingPermission.ts +4 -4
- package/composables/useMechanicalElectricalPermission.ts +4 -4
- package/composables/usePeople.ts +19 -0
- package/composables/usePestControlPermission.ts +4 -4
- package/composables/usePoolMaintenancePermission.ts +4 -4
- package/composables/useRobotBuilding.ts +9 -12
- package/composables/useRobots.ts +53 -4
- package/composables/useSecurityPermission.ts +4 -10
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- package/composables/useWebUsb.ts +14 -11
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +28 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/hid-reader-selection.ts +52 -0
- package/utils/notification-target.ts +75 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/robot-display.ts +146 -0
- package/utils/vehicle-actions.ts +12 -4
|
@@ -1,254 +1,210 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<InputLabel class="font-weight-bold" title="Serial number" />
|
|
83
|
-
<v-text-field
|
|
84
|
-
v-model="robotSn"
|
|
85
|
-
density="comfortable"
|
|
86
|
-
placeholder="Optional — found automatically if left blank"
|
|
87
|
-
:disabled="saving"
|
|
88
|
-
/>
|
|
89
|
-
<p class="text-caption text-medium-emphasis mt-n3 mb-2">
|
|
90
|
-
Leave this blank unless the same key covers more than one robot.
|
|
91
|
-
</p>
|
|
92
|
-
</v-col>
|
|
93
|
-
|
|
94
|
-
<v-col cols="12" v-if="error">
|
|
95
|
-
<v-alert type="error" variant="tonal" class="mb-3" :text="error" />
|
|
96
|
-
</v-col>
|
|
97
|
-
</v-row>
|
|
98
|
-
</v-form>
|
|
99
|
-
</v-card-text>
|
|
100
|
-
|
|
101
|
-
<v-toolbar density="compact">
|
|
102
|
-
<v-row no-gutters>
|
|
103
|
-
<v-col cols="6">
|
|
104
|
-
<v-btn
|
|
105
|
-
tile block variant="flat" size="48"
|
|
106
|
-
class="text-none" color="#EFEFEF"
|
|
107
|
-
:disabled="saving"
|
|
108
|
-
@click="$emit('cancel')"
|
|
109
|
-
>
|
|
110
|
-
Close
|
|
111
|
-
</v-btn>
|
|
112
|
-
</v-col>
|
|
113
|
-
<v-col cols="6">
|
|
114
|
-
<v-btn
|
|
115
|
-
tile block variant="flat" size="48"
|
|
116
|
-
class="text-none" color="primary"
|
|
117
|
-
:loading="saving"
|
|
118
|
-
@click="submit"
|
|
119
|
-
>
|
|
120
|
-
{{ editing ? "Save" : "Add robot" }}
|
|
121
|
-
</v-btn>
|
|
122
|
-
</v-col>
|
|
123
|
-
</v-row>
|
|
124
|
-
</v-toolbar>
|
|
125
|
-
</v-card>
|
|
2
|
+
<!--
|
|
3
|
+
Add / edit robot (HERO README §8): a 520px dialog - Name · Type (only when
|
|
4
|
+
the account presents both types) · Brand (filtered by type; each option
|
|
5
|
+
shows its capability) · Site · App key · Token (password fields), the
|
|
6
|
+
credentials note with the brand's capability, Cancel / Save robot.
|
|
7
|
+
|
|
8
|
+
Credentials are write-only: the stored pair never reaches the browser, so
|
|
9
|
+
when editing both fields say "Saved · hidden. Enter to replace" and are
|
|
10
|
+
sent only when BOTH are typed (a replacement). Editing keeps the robot's
|
|
11
|
+
type, brand and site (a different brand is a different robot; a move is a
|
|
12
|
+
remove and add) - shown, not changeable.
|
|
13
|
+
-->
|
|
14
|
+
<form class="hero-dialog hero-dialog--form" :aria-labelledby="titleId" @submit.prevent="submit">
|
|
15
|
+
<div :id="titleId" class="hero-dialog__title">{{ editing ? "Edit robot" : "Add robot" }}</div>
|
|
16
|
+
<div class="hero-form-grid">
|
|
17
|
+
<div class="hero-field hero-form-grid__full">
|
|
18
|
+
<label :for="`${uid}-name`">Name</label>
|
|
19
|
+
<input :id="`${uid}-name`" v-model="name" class="hero-input" placeholder="e.g. HERO-C12" autocomplete="off" :disabled="saving" />
|
|
20
|
+
</div>
|
|
21
|
+
<div v-if="types.length > 1" class="hero-field">
|
|
22
|
+
<label :for="`${uid}-type`">Type</label>
|
|
23
|
+
<select :id="`${uid}-type`" v-model="type" class="hero-input" :disabled="saving || editing" @change="brand = ''">
|
|
24
|
+
<option v-for="t in types" :key="t" :value="t">{{ typeLabel(t) }}</option>
|
|
25
|
+
</select>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="hero-field">
|
|
28
|
+
<label :for="`${uid}-brand`">Brand</label>
|
|
29
|
+
<select :id="`${uid}-brand`" v-model="brand" class="hero-input" :disabled="saving || editing || !options.length">
|
|
30
|
+
<option v-if="!options.length" value="">{{ loadingBrands ? "Loading brands…" : "No brand for this type" }}</option>
|
|
31
|
+
<option v-for="o in options" :key="o.value" :value="o.value">{{ o.label }}</option>
|
|
32
|
+
</select>
|
|
33
|
+
</div>
|
|
34
|
+
<div v-if="clients.length && !editing" class="hero-field hero-form-grid__full">
|
|
35
|
+
<label :for="`${uid}-client`">Client</label>
|
|
36
|
+
<select :id="`${uid}-client`" v-model="org" class="hero-input" :disabled="saving" @change="onClient">
|
|
37
|
+
<option value="" disabled>Choose a client</option>
|
|
38
|
+
<option v-for="c in clients" :key="c._id" :value="c._id">{{ c.name }}</option>
|
|
39
|
+
</select>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="hero-field hero-form-grid__full">
|
|
42
|
+
<label :for="`${uid}-site`">Site</label>
|
|
43
|
+
<select :id="`${uid}-site`" v-model="site" class="hero-input" :disabled="saving || editing || !siteOptions.length">
|
|
44
|
+
<option v-if="!siteOptions.length" value="">{{ clients.length ? "Choose a client first" : "No site" }}</option>
|
|
45
|
+
<option v-for="s in siteOptions" :key="s._id" :value="s._id">{{ s.name }}</option>
|
|
46
|
+
</select>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="hero-field">
|
|
49
|
+
<label :for="`${uid}-key`">App key</label>
|
|
50
|
+
<input
|
|
51
|
+
:id="`${uid}-key`"
|
|
52
|
+
v-model="appKey"
|
|
53
|
+
class="hero-input"
|
|
54
|
+
type="password"
|
|
55
|
+
autocomplete="new-password"
|
|
56
|
+
spellcheck="false"
|
|
57
|
+
:placeholder="credentialPlaceholder(editing)"
|
|
58
|
+
:disabled="saving"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="hero-field">
|
|
62
|
+
<label :for="`${uid}-token`">Token</label>
|
|
63
|
+
<input
|
|
64
|
+
:id="`${uid}-token`"
|
|
65
|
+
v-model="appToken"
|
|
66
|
+
class="hero-input"
|
|
67
|
+
type="password"
|
|
68
|
+
autocomplete="new-password"
|
|
69
|
+
spellcheck="false"
|
|
70
|
+
:placeholder="credentialPlaceholder(editing)"
|
|
71
|
+
:disabled="saving"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="hero-dialog__note">{{ CREDENTIALS_NOTE }} Capability: {{ note }}</div>
|
|
76
|
+
<div v-if="error" class="hero-notice hero-notice--error" role="alert">{{ error }}</div>
|
|
77
|
+
<div class="hero-dialog__actions">
|
|
78
|
+
<v-btn variant="outlined" :disabled="saving" @click="emit('cancel')">Cancel</v-btn>
|
|
79
|
+
<v-btn type="submit" color="primary" variant="flat" :loading="saving">Save robot</v-btn>
|
|
80
|
+
</div>
|
|
81
|
+
</form>
|
|
126
82
|
</template>
|
|
127
83
|
|
|
128
84
|
<script lang="ts" setup>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
* exactly when the person filling this in should type it themselves.
|
|
141
|
-
*/
|
|
142
|
-
import { robotErrorMessage } from "../../utils/robot-display";
|
|
85
|
+
import { computed, onMounted, ref, useId, watch } from "vue";
|
|
86
|
+
import {
|
|
87
|
+
brandOptions,
|
|
88
|
+
capabilityNote,
|
|
89
|
+
credentialPatch,
|
|
90
|
+
credentialPlaceholder,
|
|
91
|
+
CREDENTIALS_NOTE,
|
|
92
|
+
robotErrorMessage,
|
|
93
|
+
typeLabel,
|
|
94
|
+
type TRobotType,
|
|
95
|
+
} from "../../utils/robot-display";
|
|
143
96
|
|
|
144
97
|
const props = withDefaults(
|
|
145
98
|
defineProps<{
|
|
146
|
-
organization
|
|
147
|
-
site
|
|
148
|
-
type
|
|
149
|
-
|
|
99
|
+
organization?: string;
|
|
100
|
+
site?: string;
|
|
101
|
+
/** The type to start on (the header's switch). */
|
|
102
|
+
type?: TRobotType;
|
|
103
|
+
/** The types this account presents - the Type select shows only with both (scope isolation). */
|
|
104
|
+
types?: TRobotType[];
|
|
105
|
+
/** The sites this person may add to; the current one when empty. */
|
|
106
|
+
sites?: Array<{ _id: string; name: string }>;
|
|
107
|
+
siteName?: string;
|
|
108
|
+
/** Super Admin: pick the client first (`update:client` asks the host for its sites). */
|
|
109
|
+
clients?: Array<{ _id: string; name: string }>;
|
|
110
|
+
/** When given, the dialog edits this robot (`{ _id, name, type, brand, site }`). */
|
|
150
111
|
robot?: Record<string, any> | null;
|
|
151
112
|
}>(),
|
|
152
|
-
{ type: "cleaning", robot: null },
|
|
113
|
+
{ organization: "", site: "", type: "cleaning", types: () => ["cleaning"], sites: () => [], siteName: "", clients: () => [], robot: null },
|
|
153
114
|
);
|
|
154
|
-
|
|
155
|
-
|
|
115
|
+
const emit = defineEmits<{
|
|
116
|
+
cancel: [];
|
|
117
|
+
created: [robot: { name: string; site: string }];
|
|
118
|
+
saved: [name: string];
|
|
119
|
+
"update:client": [org: string];
|
|
120
|
+
}>();
|
|
156
121
|
|
|
157
122
|
const { createRobot, updateRobot, getRobotBrands } = useRobots();
|
|
123
|
+
const uid = useId();
|
|
124
|
+
const titleId = `${uid}-title`;
|
|
158
125
|
const editing = computed(() => !!props.robot?._id);
|
|
159
|
-
const { requiredRule } = useUtils();
|
|
160
126
|
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
127
|
+
const name = ref(String(props.robot?.name ?? ""));
|
|
128
|
+
const type = ref<TRobotType>(
|
|
129
|
+
(props.robot?.type as TRobotType) ?? (props.types.includes(props.type) ? props.type : props.types[0] ?? "cleaning"),
|
|
130
|
+
);
|
|
131
|
+
const brand = ref(String(props.robot?.brand ?? ""));
|
|
132
|
+
const org = ref(props.organization);
|
|
133
|
+
const site = ref(String(props.robot?.site?._id ?? props.site ?? ""));
|
|
166
134
|
const appKey = ref("");
|
|
167
135
|
const appToken = ref("");
|
|
168
|
-
const robotSn = ref(props.robot?.robotSn ?? "");
|
|
169
|
-
const reveal = ref(false);
|
|
170
136
|
const saving = ref(false);
|
|
171
137
|
const error = ref("");
|
|
172
138
|
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
139
|
+
const brands = ref<Array<Record<string, any>>>([]);
|
|
140
|
+
const loadingBrands = ref(false);
|
|
141
|
+
const options = computed(() => {
|
|
142
|
+
const list = brandOptions(brands.value, type.value);
|
|
143
|
+
// Editing: the robot's own brand is shown even if this build no longer registers it.
|
|
144
|
+
if (editing.value && brand.value && !list.some((o) => o.value === brand.value)) {
|
|
145
|
+
return [{ value: brand.value, label: String(props.robot?.brandName ?? brand.value), capabilities: {} }, ...list];
|
|
146
|
+
}
|
|
147
|
+
return list;
|
|
148
|
+
});
|
|
149
|
+
// The first brand for the type is preselected, as in the prototype; editing keeps the robot's own.
|
|
150
|
+
watch(
|
|
151
|
+
options,
|
|
152
|
+
(list) => {
|
|
153
|
+
if (!list.some((o) => o.value === brand.value)) brand.value = list.length === 1 || !editing.value ? list[0]?.value ?? "" : brand.value;
|
|
154
|
+
},
|
|
155
|
+
{ immediate: true },
|
|
156
|
+
);
|
|
157
|
+
const note = computed(() => capabilityNote(options.value.find((o) => o.value === brand.value)?.capabilities, type.value));
|
|
189
158
|
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
159
|
+
const siteOptions = computed(() => {
|
|
160
|
+
if (props.sites.length) return props.sites;
|
|
161
|
+
const current = site.value || props.site;
|
|
162
|
+
return current ? [{ _id: current, name: String(props.robot?.site?.name ?? props.siteName ?? "") || "This site" }] : [];
|
|
193
163
|
});
|
|
164
|
+
watch(siteOptions, (list) => {
|
|
165
|
+
if (!list.some((s) => s._id === site.value)) site.value = list[0]?._id ?? "";
|
|
166
|
+
});
|
|
167
|
+
function onClient() {
|
|
168
|
+
site.value = "";
|
|
169
|
+
emit("update:client", org.value);
|
|
170
|
+
}
|
|
194
171
|
|
|
195
|
-
async
|
|
172
|
+
onMounted(async () => {
|
|
196
173
|
loadingBrands.value = true;
|
|
197
174
|
try {
|
|
198
|
-
|
|
199
|
-
brands.value = (res?.items ?? []).map((b: any) => ({
|
|
200
|
-
...b,
|
|
201
|
-
label: b.displayName ?? b.brand,
|
|
202
|
-
}));
|
|
203
|
-
// Only preselect when there is no choice to make. Guessing a brand is how a
|
|
204
|
-
// robot ends up being sent commands in a protocol it does not speak.
|
|
205
|
-
if (brands.value.length === 1) brand.value = brands.value[0].brand;
|
|
175
|
+
brands.value = (await getRobotBrands())?.items ?? [];
|
|
206
176
|
} catch {
|
|
207
177
|
brands.value = [];
|
|
208
178
|
} finally {
|
|
209
179
|
loadingBrands.value = false;
|
|
210
180
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
onMounted(() => {
|
|
214
|
-
if (!editing.value) loadBrands();
|
|
215
181
|
});
|
|
216
182
|
|
|
217
183
|
async function submit() {
|
|
218
|
-
const { valid } = await form.value?.validate?.() ?? { valid: false };
|
|
219
|
-
if (!valid) return;
|
|
220
|
-
|
|
221
|
-
saving.value = true;
|
|
222
184
|
error.value = "";
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
185
|
+
if (!name.value.trim()) return void (error.value = "Give the robot a name.");
|
|
186
|
+
const creds = credentialPatch(appKey.value, appToken.value, editing.value);
|
|
187
|
+
if (!creds.ok) return void (error.value = creds.message);
|
|
188
|
+
saving.value = true;
|
|
189
|
+
try {
|
|
190
|
+
if (editing.value) {
|
|
191
|
+
await updateRobot(String(props.robot!._id), { name: name.value.trim(), ...creds.body });
|
|
192
|
+
emit("saved", name.value.trim());
|
|
193
|
+
} else {
|
|
194
|
+
if (!brand.value) throw new Error("Choose the robot's brand.");
|
|
195
|
+
if (!site.value) throw new Error("Choose the site the robot works at.");
|
|
196
|
+
await createRobot({
|
|
226
197
|
name: name.value.trim(),
|
|
227
|
-
|
|
198
|
+
brand: brand.value,
|
|
199
|
+
type: type.value,
|
|
200
|
+
appKey: creds.body.appKey!,
|
|
201
|
+
appToken: creds.body.appToken!,
|
|
202
|
+
metadata: { orgId: org.value, siteId: site.value },
|
|
228
203
|
});
|
|
229
|
-
emit("
|
|
230
|
-
} catch (e) {
|
|
231
|
-
error.value = robotErrorMessage(e, "Could not save the robot.");
|
|
232
|
-
} finally {
|
|
233
|
-
saving.value = false;
|
|
204
|
+
emit("created", { name: name.value.trim(), site: site.value });
|
|
234
205
|
}
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
try {
|
|
238
|
-
await createRobot({
|
|
239
|
-
name: name.value.trim(),
|
|
240
|
-
brand: brand.value,
|
|
241
|
-
appKey: appKey.value.trim(),
|
|
242
|
-
appToken: appToken.value.trim(),
|
|
243
|
-
type: props.type,
|
|
244
|
-
// Sent only when the person typed one; an empty string would otherwise be
|
|
245
|
-
// stored and stop the server ever discovering the real serial.
|
|
246
|
-
...(robotSn.value.trim() ? { robotSn: robotSn.value.trim() } : {}),
|
|
247
|
-
metadata: { orgId: props.organization, siteId: props.site },
|
|
248
|
-
});
|
|
249
|
-
emit("created");
|
|
250
206
|
} catch (e) {
|
|
251
|
-
error.value = robotErrorMessage(e, "Could not add the robot.");
|
|
207
|
+
error.value = robotErrorMessage(e, editing.value ? "Could not save the robot." : "Could not add the robot.");
|
|
252
208
|
} finally {
|
|
253
209
|
saving.value = false;
|
|
254
210
|
}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
>
|
|
33
33
|
<span class="hero-bot__ping" aria-hidden="true" />
|
|
34
34
|
<span class="hero-bot__body" :style="{ transform: r.rot }" aria-hidden="true"><span class="hero-bot__tick" /></span>
|
|
35
|
-
<span class="hero-bot__name">{{ r.name }}</span>
|
|
35
|
+
<span class="hero-bot__name" :class="tagClass(r)">{{ r.name }}</span>
|
|
36
36
|
</button>
|
|
37
37
|
<RobotReconnecting v-if="!connected" />
|
|
38
38
|
</RobotFloorPlan>
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
floorLabel,
|
|
57
57
|
mapFloors,
|
|
58
58
|
mapRobots,
|
|
59
|
+
nameTagSide,
|
|
59
60
|
pickFloor,
|
|
60
61
|
robotStatus,
|
|
61
62
|
unplacedRobots,
|
|
@@ -116,5 +117,10 @@ const TONE: Record<string, string> = {
|
|
|
116
117
|
accent: "var(--hero-accent)",
|
|
117
118
|
ink: "var(--hero-text)",
|
|
118
119
|
};
|
|
120
|
+
/** Name tags stay inside the plan: flipped left near the right edge, below near the top. */
|
|
121
|
+
function tagClass(r: TMapRobot) {
|
|
122
|
+
const side = nameTagSide(r.left, r.top, r.name);
|
|
123
|
+
return { "hero-bot__name--left": side.flipX, "hero-bot__name--below": side.below };
|
|
124
|
+
}
|
|
119
125
|
const toneColor = (r: TMapRobot) => TONE[robotStatus(r.mode, r.type).tone] ?? TONE.ink;
|
|
120
126
|
</script>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
ALERTS (README §6), one site: kicker "{client} · {site}", "Faults & alerts"
|
|
4
|
+
and "Each occurrence notified once"; the table Code · Message · Robot ·
|
|
5
|
+
Site · Floor · Since · ›, faults first then robots not reporting, server
|
|
6
|
+
paged; "No active faults" when there are none. Every robot type this app
|
|
7
|
+
presents (the API narrows by app), refreshed every 10 s while visible.
|
|
8
|
+
-->
|
|
9
|
+
<div class="hero-head">
|
|
10
|
+
<div>
|
|
11
|
+
<button v-if="backToNetwork" type="button" class="hero-back hero-back--sm" @click="emit('network')">‹ Network</button>
|
|
12
|
+
<div class="hero-kicker hero-kicker--accent">{{ kicker }}</div>
|
|
13
|
+
<h2 class="hero-title">Faults & alerts</h2>
|
|
14
|
+
</div>
|
|
15
|
+
<span class="hero-head__spacer" />
|
|
16
|
+
<span class="hero-note">Each occurrence notified once</span>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div v-if="error && !items.length" class="hero-notice" role="alert">{{ error }}</div>
|
|
20
|
+
<div v-else-if="error" class="hero-notice" role="status">Reconnecting… the alerts show their last reading.</div>
|
|
21
|
+
<RobotAlertsTable
|
|
22
|
+
v-if="!(error && !items.length)"
|
|
23
|
+
:items="items"
|
|
24
|
+
:total="total"
|
|
25
|
+
:page="page"
|
|
26
|
+
:items-per-page="limit"
|
|
27
|
+
:loading="loading"
|
|
28
|
+
:states="states"
|
|
29
|
+
:now="now"
|
|
30
|
+
@update:page="load"
|
|
31
|
+
@open="(f) => emit('open', String(f?.robot?._id ?? ''))"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
37
|
+
import RobotAlertsTable from "./AlertsTable.vue";
|
|
38
|
+
import useRobotLive, { siteStatesFeed } from "../../composables/useRobotLive";
|
|
39
|
+
import { listMeta } from "../../utils/robot-display";
|
|
40
|
+
|
|
41
|
+
const props = withDefaults(
|
|
42
|
+
defineProps<{
|
|
43
|
+
site: string;
|
|
44
|
+
siteName?: string;
|
|
45
|
+
clientName?: string;
|
|
46
|
+
backToNetwork?: boolean;
|
|
47
|
+
limit?: number;
|
|
48
|
+
pollMs?: number;
|
|
49
|
+
}>(),
|
|
50
|
+
{ siteName: "", clientName: "", backToNetwork: false, limit: 25, pollMs: 10000 },
|
|
51
|
+
);
|
|
52
|
+
const emit = defineEmits<{
|
|
53
|
+
open: [robotId: string];
|
|
54
|
+
network: [];
|
|
55
|
+
status: [status: { connected: boolean; faults: number; siteName: string; clientName: string }];
|
|
56
|
+
}>();
|
|
57
|
+
|
|
58
|
+
const { getSiteFaults } = useRobots();
|
|
59
|
+
const items = ref<any[]>([]);
|
|
60
|
+
const total = ref(0);
|
|
61
|
+
const faults = ref(0);
|
|
62
|
+
const page = ref(1);
|
|
63
|
+
const loading = ref(true);
|
|
64
|
+
const error = ref("");
|
|
65
|
+
const now = ref(Date.now());
|
|
66
|
+
|
|
67
|
+
const first = computed(() => items.value[0] ?? null);
|
|
68
|
+
const kicker = computed(() =>
|
|
69
|
+
[props.clientName || first.value?.client?.name, props.siteName || first.value?.site?.name].filter(Boolean).join(" · "),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
async function load(next = page.value) {
|
|
73
|
+
page.value = next;
|
|
74
|
+
try {
|
|
75
|
+
const res = await getSiteFaults(props.site, { page: next, limit: props.limit });
|
|
76
|
+
items.value = res?.items ?? [];
|
|
77
|
+
total.value = listMeta(res, props.limit).total;
|
|
78
|
+
faults.value = Number(res?.faults ?? 0);
|
|
79
|
+
error.value = "";
|
|
80
|
+
} catch (e) {
|
|
81
|
+
error.value = (e as any)?.data?.message || "Can't reach the alerts right now. Reconnecting…";
|
|
82
|
+
} finally {
|
|
83
|
+
loading.value = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Floor: the live state of the robots on this page (never a guess - "Floor unknown"). */
|
|
88
|
+
const ids = computed(() => [...new Set(items.value.map((f) => String(f?.robot?._id ?? "")).filter(Boolean))]);
|
|
89
|
+
const { states, connected } = useRobotLive(ids, siteStatesFeed());
|
|
90
|
+
|
|
91
|
+
const timer = setInterval(() => {
|
|
92
|
+
now.value = Date.now();
|
|
93
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
94
|
+
load();
|
|
95
|
+
}, props.pollMs);
|
|
96
|
+
onBeforeUnmount(() => clearInterval(timer));
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => props.site,
|
|
100
|
+
() => {
|
|
101
|
+
loading.value = true;
|
|
102
|
+
load(1);
|
|
103
|
+
},
|
|
104
|
+
{ immediate: true },
|
|
105
|
+
);
|
|
106
|
+
watch(
|
|
107
|
+
[() => !error.value && connected.value, faults, kicker],
|
|
108
|
+
([up, count]) =>
|
|
109
|
+
emit("status", {
|
|
110
|
+
connected: up,
|
|
111
|
+
faults: count,
|
|
112
|
+
siteName: props.siteName || first.value?.site?.name || "",
|
|
113
|
+
clientName: props.clientName || first.value?.client?.name || "",
|
|
114
|
+
}),
|
|
115
|
+
{ immediate: true },
|
|
116
|
+
);
|
|
117
|
+
</script>
|