@7365admin1/layer-common 4.22.0 → 4.22.1-staging.352
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/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -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 +29 -5
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +833 -152
- package/components/InvitationClientForm.vue +19 -1
- package/components/Robot/Fleet.vue +709 -0
- package/components/Robot/Form.vue +256 -0
- package/components/Robot/Map3D.vue +421 -0
- package/components/Robot/Plans.vue +63 -0
- package/components/Robot/SpotClean.vue +174 -0
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -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/usePeople.ts +19 -0
- package/composables/useRobots.ts +236 -0
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- package/composables/useWebUsb.ts +14 -11
- package/package.json +2 -2
- 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/building-map.ts +398 -0
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/robot-display.ts +212 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OWNER / OCCUPANT / PERSON IN CHARGE - the three standings a business
|
|
3
|
+
* tenancy has, and everything the product says about them.
|
|
4
|
+
*
|
|
5
|
+
* One list, because three screens read it: the form that asks the question
|
|
6
|
+
* (`PeopleFormMgmt`), the list and preview that print the answer back, and
|
|
7
|
+
* the row menu that reassigns it (`people-mgmt`). The values are the ones the
|
|
8
|
+
* server stores and validates - `OccupancyRoles` in core's `person.model.ts`
|
|
9
|
+
* - so a value added on one side has to be added on the other.
|
|
10
|
+
*/
|
|
11
|
+
export const OCCUPANCY_ROLE_OPTIONS: TOccupancyRoleOption[] = [
|
|
12
|
+
{
|
|
13
|
+
value: "owner",
|
|
14
|
+
title: "Owner",
|
|
15
|
+
action: "Assign Owner",
|
|
16
|
+
prompt: "Assign Owner",
|
|
17
|
+
description:
|
|
18
|
+
"The legal titleholder or primary deed owner of the property.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: "occupant",
|
|
22
|
+
title: "Occupant",
|
|
23
|
+
action: "Assign Occupant",
|
|
24
|
+
prompt: "Assign Occupant",
|
|
25
|
+
description:
|
|
26
|
+
"The person currently living in, renting, or utilizing the physical unit.",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "person-in-charge",
|
|
30
|
+
title: "Person in Charge",
|
|
31
|
+
action: "Assign Person in Charge",
|
|
32
|
+
prompt: "Assign Person in Charge (PIC)",
|
|
33
|
+
description:
|
|
34
|
+
"The designated manager responsible for maintenance, emergencies, and daily operations.",
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The same three, in the order the ROW MENU draws them, which is not the
|
|
40
|
+
* order the form's radio does. Derived rather than re-typed so the wording
|
|
41
|
+
* cannot drift between the two.
|
|
42
|
+
*/
|
|
43
|
+
export const OCCUPANCY_ROLE_ACTIONS: TOccupancyRoleOption[] = (
|
|
44
|
+
["person-in-charge", "owner", "occupant"] as TOccupancyRole[]
|
|
45
|
+
).map(
|
|
46
|
+
(value) =>
|
|
47
|
+
OCCUPANCY_ROLE_OPTIONS.find(
|
|
48
|
+
(option) => option.value === value,
|
|
49
|
+
) as TOccupancyRoleOption,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The label for a stored role, or "" for a person who was never asked - which
|
|
54
|
+
* is everyone on a residential site and everyone saved before the question
|
|
55
|
+
* existed. Callers decide what to print instead; nobody should print a raw
|
|
56
|
+
* `person-in-charge` at a user.
|
|
57
|
+
*/
|
|
58
|
+
export function occupancyRoleLabel(role?: string | null): string {
|
|
59
|
+
return (
|
|
60
|
+
OCCUPANCY_ROLE_OPTIONS.find((option) => option.value === role)?.title ?? ""
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Does this person hold OWNER at their unit?
|
|
66
|
+
*
|
|
67
|
+
* The role when there is one, `isOwner` when there is not - the same test the
|
|
68
|
+
* server applies (`holdsUnitOwner` in core's `unit-owner.util.ts`). A person
|
|
69
|
+
* recorded before the role existed carries only the flag, and the people list
|
|
70
|
+
* already prints them as "Owner".
|
|
71
|
+
*/
|
|
72
|
+
export function holdsUnitOwner(person?: {
|
|
73
|
+
occupancyRole?: string | null;
|
|
74
|
+
isOwner?: boolean;
|
|
75
|
+
}): boolean {
|
|
76
|
+
if (!person) return false;
|
|
77
|
+
|
|
78
|
+
if (person.occupancyRole) return person.occupancyRole === "owner";
|
|
79
|
+
|
|
80
|
+
return person.isOwner === true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* MUST THIS PERSON HAND THE UNIT OVER BEFORE THEY CAN BE DEACTIVATED?
|
|
85
|
+
*
|
|
86
|
+
* The owner of a unit does not leave while they still own it - the standing
|
|
87
|
+
* moves to another tenant at the same block, level and unit first.
|
|
88
|
+
*
|
|
89
|
+
* Keyed to the ROLE and never to `isOwner`, exactly as the server keys it
|
|
90
|
+
* (`mustHandOverBeforeDeactivating` in core): the flag is on every resident in
|
|
91
|
+
* the estate, and no residential screen can change it, so a rule keyed to it
|
|
92
|
+
* would trap records that can never satisfy it.
|
|
93
|
+
*/
|
|
94
|
+
export function mustHandOverBeforeDeactivating(person?: {
|
|
95
|
+
occupancyRole?: string | null;
|
|
96
|
+
}): boolean {
|
|
97
|
+
return person?.occupancyRole === "owner";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Why a deactivation was held back. The SERVER carries the enforcing copy of
|
|
102
|
+
* this rule and of these words (core `unit-owner.util.ts`); this one exists so
|
|
103
|
+
* the console can say it before the round trip rather than after.
|
|
104
|
+
*/
|
|
105
|
+
export function ownerHandoverRequiredMessage(name?: string): string {
|
|
106
|
+
const who = name?.trim() ? `"${name.trim()}"` : "This person";
|
|
107
|
+
|
|
108
|
+
return `${who} is the owner of this unit. Assign the owner role to another tenant at the same block, level and unit before deactivating them.`;
|
|
109
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a robot's state is shown to a person.
|
|
3
|
+
*
|
|
4
|
+
* The API answers with a mode from a fixed vocabulary; every screen turns that
|
|
5
|
+
* into the same words and the same colour, so a cleaner on a phone and a manager
|
|
6
|
+
* on a desktop are never looking at two different descriptions of one robot.
|
|
7
|
+
*
|
|
8
|
+
* Pure on purpose: the interesting part is the failure wording, and none of it
|
|
9
|
+
* needs Nuxt, a network or a robot to test.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type TRobotMode =
|
|
13
|
+
| "IDLE"
|
|
14
|
+
| "CHARGED"
|
|
15
|
+
| "WORKING"
|
|
16
|
+
| "PAUSED"
|
|
17
|
+
| "CHARGING_CYCLE"
|
|
18
|
+
| "MAINTENANCE"
|
|
19
|
+
| "IN_TRANSIT"
|
|
20
|
+
| "MANUAL"
|
|
21
|
+
| "UNAVAILABLE";
|
|
22
|
+
|
|
23
|
+
export type TRobotDisplay = {
|
|
24
|
+
/** What the person reads. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** A Vuetify colour token, not a hex — the theme decides the shade. */
|
|
27
|
+
color: string;
|
|
28
|
+
icon: string;
|
|
29
|
+
/** True only when the robot could be given a job this moment. */
|
|
30
|
+
ready: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DISPLAY: Readonly<Record<TRobotMode, TRobotDisplay>> = {
|
|
34
|
+
IDLE: { label: "Ready", color: "success", icon: "mdi-check-circle-outline", ready: true },
|
|
35
|
+
CHARGED: { label: "Charged", color: "success", icon: "mdi-battery-charging-100", ready: true },
|
|
36
|
+
WORKING: { label: "Cleaning", color: "primary", icon: "mdi-broom", ready: false },
|
|
37
|
+
PAUSED: { label: "Paused", color: "warning", icon: "mdi-pause-circle-outline", ready: false },
|
|
38
|
+
CHARGING_CYCLE: { label: "Charging", color: "info", icon: "mdi-battery-charging", ready: false },
|
|
39
|
+
MAINTENANCE: { label: "Maintenance", color: "warning", icon: "mdi-wrench-outline", ready: false },
|
|
40
|
+
IN_TRANSIT: { label: "Changing floor", color: "info", icon: "mdi-elevator-passenger-outline", ready: false },
|
|
41
|
+
MANUAL: { label: "Manual control", color: "warning", icon: "mdi-hand-back-right-outline", ready: false },
|
|
42
|
+
UNAVAILABLE: { label: "Unavailable", color: "error", icon: "mdi-alert-circle-outline", ready: false },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const UNKNOWN: TRobotDisplay = {
|
|
46
|
+
label: "Unknown",
|
|
47
|
+
color: "error",
|
|
48
|
+
icon: "mdi-help-circle-outline",
|
|
49
|
+
ready: false,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A mode we do not recognise shows as "Unknown" and is NEVER ready.
|
|
54
|
+
*
|
|
55
|
+
* The branch that matters. A firmware state this build has not seen must not
|
|
56
|
+
* render as a green "Ready" chip with a Clean button beside it — a person would
|
|
57
|
+
* press it, and the robot would refuse, and the screen would look broken.
|
|
58
|
+
*/
|
|
59
|
+
export function robotDisplay(mode: unknown): TRobotDisplay {
|
|
60
|
+
if (typeof mode !== "string") return UNKNOWN;
|
|
61
|
+
return DISPLAY[mode as TRobotMode] ?? UNKNOWN;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* May the Clean / Return buttons be offered?
|
|
66
|
+
*
|
|
67
|
+
* Offline beats everything: a robot we cannot reach cannot be commanded,
|
|
68
|
+
* whatever its last known mode said.
|
|
69
|
+
*/
|
|
70
|
+
export function canDispatch(state: {
|
|
71
|
+
online?: unknown;
|
|
72
|
+
dispatchable?: unknown;
|
|
73
|
+
mode?: unknown;
|
|
74
|
+
} | null | undefined): boolean {
|
|
75
|
+
if (!state) return false;
|
|
76
|
+
if (state.online === false) return false;
|
|
77
|
+
// The server already decided this; the client agrees rather than re-deriving,
|
|
78
|
+
// so the two can never disagree about whether a button should be there.
|
|
79
|
+
return state.dispatchable === true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Return-to-dock is offered even when a robot is busy.
|
|
84
|
+
*
|
|
85
|
+
* It is how an operator recovers a robot, so it has to be reachable precisely
|
|
86
|
+
* when the robot is doing something wrong. Only an unreachable robot hides it.
|
|
87
|
+
*/
|
|
88
|
+
export function canRecall(state: { online?: unknown } | null | undefined): boolean {
|
|
89
|
+
if (!state) return false;
|
|
90
|
+
return state.online !== false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The floor to show, when the robot does not report one.
|
|
95
|
+
*
|
|
96
|
+
* The vendor's tracking stream carries no floor, so anything claiming to know it
|
|
97
|
+
* must say how sure it is. An unknown floor is shown as unknown rather than
|
|
98
|
+
* guessed — a robot displayed on the wrong storey is worse than one displayed
|
|
99
|
+
* on no storey.
|
|
100
|
+
*/
|
|
101
|
+
export function floorLabel(state: {
|
|
102
|
+
floorNo?: unknown;
|
|
103
|
+
floorKnown?: unknown;
|
|
104
|
+
} | null | undefined): string {
|
|
105
|
+
if (!state || state.floorKnown !== true) return "Floor unknown";
|
|
106
|
+
return typeof state.floorNo === "number" ? `Floor ${state.floorNo}` : "Floor unknown";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Turn a failed fleet call into something worth reading.
|
|
111
|
+
*
|
|
112
|
+
* These calls cross to the vendor's cloud, so the useful message is usually the
|
|
113
|
+
* server's own — "Robot X is Cleaning and cannot take a new job" tells an
|
|
114
|
+
* operator what to do; "Request failed" does not.
|
|
115
|
+
*/
|
|
116
|
+
export function robotErrorMessage(error: unknown, fallback = "Could not reach the robot."): string {
|
|
117
|
+
const e = error as any;
|
|
118
|
+
const fromServer =
|
|
119
|
+
e?.data?.message ?? e?.response?._data?.message ?? e?.data?.msg;
|
|
120
|
+
if (typeof fromServer === "string" && fromServer.trim()) return fromServer.trim();
|
|
121
|
+
if (typeof e?.message === "string" && e.message.trim()) return e.message.trim();
|
|
122
|
+
return fallback;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* May the "Spot clean" control be offered?
|
|
127
|
+
*
|
|
128
|
+
* Only when the robot could take a job now AND its brand says it can take a
|
|
129
|
+
* click on the plan (`spotClean`). A brand without it - Ounitech, until its
|
|
130
|
+
* pixel frame is verified - gets no control rather than one the server refuses.
|
|
131
|
+
*/
|
|
132
|
+
export function canSpotClean(state: {
|
|
133
|
+
online?: unknown;
|
|
134
|
+
dispatchable?: unknown;
|
|
135
|
+
capabilities?: Record<string, unknown> | null;
|
|
136
|
+
} | null | undefined): boolean {
|
|
137
|
+
return canDispatch(state) && state?.capabilities?.spotClean === true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Whether the brand can take a spot at all, busy or not - decides if the control exists. */
|
|
141
|
+
export function brandSpotCleans(state: { capabilities?: Record<string, unknown> | null } | null | undefined) {
|
|
142
|
+
return state?.capabilities?.spotClean === true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The fault the robot is reporting, in its own words, or null. */
|
|
146
|
+
export function robotFaultText(state: { fault?: { message?: unknown; code?: unknown } | null } | null | undefined): string | null {
|
|
147
|
+
const fault = state?.fault;
|
|
148
|
+
if (!fault) return null;
|
|
149
|
+
const text = typeof fault.message === "string" && fault.message.trim()
|
|
150
|
+
? fault.message.trim()
|
|
151
|
+
: typeof fault.code === "string" ? fault.code : "";
|
|
152
|
+
return text ? `Fault: ${text}` : null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A small square around a clicked pixel, as the polygon a spot command takes.
|
|
157
|
+
*
|
|
158
|
+
* A spot command needs at least three points (a single point encloses
|
|
159
|
+
* nothing). Clamped to the image so a click on the edge stays on the plan.
|
|
160
|
+
*/
|
|
161
|
+
export function spotPolygon(
|
|
162
|
+
x: number,
|
|
163
|
+
y: number,
|
|
164
|
+
size: { width: number; height: number },
|
|
165
|
+
half = 10,
|
|
166
|
+
): Array<{ x: number; y: number }> {
|
|
167
|
+
const cx = (v: number) => Math.round(Math.min(Math.max(v, 0), Math.max(size.width - 1, 0)));
|
|
168
|
+
const cy = (v: number) => Math.round(Math.min(Math.max(v, 0), Math.max(size.height - 1, 0)));
|
|
169
|
+
return [
|
|
170
|
+
{ x: cx(x - half), y: cy(y - half) },
|
|
171
|
+
{ x: cx(x + half), y: cy(y - half) },
|
|
172
|
+
{ x: cx(x + half), y: cy(y + half) },
|
|
173
|
+
{ x: cx(x - half), y: cy(y + half) },
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const DAY_NAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A cleaning schedule, as a person reads it.
|
|
181
|
+
*
|
|
182
|
+
* The vendor's `dateList` is 1-7, Monday first. An unknown day number is
|
|
183
|
+
* dropped rather than shown as a blank - but a plan with NO valid days says so,
|
|
184
|
+
* instead of reading like "every day".
|
|
185
|
+
*/
|
|
186
|
+
export function planSummary(plan: Record<string, any> | null | undefined) {
|
|
187
|
+
const days = [...new Set((Array.isArray(plan?.dateList) ? plan!.dateList : [])
|
|
188
|
+
.filter((d: unknown) => Number.isInteger(d) && (d as number) >= 1 && (d as number) <= 7))]
|
|
189
|
+
.sort((a: any, b: any) => a - b) as number[];
|
|
190
|
+
|
|
191
|
+
const dayText =
|
|
192
|
+
days.length === 7 ? "Every day"
|
|
193
|
+
: days.length ? days.map((d) => DAY_NAMES[d - 1]).join(", ")
|
|
194
|
+
: "No days set";
|
|
195
|
+
|
|
196
|
+
const start = typeof plan?.startTime === "string" ? plan.startTime : "";
|
|
197
|
+
const end = typeof plan?.endTime === "string" ? plan.endTime : "";
|
|
198
|
+
const time = start && end ? `${start}–${end}` : start || end || "No time set";
|
|
199
|
+
|
|
200
|
+
const jobs = (Array.isArray(plan?.jobList) ? plan!.jobList : []).map((job: any) => {
|
|
201
|
+
const floor = typeof job?.floorNo === "number" ? `Floor ${job.floorNo}` : "Floor unknown";
|
|
202
|
+
const passes = typeof job?.cleanTimes === "number" ? `${job.cleanTimes} pass${job.cleanTimes === 1 ? "" : "es"}` : "";
|
|
203
|
+
return [floor, passes].filter(Boolean).join(" · ");
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
days: dayText,
|
|
208
|
+
time,
|
|
209
|
+
enabled: plan?.enableFlag === true || plan?.enableFlag === 1,
|
|
210
|
+
jobs,
|
|
211
|
+
};
|
|
212
|
+
}
|