@7365admin1/layer-common 4.25.0 → 4.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 98dbabc: Robots: building layout editor in the 3D view (place, move and remove doors and lift shafts, floor heights, save/remove the layout), doors and lift shafts drawn in 3D with shafts spanning stacked floors, and a live lift queue panel (simulated lift) with request/release for demo robots. New useRobots calls for building maps and lift sessions.
8
+
9
+ ## 4.26.0
10
+
11
+ ### Minor Changes
12
+
13
+ - a4e0317: Robots: edit and remove, schedule, spot clean on the floor plan, faults, stacked levels
14
+
15
+ - `RobotFleet` gains a row menu: Schedule (read-only view of the robot's plans),
16
+ Spot clean (only for brands whose state reports `capabilities.spotClean`),
17
+ Edit (name, serial) and Remove, behind new `canEdit` / `canDelete` props.
18
+ - A robot's reported fault is shown under its status chip.
19
+ - `RobotMap3D` offers "All levels (stacked)" when a robot maps more than one
20
+ floor; the view fits the whole stack.
21
+ - `useRobots` gains `updateRobot` and `deleteRobot`.
22
+
3
23
  ## 4.25.0
4
24
 
5
25
  ### Minor Changes
@@ -1323,11 +1343,11 @@
1323
1343
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1324
1344
  own rule from two endpoints the console already calls, unprojected:
1325
1345
 
1326
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1327
- GET /api/roles/id/:role that membership's role document
1346
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1347
+ GET /api/roles/id/:role that membership's role document
1328
1348
 
1329
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1330
- staff = member.type === "admin" && role.type === "admin"
1349
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1350
+ staff = member.type === "admin" && role.type === "admin"
1331
1351
 
1332
1352
  `role.default` is the marker because it is the only property of a platform
1333
1353
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -100,6 +100,13 @@
100
100
  <v-icon start size="16">{{ display(item).icon }}</v-icon>
101
101
  {{ display(item).label }}
102
102
  </v-chip>
103
+ <!-- The robot's own fault, in its words, under the chip. -->
104
+ <div
105
+ v-if="robotFaultText(states[item._id])"
106
+ class="text-caption text-error mt-1"
107
+ >
108
+ {{ robotFaultText(states[item._id]) }}
109
+ </div>
103
110
  </template>
104
111
 
105
112
  <template #item.floor="{ item }">
@@ -154,6 +161,38 @@
154
161
  <AppButton size="small" variant="text" @click="openMap(item)">
155
162
  View layout
156
163
  </AppButton>
164
+ <v-menu location="bottom end">
165
+ <template #activator="{ props: menu }">
166
+ <AppButton
167
+ v-bind="menu"
168
+ variant="icon"
169
+ icon="mdi-dots-vertical"
170
+ :aria-label="`More actions for ${item.name}`"
171
+ />
172
+ </template>
173
+ <v-list density="compact">
174
+ <v-list-item title="Schedule" prepend-icon="mdi-calendar-clock" @click="openPlans(item)" />
175
+ <!--
176
+ Only for a brand that can take a click on the plan. A brand
177
+ without it gets no control, not one the server refuses.
178
+ -->
179
+ <v-list-item
180
+ v-if="canCommand && brandSpotCleans(states[item._id])"
181
+ title="Spot clean"
182
+ prepend-icon="mdi-target"
183
+ :disabled="!canSpotClean(states[item._id])"
184
+ @click="openSpot(item)"
185
+ />
186
+ <v-list-item v-if="canEdit" title="Edit" prepend-icon="mdi-pencil-outline" @click="openEdit(item)" />
187
+ <v-list-item
188
+ v-if="canDelete"
189
+ title="Remove"
190
+ prepend-icon="mdi-delete-outline"
191
+ base-color="error"
192
+ @click="openRemove(item)"
193
+ />
194
+ </v-list>
195
+ </v-menu>
157
196
  </div>
158
197
  </template>
159
198
 
@@ -183,6 +222,9 @@
183
222
  :key="mapRobot._id"
184
223
  :robot-id="mapRobot._id"
185
224
  :robot-state="states[mapRobot._id] ?? null"
225
+ :can-edit="canEdit"
226
+ :robot-name="mapRobot.name"
227
+ :robot-brand="mapRobot.brand"
186
228
  />
187
229
  </AppCard>
188
230
  </v-dialog>
@@ -245,6 +287,68 @@
245
287
  @created="onCreated"
246
288
  />
247
289
  </v-dialog>
290
+
291
+ <v-dialog v-model="editDialog" width="460" persistent>
292
+ <RobotForm
293
+ v-if="editDialog && actionRobot"
294
+ :key="actionRobot._id"
295
+ :organization="organization"
296
+ :site="site"
297
+ :type="robotType"
298
+ :robot="actionRobot"
299
+ @cancel="editDialog = false"
300
+ @saved="onSaved"
301
+ />
302
+ </v-dialog>
303
+
304
+ <v-dialog v-model="plansDialog" width="560" scrollable>
305
+ <AppCard class="pa-0">
306
+ <v-toolbar density="comfortable" class="pl-4">
307
+ <span class="font-weight-medium text-h6">Schedule — {{ actionRobot?.name }}</span>
308
+ <v-spacer />
309
+ <AppButton variant="icon" icon="mdi-close" aria-label="Close" @click="plansDialog = false" />
310
+ </v-toolbar>
311
+ <RobotPlans v-if="plansDialog && actionRobot" :key="actionRobot._id" :robot-id="actionRobot._id" />
312
+ </AppCard>
313
+ </v-dialog>
314
+
315
+ <v-dialog v-model="spotDialog" width="720" scrollable>
316
+ <AppCard class="pa-0">
317
+ <v-toolbar density="comfortable" class="pl-4">
318
+ <span class="font-weight-medium text-h6">Spot clean — {{ actionRobot?.name }}</span>
319
+ </v-toolbar>
320
+ <RobotSpotClean
321
+ v-if="spotDialog && actionRobot"
322
+ :key="actionRobot._id"
323
+ :robot-id="actionRobot._id"
324
+ :robot-name="actionRobot.name"
325
+ @close="spotDialog = false"
326
+ @sent="onSpotSent"
327
+ />
328
+ </AppCard>
329
+ </v-dialog>
330
+
331
+ <ConfirmDialog v-model="removeDialog" :loading="removing">
332
+ <template #title>Remove {{ actionRobot?.name }}?</template>
333
+ <template #description>
334
+ It stops appearing here and can no longer be sent to clean. To use it
335
+ again, add it back with its app key and token.
336
+ </template>
337
+ <template #footer>
338
+ <v-row no-gutters class="w-100">
339
+ <v-col cols="6" class="pr-2">
340
+ <v-btn block variant="outlined" class="text-none" :disabled="removing" @click="removeDialog = false">
341
+ Cancel
342
+ </v-btn>
343
+ </v-col>
344
+ <v-col cols="6" class="pl-2">
345
+ <v-btn block variant="flat" color="error" class="text-none" :loading="removing" @click="confirmRemove">
346
+ Remove
347
+ </v-btn>
348
+ </v-col>
349
+ </v-row>
350
+ </template>
351
+ </ConfirmDialog>
248
352
  </template>
249
353
 
250
354
  <script lang="ts" setup>
@@ -261,11 +365,14 @@
261
365
  * gets nothing back rather than being trusted.
262
366
  */
263
367
  import {
368
+ brandSpotCleans,
264
369
  canDispatch,
265
370
  canRecall,
371
+ canSpotClean,
266
372
  floorLabel,
267
373
  robotDisplay,
268
374
  robotErrorMessage,
375
+ robotFaultText,
269
376
  } from "../../utils/robot-display";
270
377
 
271
378
  const props = withDefaults(
@@ -278,11 +385,84 @@ const props = withDefaults(
278
385
  canAdd?: boolean;
279
386
  /** Whether this user may dispatch. Reads and writes are separate grants. */
280
387
  canCommand?: boolean;
388
+ /** `robot-mgmt:update-robot` - rename a robot or set its serial. */
389
+ canEdit?: boolean;
390
+ /** `robot-mgmt:delete-robot` - remove a robot. */
391
+ canDelete?: boolean;
281
392
  }>(),
282
- { robotType: "cleaning", title: "Robots", canAdd: false, canCommand: false },
393
+ {
394
+ robotType: "cleaning",
395
+ title: "Robots",
396
+ canAdd: false,
397
+ canCommand: false,
398
+ canEdit: false,
399
+ canDelete: false,
400
+ },
283
401
  );
284
402
 
285
- const { getRobots, getRobotState, sendRobotCommand, getRobotMaps, trackRobot } = useRobots();
403
+ const { getRobots, getRobotState, sendRobotCommand, getRobotMaps, trackRobot, deleteRobot } =
404
+ useRobots();
405
+
406
+ /* ---- the row menu: schedule, spot clean, edit, remove ------------------ */
407
+
408
+ const actionRobot = ref<Record<string, any> | null>(null);
409
+ const plansDialog = ref(false);
410
+ const spotDialog = ref(false);
411
+ const editDialog = ref(false);
412
+ const removeDialog = ref(false);
413
+ const removing = ref(false);
414
+
415
+ function openPlans(robot: Record<string, any>) {
416
+ actionRobot.value = robot;
417
+ plansDialog.value = true;
418
+ }
419
+ function openSpot(robot: Record<string, any>) {
420
+ actionRobot.value = robot;
421
+ spotDialog.value = true;
422
+ }
423
+ function openEdit(robot: Record<string, any>) {
424
+ actionRobot.value = robot;
425
+ editDialog.value = true;
426
+ }
427
+ function openRemove(robot: Record<string, any>) {
428
+ actionRobot.value = robot;
429
+ removeDialog.value = true;
430
+ }
431
+
432
+ async function onSpotSent(message: string) {
433
+ spotDialog.value = false;
434
+ showToast(message, "success");
435
+ const robot = actionRobot.value;
436
+ if (!robot) return;
437
+ // Re-read: the API returns no job id, so the robot's own state is the proof.
438
+ try {
439
+ states.value = { ...states.value, [robot._id]: await getRobotState(robot._id) };
440
+ } catch {
441
+ // The command was accepted; a failed re-read only leaves the old chip.
442
+ }
443
+ }
444
+
445
+ function onSaved() {
446
+ editDialog.value = false;
447
+ showToast("Robot saved.", "success");
448
+ load();
449
+ }
450
+
451
+ async function confirmRemove() {
452
+ const robot = actionRobot.value;
453
+ if (!robot) return;
454
+ removing.value = true;
455
+ try {
456
+ await deleteRobot(robot._id);
457
+ removeDialog.value = false;
458
+ showToast(`${robot.name} has been removed.`, "success");
459
+ load();
460
+ } catch (e) {
461
+ showToast(robotErrorMessage(e, "Could not remove the robot."), "error");
462
+ } finally {
463
+ removing.value = false;
464
+ }
465
+ }
286
466
 
287
467
  // The house pattern is a local Snackbar with local state, as
288
468
  // `AccessCardPreviewDialog.vue` does - there is no global toast composable.
@@ -1,14 +1,20 @@
1
1
  <template>
2
2
  <v-card width="100%">
3
3
  <v-toolbar density="comfortable" class="pl-4 py-2">
4
- <span class="font-weight-medium text-h6">Add {{ typeLabel }} robot</span>
4
+ <span class="font-weight-medium text-h6">
5
+ {{ editing ? `Edit ${robot?.name ?? "robot"}` : `Add ${typeLabel} robot` }}
6
+ </span>
5
7
  </v-toolbar>
6
8
 
7
9
  <v-card-text class="pa-0" style="max-height: 70vh; overflow-y: auto">
8
10
  <v-form ref="form" @submit.prevent="submit">
9
11
  <v-row no-gutters class="px-6 pt-4">
10
12
  <v-col cols="12" class="mb-2">
11
- <p class="text-body-2 text-medium-emphasis">
13
+ <p v-if="editing" class="text-body-2 text-medium-emphasis">
14
+ Rename the robot or set its serial. To change its brand or its app
15
+ key and token, remove the robot and add it again.
16
+ </p>
17
+ <p v-else class="text-body-2 text-medium-emphasis">
12
18
  The app key and token come from your robot supplier. They are used
13
19
  to talk to the robot and are never shown again once saved.
14
20
  </p>
@@ -25,7 +31,7 @@
25
31
  />
26
32
  </v-col>
27
33
 
28
- <v-col cols="12">
34
+ <v-col v-if="!editing" cols="12">
29
35
  <InputLabel class="font-weight-bold" title="Brand" required />
30
36
  <AppSelect
31
37
  v-model="brand"
@@ -42,7 +48,7 @@
42
48
  </p>
43
49
  </v-col>
44
50
 
45
- <v-col cols="12">
51
+ <v-col v-if="!editing" cols="12">
46
52
  <InputLabel class="font-weight-bold" title="App key" required />
47
53
  <v-text-field
48
54
  v-model="appKey"
@@ -53,7 +59,7 @@
53
59
  />
54
60
  </v-col>
55
61
 
56
- <v-col cols="12">
62
+ <v-col v-if="!editing" cols="12">
57
63
  <InputLabel class="font-weight-bold" title="App token" required />
58
64
  <!--
59
65
  Masked like a password because that is what it is: this token signs
@@ -111,7 +117,7 @@
111
117
  :loading="saving"
112
118
  @click="submit"
113
119
  >
114
- Add robot
120
+ {{ editing ? "Save" : "Add robot" }}
115
121
  </v-btn>
116
122
  </v-col>
117
123
  </v-row>
@@ -140,23 +146,26 @@ const props = withDefaults(
140
146
  organization: string;
141
147
  site: string;
142
148
  type?: "cleaning" | "security";
149
+ /** When given, the form edits this robot instead of adding one. */
150
+ robot?: Record<string, any> | null;
143
151
  }>(),
144
- { type: "cleaning" },
152
+ { type: "cleaning", robot: null },
145
153
  );
