@7365admin1/layer-common 4.35.1-staging.372 → 4.35.1-staging.373

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.
@@ -210,6 +210,23 @@
210
210
  Confirmed on the reader:
211
211
  <strong>{{ formatDate(selectedReader?.identificationMethodsAppliedAt) }}</strong>
212
212
  </p>
213
+
214
+ <!--
215
+ Its own action, not a save. A reader's settings can change without
216
+ us — a firmware update, its own touchscreen, a restore, a reset —
217
+ and saving only writes what is on screen. This reads the device
218
+ first and reports what had moved.
219
+ -->
220
+ <div class="dialog-actions-inline">
221
+ <AppButton
222
+ variant="ghost"
223
+ icon="mdi-sync"
224
+ :disabled="identificationReconciling || identificationSaving || !selectedReader?.identificationMethods"
225
+ @click="reapplyIdentificationMethods"
226
+ >
227
+ {{ identificationReconciling ? "Checking reader..." : "Re-apply settings" }}
228
+ </AppButton>
229
+ </div>
213
230
  </v-card-text>
214
231
 
215
232
  <v-card-text v-else class="reader-action-content">
@@ -229,14 +246,14 @@
229
246
  <v-spacer />
230
247
  <AppButton
231
248
  variant="ghost"
232
- :disabled="identificationSaving"
249
+ :disabled="identificationSaving || identificationReconciling"
233
250
  @click="identificationStage === 'confirm' ? (identificationStage = 'edit') : (identificationDialog = false)"
234
251
  >
235
252
  {{ identificationStage === "confirm" ? "Back" : "Cancel" }}
236
253
  </AppButton>
237
254
  <AppButton
238
255
  v-if="identificationStage === 'edit'"
239
- :disabled="!identificationChanged"
256
+ :disabled="!identificationChanged || identificationReconciling"
240
257
  @click="identificationStage = 'confirm'"
241
258
  >
242
259
  Save
@@ -472,6 +489,7 @@ const {
472
489
  setReaderMonitor,
473
490
  setReaderOperatingMode,
474
491
  setReaderIdentificationMethods,
492
+ reconcileReaderIdentificationMethods,
475
493
  getReaderUsers,
476
494
  } = useHidAmico();
477
495
 
@@ -493,6 +511,7 @@ const identificationDialog = ref(false);
493
511
  so it is never one click away. */
494
512
  const identificationStage = ref<"edit" | "confirm">("edit");
495
513
  const identificationSaving = ref(false);
514
+ const identificationReconciling = ref(false);
496
515
  const identificationForm = ref<{
497
516
  facial: boolean;
498
517
  card: boolean;
@@ -714,6 +733,79 @@ const identificationBeingDisabled = computed(() => {
714
733
  * reader would not take, and the controls must go back to what the device
715
734
  * actually holds rather than keeping the rejected choice on screen.
716
735
  */
736
+ /*
737
+ * What the device is actually holding, put back to what we hold for it.
738
+ *
739
+ * Worth a button of its own because drift has causes nobody here controls — a
740
+ * firmware update, somebody using the reader's own touchscreen, a restore, a
741
+ * reset. Saving the dialog only writes what is on screen; this reads the
742
+ * device first and reports what had moved.
743
+ */
744
+ async function reapplyIdentificationMethods() {
745
+ const readerId = String(selectedReader.value?._id || "");
746
+ if (!readerId) return;
747
+
748
+ const readerName = String(selectedReader.value?.name || "HID Reader");
749
+ identificationReconciling.value = true;
750
+ try {
751
+ const response = await reconcileReaderIdentificationMethods(readerId);
752
+ const result = (response?.data || response || {}) as HidRecord;
753
+ identificationDialog.value = false;
754
+ await loadReaders();
755
+ selectedReader.value = readers.value.find((reader) => String(reader._id) === readerId) || null;
756
+
757
+ const status = String(result.status || "");
758
+ const drifted = Array.isArray(result.drifted) ? result.drifted.map(String) : [];
759
+ if (status === "drift_corrected") {
760
+ showResult(
761
+ true,
762
+ "Settings Re-applied",
763
+ `${readerName} had drifted and has been put back. Corrected: ${drifted.map(identificationFieldLabel).join(", ")}.`,
764
+ { readerName },
765
+ );
766
+ } else if (status === "in_sync") {
767
+ showResult(true, "Settings Already Correct", `${readerName} matches what iService365 holds for it.`, { readerName });
768
+ } else if (status === "skipped" && result.reason === "duplicate_reader") {
769
+ // Not a failure to retry: the device is registered twice, and until a
770
+ // person removes one record both would fight over its configuration.
771
+ showResult(
772
+ false,
773
+ "Duplicate HID Reader",
774
+ `${readerName} shares a device with another registered reader. Remove or deactivate one of them before re-applying settings.`,
775
+ { readerName },
776
+ );
777
+ } else if (status === "skipped") {
778
+ showResult(
779
+ false,
780
+ "Nothing to Re-apply",
781
+ `No identification methods have been set for ${readerName} yet.`,
782
+ { readerName },
783
+ );
784
+ } else {
785
+ showResult(false, "Could Not Re-apply Settings", String(result.message || "The HID reader could not be reached."), { readerName });
786
+ }
787
+ } catch (error: unknown) {
788
+ console.error("Unable to reconcile HID identification methods:", error);
789
+ identificationDialog.value = false;
790
+ await loadReaders();
791
+ showResult(false, "Could Not Re-apply Settings", getFriendlyHidError(error), { readerName });
792
+ } finally {
793
+ identificationReconciling.value = false;
794
+ }
795
+ }
796
+
797
+ /** The reader's own field names, as the person in front of the door knows them. */
798
+ function identificationFieldLabel(field: string) {
799
+ const labels: Record<string, string> = {
800
+ face_identification_enabled: "Facial",
801
+ card_identification_enabled: "Card",
802
+ qrcode_identification_enabled: "QR code",
803
+ pin_identification_enabled: "Credential entry",
804
+ multi_factor_authentication: "Multi-factor",
805
+ };
806
+ return labels[field] || field;
807
+ }
808
+
717
809
  async function saveIdentificationMethods() {
718
810
  const readerId = String(selectedReader.value?._id || "");
719
811
  if (!readerId) return;
@@ -331,6 +331,20 @@ export default function useHidAmico() {
331
331
  );
332
332
  }
333
333
 
334
+ /**
335
+ * Put a reader back to the settings iService holds for it.
336
+ *
337
+ * A POST rather than a GET because it WRITES: reading the reader's
338
+ * configuration is only the first half, and anything that drifted is
339
+ * re-applied before this returns.
340
+ */
341
+ function reconcileReaderIdentificationMethods(readerId: string) {
342
+ return useNuxtApp().$api<HidApiRecord>(
343
+ `${basePath}/readers/${readerId}/identification-methods/reconcile`,
344
+ { method: "POST" },
345
+ );
346
+ }
347
+
334
348
  function getIdentities(readerId: string, query: HidApiRecord = {}) {
335
349
  return useNuxtApp().$api<HidApiRecord>(`${basePath}/readers/${readerId}/identities`, {
336
350
  method: "GET",
@@ -648,6 +662,7 @@ export default function useHidAmico() {
648
662
  getReaderConfiguration,
649
663
  setReaderConfiguration,
650
664
  setReaderIdentificationMethods,
665
+ reconcileReaderIdentificationMethods,
651
666
  getLogs,
652
667
  setUserImage,
653
668
  deleteUserImage,
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.35.1-staging.372",
5
+ "version": "4.35.1-staging.373",
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.",