@7365admin1/layer-common 4.97.1-staging.649 → 4.97.1-staging.651

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.
@@ -121,6 +121,26 @@
121
121
  <!-- Single Add Mode -->
122
122
  <v-form v-if="uploadMode === 'single'" v-model="validForm" :disabled="disable">
123
123
  <v-row no-gutters class="px-6 pt-4">
124
+ <v-col v-if="entryPassFailure" cols="12" class="px-1 pb-4">
125
+ <v-alert
126
+ :type="entryPassFailure.kind === 'not-set-up' ? 'warning' : 'error'"
127
+ variant="tonal"
128
+ density="comfortable"
129
+ data-test="entrypass-failure"
130
+ >
131
+ <div class="font-weight-bold">{{ entryPassFailure.title }}</div>
132
+ <div class="mt-1">{{ entryPassFailure.body }}</div>
133
+ <v-btn
134
+ class="mt-3 text-none"
135
+ size="small"
136
+ variant="outlined"
137
+ :loading="entryPassLoading"
138
+ @click="loadEntryPassLists"
139
+ >
140
+ Try again
141
+ </v-btn>
142
+ </v-alert>
143
+ </v-col>
124
144
  <v-col cols="12" class="px-1">
125
145
  <InputLabel
126
146
  class="text-capitalize font-weight-bold"
@@ -226,6 +246,8 @@
226
246
  item-value="no"
227
247
  hide-details
228
248
  :rules="[requiredRule]"
249
+ :loading="entryPassLoading"
250
+ :placeholder="entryPassLoading ? 'Loading from EntryPass…' : accessLevelItems.length ? '' : 'Not available'"
229
251
  >
230
252
  </v-select>
231
253
  </v-col>
@@ -244,6 +266,8 @@
244
266
  hide-details
245
267
  :rules="[requiredRule]"
246
268
  multiple
269
+ :loading="entryPassLoading"
270
+ :placeholder="entryPassLoading ? 'Loading from EntryPass…' : accessGroupItems.length ? '' : 'Not available'"
247
271
  >
248
272
  </v-select>
249
273
  </v-col>
@@ -423,6 +447,7 @@
423
447
  // Imported by name rather than left to auto-imports, the way
424
448
  // `VehicleBulkAddForm` reaches for `~/utils/phoneMasks`.
425
449
  import { normaliseCardNo, validateCardNo } from "~/utils/access-card-number";
450
+ import { describeEntryPassFailure, type EntryPassFailure } from "../utils/entrypass-failure";
426
451
 
