@7365admin1/layer-common 4.97.1-staging.527 → 4.97.1-staging.529
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.
|
@@ -392,6 +392,60 @@
|
|
|
392
392
|
</v-row>
|
|
393
393
|
</v-window-item>
|
|
394
394
|
|
|
395
|
+
<!-- ─── Tab 6: Apps ───────────────────────────────────── -->
|
|
396
|
+
<!--
|
|
397
|
+
Which apps offer the entry pass at this site. `accessDoor` above says
|
|
398
|
+
whether the site offers QR and Bluetooth at all; these say which apps
|
|
399
|
+
may show them, so the two compose - turning QR off up there hides it
|
|
400
|
+
everywhere regardless of what is switched on here.
|
|
401
|
+
-->
|
|
402
|
+
<v-window-item value="apps">
|
|
403
|
+
<v-row no-gutters class="px-6 pt-4">
|
|
404
|
+
<v-col cols="12">
|
|
405
|
+
<div class="mt-3 pb-5">
|
|
406
|
+
<p class="font-weight-medium mb-1">Entry Pass Apps</p>
|
|
407
|
+
<p class="text-caption text-medium-emphasis mb-4">
|
|
408
|
+
Turn an app off to hide Entry Pass QR Code and Entry Pass
|
|
409
|
+
Bluetooth from it. Everything else in that app is unaffected.
|
|
410
|
+
</p>
|
|
411
|
+
|
|
412
|
+
<template v-for="group in entrypassAppGroups" :key="group.name">
|
|
413
|
+
<p class="text-caption text-uppercase text-medium-emphasis mt-4 mb-1">
|
|
414
|
+
{{ group.name }}
|
|
415
|
+
</p>
|
|
416
|
+
<div
|
|
417
|
+
v-for="app in group.apps"
|
|
418
|
+
:key="app.value"
|
|
419
|
+
class="d-flex align-center py-3 pr-5 entrypass-app-row"
|
|
420
|
+
>
|
|
421
|
+
<span class="flex-grow-1 font-weight-medium">{{ app.label }}</span>
|
|
422
|
+
<v-switch
|
|
423
|
+
:data-testid="`entrypass-app-${app.value}`"
|
|
424
|
+
color="success"
|
|
425
|
+
hide-details
|
|
426
|
+
v-model="currentEntryPassSettings.accessApps[app.value]"
|
|
427
|
+
/>
|
|
428
|
+
</div>
|
|
429
|
+
</template>
|
|
430
|
+
|
|
431
|
+
<v-row class="mt-4">
|
|
432
|
+
<v-col cols="12" md="3">
|
|
433
|
+
<v-btn
|
|
434
|
+
color="primary"
|
|
435
|
+
variant="flat"
|
|
436
|
+
prepend-icon="mdi-content-save"
|
|
437
|
+
block
|
|
438
|
+
@click="saveAccessAppsSettings()"
|
|
439
|
+
>
|
|
440
|
+
Save
|
|
441
|
+
</v-btn>
|
|
442
|
+
</v-col>
|
|
443
|
+
</v-row>
|
|
444
|
+
</div>
|
|
445
|
+
</v-col>
|
|
446
|
+
</v-row>
|
|
447
|
+
</v-window-item>
|
|
448
|
+
|
|
395
449
|
<!-- ─── Tab 5: Self-Service ───────────────────────────── -->
|
|
396
450
|
<v-window-item value="onboarding">
|
|
397
451
|
<v-row no-gutters class="px-6 pt-4">
|
|
@@ -615,6 +669,7 @@ const entryPassTabs = [
|
|
|
615
669
|
{ value: "printer", label: "Printer", icon: "mdi-printer" },
|
|
616
670
|
{ value: "entrypass", label: "Entrypass", icon: "mdi-link-variant" },
|
|
617
671
|
{ value: "onboarding", label: "Self-Service", icon: "mdi-account-multiple-check-outline" },
|
|
672
|
+
{ value: "apps", label: "Apps", icon: "mdi-cellphone-cog" },
|
|
618
673
|
];
|
|
619
674
|
|
|
620
675
|
const currentEntryPassSettings = ref<Record<string, any>>({
|
|
@@ -631,6 +686,8 @@ const currentEntryPassSettings = ref<Record<string, any>>({
|
|
|
631
686
|
keyPass: false,
|
|
632
687
|
accessDoorQrCode: false,
|
|
633
688
|
accessDoorBluetooth: false,
|
|
689
|
+
// Every app explicit, so a save can never switch one off by omitting it.
|
|
690
|
+
accessApps: entrypassAppsPayload(null),
|
|
634
691
|
printerVendorId: "",
|
|
635
692
|
printerProductId: "",
|
|
636
693
|
qrCodeTemplateHeader: "",
|
|
@@ -819,6 +876,9 @@ watchEffect(() => {
|
|
|
819
876
|
keyPass: data.settings?.keyPass ?? false,
|
|
820
877
|
accessDoorQrCode: data.settings?.accessDoor?.qrCode ?? false,
|
|
821
878
|
accessDoorBluetooth: data.settings?.accessDoor?.bluetooth ?? false,
|
|
879
|
+
// Absent means on, so a site that has never opened this tab shows every
|
|
880
|
+
// app enabled rather than every app off.
|
|
881
|
+
accessApps: entrypassAppsPayload(data.settings?.accessApps),
|
|
822
882
|
printerVendorId: data.settings?.printer?.vendorId ? String(data.settings.printer.vendorId) : "",
|
|
823
883
|
printerProductId: data.settings?.printer?.productId ? String(data.settings.printer.productId) : "",
|
|
824
884
|
qrCodeTemplateHeader: data.settings?.qrTemplate?.header ?? "",
|
|
@@ -863,6 +923,7 @@ function buildPayload() {
|
|
|
863
923
|
qrCode: currentEntryPassSettings.value.accessDoorQrCode,
|
|
864
924
|
bluetooth: currentEntryPassSettings.value.accessDoorBluetooth,
|
|
865
925
|
},
|
|
926
|
+
accessApps: entrypassAppsPayload(currentEntryPassSettings.value.accessApps),
|
|
866
927
|
printer: {
|
|
867
928
|
vendorId: Number(currentEntryPassSettings.value.printerVendorId) || null,
|
|
868
929
|
productId: Number(currentEntryPassSettings.value.printerProductId) || null,
|
|
@@ -913,6 +974,23 @@ async function saveAccessDoorSettings() {
|
|
|
913
974
|
getSiteEntryPassSettings();
|
|
914
975
|
}
|
|
915
976
|
|
|
977
|
+
/** The switches, in the two groups the tab shows them under. */
|
|
978
|
+
const entrypassAppGroups = computed(() => {
|
|
979
|
+
const groups: { name: string; apps: typeof ENTRYPASS_APPS[number][] }[] = [];
|
|
980
|
+
for (const app of ENTRYPASS_APPS) {
|
|
981
|
+
const existing = groups.find((g) => g.name === app.group);
|
|
982
|
+
if (existing) existing.apps.push(app);
|
|
983
|
+
else groups.push({ name: app.group, apps: [app] });
|
|
984
|
+
}
|
|
985
|
+
return groups;
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
async function saveAccessAppsSettings() {
|
|
989
|
+
await _save(buildPayload());
|
|
990
|
+
showMessage("App settings saved successfully!", "success");
|
|
991
|
+
getSiteEntryPassSettings();
|
|
992
|
+
}
|
|
993
|
+
|
|
916
994
|
async function savePrinterSettings() {
|
|
917
995
|
await _save(buildPayload());
|
|
918
996
|
showMessage("Printer settings saved successfully!", "success");
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
"Open HERO Fleet Core" (web only, owner 2026-10-09: Super Admin + Property
|
|
4
|
+
Management). Shown only when the server says this account may open the
|
|
5
|
+
console (`?check=1` answered 200) - 404 where Fleet Core is not set up and
|
|
6
|
+
403 for everyone else keep it hidden. The pass is fetched on click only.
|
|
7
|
+
-->
|
|
8
|
+
<v-btn
|
|
9
|
+
v-if="available"
|
|
10
|
+
size="small"
|
|
11
|
+
variant="tonal"
|
|
12
|
+
color="primary"
|
|
13
|
+
prepend-icon="mdi-open-in-new"
|
|
14
|
+
:loading="opening"
|
|
15
|
+
@click="open"
|
|
16
|
+
>
|
|
17
|
+
Open HERO Fleet Core
|
|
18
|
+
</v-btn>
|
|
19
|
+
<span v-if="failed" class="hero-tag hero-tag--neutral" role="status">Could not open HERO Fleet Core. Try again.</span>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { onMounted, ref } from "vue";
|
|
24
|
+
import { openFleetCoreConsole } from "../../utils/robot-fleet-core";
|
|
25
|
+
|
|
26
|
+
const { getFleetCoreSession } = useRobots();
|
|
27
|
+
const available = ref(false);
|
|
28
|
+
const opening = ref(false);
|
|
29
|
+
const failed = ref(false);
|
|
30
|
+
|
|
31
|
+
onMounted(async () => {
|
|
32
|
+
try {
|
|
33
|
+
available.value = (await getFleetCoreSession({ check: true }))?.available === true;
|
|
34
|
+
} catch {
|
|
35
|
+
available.value = false;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
async function open() {
|
|
40
|
+
opening.value = true;
|
|
41
|
+
failed.value = false;
|
|
42
|
+
failed.value = !(await openFleetCoreConsole(
|
|
43
|
+
() => getFleetCoreSession(),
|
|
44
|
+
() => window.open("", "_blank") as any,
|
|
45
|
+
));
|
|
46
|
+
opening.value = false;
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
</div>
|
|
36
36
|
<span class="hero-head__spacer" />
|
|
37
37
|
<div class="hero-header__right">
|
|
38
|
+
<RobotFleetCoreButton />
|
|
38
39
|
<RobotLiveIndicator :connected="connected" />
|
|
39
40
|
<span class="hero-tag hero-tag--neutral">{{ role }}</span>
|
|
40
41
|
</div>
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
<script setup lang="ts">
|
|
46
47
|
import RobotMark from "./Mark.vue";
|
|
47
48
|
import RobotLiveIndicator from "./LiveIndicator.vue";
|
|
49
|
+
import RobotFleetCoreButton from "./FleetCoreButton.vue";
|
|
48
50
|
import { typeLabel, type TRobotType } from "../../utils/robot-display";
|
|
49
51
|
|
|
50
52
|
withDefaults(
|
package/composables/useRobots.ts
CHANGED
|
@@ -400,6 +400,18 @@ export default function useRobots() {
|
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
+
/**
|
|
404
|
+
* HERO Fleet Core sign-in pass (web only): `{ url: "<console>/#token=...", expiresAt }`.
|
|
405
|
+
* `check: true` only asks whether this account may open the console (mints nothing).
|
|
406
|
+
* 404 where Fleet Core is not set up, 403 for anyone but Super Admin / Property Management.
|
|
407
|
+
*/
|
|
408
|
+
function getFleetCoreSession({ check = false }: { check?: boolean } = {}) {
|
|
409
|
+
return useNuxtApp().$api<{ url?: string; expiresAt?: string; available?: boolean }>("/api/robots/fleet-core/session", {
|
|
410
|
+
method: "GET",
|
|
411
|
+
query: check ? { check: "1" } : {},
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
403
415
|
/* ------------------------------------------ alerts + activity log */
|
|
404
416
|
|
|
405
417
|
/**
|
|
@@ -566,6 +578,7 @@ export default function useRobots() {
|
|
|
566
578
|
listBuildingMaps,
|
|
567
579
|
listSiteBuildingMaps,
|
|
568
580
|
getFleetCoreBuilding,
|
|
581
|
+
getFleetCoreSession,
|
|
569
582
|
getSiteFaults,
|
|
570
583
|
getSiteActivity,
|
|
571
584
|
getNetworkActivity,
|
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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.529",
|
|
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.",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHICH APPS OFFER THE ENTRY PASS, PER SITE.
|
|
3
|
+
*
|
|
4
|
+
* `settings.accessDoor.{qrCode,bluetooth}` already says whether a site offers
|
|
5
|
+
* QR or Bluetooth at all, but it says it for every app at once. A site that
|
|
6
|
+
* wants its M&E crew on the entry pass and its landscapers not had no way to
|
|
7
|
+
* say so — the two methods were all-or-nothing across the estate.
|
|
8
|
+
*
|
|
9
|
+
* `settings.accessApps` is that second axis: one switch per app, read by the
|
|
10
|
+
* app itself to decide whether to offer Entry Pass QR Code and Entry Pass
|
|
11
|
+
* Bluetooth at all. The two compose — a method still has to be on for the site
|
|
12
|
+
* before any app can show it.
|
|
13
|
+
*
|
|
14
|
+
* ## Keyed by SERVICE CODE, not app name
|
|
15
|
+
*
|
|
16
|
+
* `cleaning_services`, not `hygiene`. The codes are what `/api/service-providers`
|
|
17
|
+
* and `members` already speak, so a site's providers line up with the switches
|
|
18
|
+
* without a translation table in between. The label is where "Hygiene" lives,
|
|
19
|
+
* because that is what the app is called — `serviceTypeLabel` deliberately says
|
|
20
|
+
* "Cleaning" for the same code elsewhere, and both names are correct in their
|
|
21
|
+
* own screen.
|
|
22
|
+
*
|
|
23
|
+
* `ma` is the odd one out: the MA app is the management app, not a service
|
|
24
|
+
* provider, so it has no service code of its own.
|
|
25
|
+
*
|
|
26
|
+
* ## MISSING MEANS ON
|
|
27
|
+
*
|
|
28
|
+
* No site has this field, so a closed default would switch the entry pass off
|
|
29
|
+
* for every app in every estate the moment it shipped. Absent, `null`, a
|
|
30
|
+
* non-object, an unknown key and every value that is not exactly `false` mean
|
|
31
|
+
* the app offers it — the same rule `accessDoor` and the resident app's module
|
|
32
|
+
* switches already follow. Only a switch somebody deliberately turned off
|
|
33
|
+
* hides anything.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** The app each switch governs. `value` is stored; `label` is only shown. */
|
|
37
|
+
export const ENTRYPASS_APPS: readonly {
|
|
38
|
+
value: string;
|
|
39
|
+
label: string;
|
|
40
|
+
group: "Management" | "Service Providers";
|
|
41
|
+
}[] = Object.freeze([
|
|
42
|
+
{ value: "ma", label: "MA App", group: "Management" },
|
|
43
|
+
{ value: "mechanical_electrical_services", label: "M&E", group: "Service Providers" },
|
|
44
|
+
{ value: "cleaning_services", label: "Hygiene", group: "Service Providers" },
|
|
45
|
+
{ value: "pool_maintenance_services", label: "Pool Maintenance", group: "Service Providers" },
|
|
46
|
+
{ value: "pest_control_services", label: "Pest Control", group: "Service Providers" },
|
|
47
|
+
{ value: "landscaping_services", label: "Landscape", group: "Service Providers" },
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
export type EntrypassApps = Partial<Record<string, boolean>>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Does this app offer the entry pass at this site?
|
|
54
|
+
*
|
|
55
|
+
* Fails open on every uncertainty, so a site that has never been configured —
|
|
56
|
+
* which is all of them until somebody opens the tab — behaves exactly as it
|
|
57
|
+
* does today.
|
|
58
|
+
*/
|
|
59
|
+
export function isEntrypassAppEnabled(
|
|
60
|
+
accessApps: EntrypassApps | null | undefined,
|
|
61
|
+
app: string,
|
|
62
|
+
): boolean {
|
|
63
|
+
if (!accessApps || typeof accessApps !== "object" || Array.isArray(accessApps)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return (accessApps as Record<string, unknown>)[app] !== false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every switch written out explicitly, so a save can never turn one off by omission. */
|
|
70
|
+
export function entrypassAppsPayload(
|
|
71
|
+
current: EntrypassApps | null | undefined,
|
|
72
|
+
): Record<string, boolean> {
|
|
73
|
+
return Object.fromEntries(
|
|
74
|
+
ENTRYPASS_APPS.map(({ value }) => [value, isEntrypassAppEnabled(current, value)]),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -55,3 +55,41 @@ export function fleetLiftItems(map: Record<string, any> | null | undefined, rows
|
|
|
55
55
|
};
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
/* ---- "Open HERO Fleet Core" (web only, owner 2026-10-09) ---------------- */
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Is this a console URL we may open? https, and the pass in the fragment
|
|
63
|
+
* (`#token=`) - the only form the console reads, and one no server ever logs.
|
|
64
|
+
*/
|
|
65
|
+
export function isFleetCoreConsoleUrl(url: unknown): url is string {
|
|
66
|
+
if (typeof url !== "string") return false;
|
|
67
|
+
try {
|
|
68
|
+
const u = new URL(url);
|
|
69
|
+
return u.protocol === "https:" && /^#token=[\w-]+\.[\w-]+\.[\w-]+$/.test(u.hash);
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Open the console in a new tab. The tab is opened BEFORE the pass is fetched
|
|
77
|
+
* (inside the click), so popup blockers allow it; it is then pointed at the
|
|
78
|
+
* console, or closed if no pass came back. Returns false when it failed.
|
|
79
|
+
*/
|
|
80
|
+
export async function openFleetCoreConsole(
|
|
81
|
+
getSession: () => Promise<{ url?: unknown } | null | undefined>,
|
|
82
|
+
openTab: () => { location: { href: string }; opener: unknown; close: () => void } | null,
|
|
83
|
+
): Promise<boolean> {
|
|
84
|
+
const tab = openTab();
|
|
85
|
+
if (tab) tab.opener = null; // the console never gets a handle on this app
|
|
86
|
+
try {
|
|
87
|
+
const session = await getSession();
|
|
88
|
+
if (!tab || !isFleetCoreConsoleUrl(session?.url)) throw new Error("no pass");
|
|
89
|
+
tab.location.href = session!.url as string;
|
|
90
|
+
return true;
|
|
91
|
+
} catch {
|
|
92
|
+
tab?.close();
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|