146
154
 
147
- const emit = defineEmits<{ cancel: []; created: [] }>();
155
+ const emit = defineEmits<{ cancel: []; created: []; saved: [] }>();
148
156
 
149
- const { createRobot, getRobotBrands } = useRobots();
157
+ const { createRobot, updateRobot, getRobotBrands } = useRobots();
158
+ const editing = computed(() => !!props.robot?._id);
150
159
  const { requiredRule } = useUtils();
151
160
 
152
161
  const form = ref();
153
- const name = ref("");
162
+ const name = ref(props.robot?.name ?? "");
154
163
  const brand = ref("");
155
164
  const brands = ref<Array<Record<string, any>>>([]);
156
165
  const loadingBrands = ref(false);
157
166
  const appKey = ref("");
158
167
  const appToken = ref("");
159
- const robotSn = ref("");
168
+ const robotSn = ref(props.robot?.robotSn ?? "");
160
169
  const reveal = ref(false);
161
170
  const saving = ref(false);
162
171
  const error = ref("");
@@ -201,7 +210,9 @@ async function loadBrands() {
201
210
  }
202
211
  }
203
212
 
204
- onMounted(loadBrands);
213
+ onMounted(() => {
214
+ if (!editing.value) loadBrands();
215
+ });
205
216
 
206
217
  async function submit() {
207
218
  const { valid } = await form.value?.validate?.() ?? { valid: false };
@@ -209,6 +220,20 @@ async function submit() {
209
220
 
210
221
  saving.value = true;
211
222
  error.value = "";
223
+ if (editing.value) {
224
+ try {
225
+ await updateRobot(props.robot!._id, {
226
+ name: name.value.trim(),
227
+ robotSn: robotSn.value.trim(),
228
+ });
229
+ emit("saved");
230
+ } catch (e) {
231
+ error.value = robotErrorMessage(e, "Could not save the robot.");
232
+ } finally {
233
+ saving.value = false;
234
+ }
235
+ return;
236
+ }
212
237
  try {
213
238
  await createRobot({
214
239
  name: name.value.trim(),