427
452
  const prop = defineProps({
428
453
  mode: {
@@ -606,23 +631,57 @@ watch(uploadMode, (mode) => {
606
631
  if (mode === "bulk") fetchEntryPassTemplate();
607
632
  });
608
633
 
609
- onMounted(async () => {
634
+ // DV-0887: the dialog stays open and says which part failed (not set up, did
635
+ // not respond, or what EntryPass answered), with Try again, instead of one
636
+ // generic toast. A site with no EntryPass address is "not set up" here rather
637
+ // than using the default host. Lists that did load are kept.
638
+ const entryPassLoading = ref(true);
639
+ const entryPassFailure = ref<EntryPassFailure | null>(null);
640
+
641
+ async function loadEntryPassLists() {
642
+ entryPassLoading.value = true;
643
+ entryPassFailure.value = null;
610
644
  try {
611
- const acmUrl = await _getEncryptedAcmUrl(siteId);
645
+ let acmUrl = "";
646
+ try {
647
+ acmUrl = await _getEncryptedAcmUrl(siteId, { requireSiteUrl: true });
648
+ } catch (error) {
649
+ console.error("Failed to resolve the EntryPass address:", error);
650
+ entryPassFailure.value = describeEntryPassFailure(error);
651
+ return;
652
+ }
612
653
  encryptedAcmUrl.value = acmUrl;
613
- const [doorLevels, liftLevels, groups] = await Promise.all([
654
+
655
+ const [doorLevels, liftLevels, groups] = await Promise.allSettled([
614
656
  _getDoorAccessLevels(acmUrl),
615
657
  _getLiftAccessLevels(acmUrl),
616
658
  _getAccessGroups(acmUrl),
617
659
  ]);
618
- accessLevelItems.value = doorLevels.data ?? [];
619
- liftAccessLevelItems.value = liftLevels.data ?? [];
620
- accessGroupItems.value = groups.data ?? [];
621
- } catch (error) {
622
- console.error("Failed to fetch access management data:", error);
623
- emit("error", "EntryPass server is unavailable. Please contact your administrator.");
660
+ if (doorLevels.status === "fulfilled") accessLevelItems.value = doorLevels.value.data ?? [];
661
+ if (liftLevels.status === "fulfilled") liftAccessLevelItems.value = liftLevels.value.data ?? [];
662
+ if (groups.status === "fulfilled") accessGroupItems.value = groups.value.data ?? [];
663
+
664
+ const failed = (
665
+ [
666
+ [doorLevels, "door locations"],
667
+ [liftLevels, "lift access levels"],
668
+ [groups, "access groups"],
669
+ ] as const
670
+ ).filter(([result]) => result.status === "rejected");
671
+ if (!failed.length) return;
672
+
673
+ const firstError = (failed[0][0] as PromiseRejectedResult).reason;
674
+ console.error("Failed to fetch access management data:", firstError);
675
+ entryPassFailure.value = describeEntryPassFailure(
676
+ firstError,
677
+ failed.map(([, list]) => list),
678
+ );
679
+ } finally {
680
+ entryPassLoading.value = false;
624
681
  }
625
- });
682
+ }
683
+
684
+ onMounted(loadEntryPassLists);
626
685
 
627
686
  /** Mirrors what core accepts - see `utils/access-card-number.ts` for why. */
628
687
  const cardNoRule = (value: string | number | null | undefined) =>
@@ -194,6 +194,8 @@
194
194
  </v-card>
195
195
  </template>
196
196
  <script setup lang="ts">
197
+ import { describeEntryPassFailure, entryPassFailureToast } from "../utils/entrypass-failure";
198
+
197
199
  const props = defineProps({
198
200
  siteId: {
199
201
  type: String,
@@ -378,17 +380,17 @@ onMounted(async () => {
378
380
  ]);
379
381
  accessLevelItems.value = [NO_SELECTION, ...(doorLevels.data ?? [])];
380
382
  liftAccessLevelItems.value = [NO_SELECTION, ...(liftLevels.data ?? [])];
381
- } catch {
383
+ } catch (error) {
384
+ // DV-0887: say what failed rather than one generic message.
382
385
  emit(
383
386
  "error",
384
- "EntryPass server is unavailable. Please contact your administrator."
387
+ entryPassFailureToast(
388
+ describeEntryPassFailure(error, ["door locations", "lift access levels"])
389
+ )
385
390
  );
386
391
  }
387
392
  } else {
388
- emit(
389
- "error",
390
- "EntryPass server is unavailable. Please contact your administrator."
391
- );
393
+ emit("error", entryPassFailureToast(describeEntryPassFailure(acmResult.reason)));
392
394
  }
393
395
  levelsLoading.value = false;
394
396
  });
@@ -835,8 +835,9 @@ async function confirmAssign() {
835
835
  emit("refresh");
836
836
  } catch (e: any) {
837
837
  const rawMsg = e?.data?.message ?? "";
838
+ // DV-0887: EntryPass's own answer is shown rather than one generic message.
838
839
  const msg = rawMsg.includes("500")
839
- ? "EntryPass server is unavailable. Please contact your administrator."
840
+ ? `EntryPass could not assign the card. It answered: "${rawMsg}".`
840
841
  : rawMsg || "Failed to assign. Please try again.";
841
842
  assignError.value = msg;
842
843
  showToast(msg, "error");
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.649",
5
+ "version": "4.97.1-staging.651",
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.",