diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue
index 6681246..2e214a7 100644
--- a/ui/src/components/admin/ConfigView.vue
+++ b/ui/src/components/admin/ConfigView.vue
@@ -139,12 +139,15 @@
Zugangsdaten
-
+
user
- {{ dav_credentials[0] }}
+ {{ creds.dav[0] }}
pass
- {{ dav_credentials[1] }}
+ {{ creds.dav[1] }}
@@ -167,12 +170,15 @@
UI-Admin
-
+
user
- {{ ui_credentials[0] }}
+ {{ creds.ui[0] }}
pass
- {{ ui_credentials[1] }}
+ {{ creds.ui[1] }}
@@ -237,8 +243,10 @@ const admin_config_model = ref({
});
const doors = ref([]);
-const dav_credentials = ref(["", ""]);
-const ui_credentials = ref(["", ""]);
+const creds = ref>({
+ dav: ["", ""],
+ ui: ["", ""],
+});
function fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
const iso_date = admin_config_model.value.puzzle[name];
@@ -257,22 +265,24 @@ async function on_open(): Promise {
void store_update; // discard value
admin_config_model.value = new_admin_config_model;
doors.value = new_doors;
+ creds.value = { dav: ["", ""], ui: ["", ""] };
}
-async function load_dav_credentials(): Promise {
+async function load_credentials(
+ creds: Credentials,
+ endpoint: string,
+): Promise {
try {
- dav_credentials.value = await API.request(
- "admin/dav_credentials",
- );
+ const new_creds = await API.request(endpoint);
+
+ creds[0] = new_creds[0];
+ creds[1] = new_creds[1];
} catch {}
}
-async function load_ui_credentials(): Promise {
- try {
- ui_credentials.value = await API.request(
- "admin/ui_credentials",
- );
- } catch {}
+function clear_credentials(creds: Credentials): void {
+ creds[0] = "";
+ creds[1] = "";
}
diff --git a/ui/src/components/bulma/Secret.vue b/ui/src/components/bulma/Secret.vue
index c51b80e..c596488 100644
--- a/ui/src/components/bulma/Secret.vue
+++ b/ui/src/components/bulma/Secret.vue
@@ -4,8 +4,8 @@
***
@@ -16,24 +16,37 @@ import { computed, ref } from "vue";
import BulmaButton from "./Button.vue";
const emit = defineEmits<{
- (event: "load"): void;
+ (event: "show"): void;
+ (event: "hide"): void;
}>();
-type State = "hidden" | "clicked" | "visible";
+type State = "hidden" | "pending" | "visible";
const state = ref("hidden");
const state_map: Record = {
- hidden: { color: "primary", icon: "eye-slash", next: "clicked" },
- clicked: { color: "warning", icon: "eye-slash", next: "visible" },
+ hidden: { color: "primary", icon: "eye-slash", next: "pending" },
+ pending: { color: "warning", icon: "eye-slash", next: "visible" },
visible: { color: "danger", icon: "eye", next: "hidden" },
} as const;
const record = computed(() => state_map[state.value] ?? state_map.hidden);
+let pending_timeout: number | undefined;
+
function on_click(): void {
state.value = record.value.next;
+ if (state.value === "hidden") {
+ emit("hide");
+ }
+
+ if (state.value === "pending") {
+ pending_timeout = window.setTimeout(() => (state.value = "hidden"), 2500);
+ } else {
+ window.clearTimeout(pending_timeout);
+ }
+
if (state.value === "visible") {
- emit("load");
+ emit("show");
}
}