From 5a115e33e38bb97553215856575fa38c4ffd17b1 Mon Sep 17 00:00:00 2001 From: Bernd Storath <999999bst@gmail.com> Date: Fri, 14 Feb 2025 15:21:55 +0100 Subject: [PATCH] fix even more stuff --- src/app/app.vue | 3 ++ src/app/components/Base/Dialog.vue | 3 +- src/app/components/ClientCard/OneTimeLink.vue | 44 +++++++++++++++--- .../components/ClientCard/OneTimeLinkBtn.vue | 40 +++++++---------- src/app/components/ClientCard/QRCode.vue | 4 +- src/app/components/ClientCard/Switch.vue | 45 ++++++++++++------- src/app/components/Form/DateField.vue | 4 +- src/app/components/Form/Label.vue | 9 ++++ src/app/components/Form/NullTextField.vue | 4 +- src/app/components/Form/NumberField.vue | 4 +- src/app/components/Form/PasswordField.vue | 4 +- src/app/components/Form/SwitchField.vue | 4 +- src/app/components/Form/TextField.vue | 4 +- src/app/components/Icons/Link.vue | 15 +++++++ src/app/components/Ui/Footer.vue | 3 +- src/app/pages/setup/4.vue | 2 +- src/app/stores/global.ts | 21 +-------- src/server/utils/Database.ts | 1 - src/server/utils/WireGuard.ts | 4 +- src/server/utils/types.ts | 2 - 20 files changed, 133 insertions(+), 87 deletions(-) create mode 100644 src/app/components/Form/Label.vue create mode 100644 src/app/components/Icons/Link.vue diff --git a/src/app/app.vue b/src/app/app.vue index 9ce499e4..9991e288 100644 --- a/src/app/app.vue +++ b/src/app/app.vue @@ -16,6 +16,9 @@ const toast = useToast(); const toastRef = useTemplateRef('toastRef'); toast.setToast(toastRef); +// make sure to fetch release early +useGlobalStore(); + useHead({ bodyAttrs: { class: 'bg-gray-50 dark:bg-neutral-800', diff --git a/src/app/components/Base/Dialog.vue b/src/app/components/Base/Dialog.vue index 040d0f01..eea4fa56 100644 --- a/src/app/components/Base/Dialog.vue +++ b/src/app/components/Base/Dialog.vue @@ -3,7 +3,7 @@ diff --git a/src/app/components/ClientCard/OneTimeLink.vue b/src/app/components/ClientCard/OneTimeLink.vue index 7e3d142c..b14c5aa0 100644 --- a/src/app/components/ClientCard/OneTimeLink.vue +++ b/src/app/components/ClientCard/OneTimeLink.vue @@ -7,11 +7,45 @@ diff --git a/src/app/components/ClientCard/OneTimeLinkBtn.vue b/src/app/components/ClientCard/OneTimeLinkBtn.vue index 31e77b8d..e3ff7e3f 100644 --- a/src/app/components/ClientCard/OneTimeLinkBtn.vue +++ b/src/app/components/ClientCard/OneTimeLinkBtn.vue @@ -2,37 +2,31 @@ diff --git a/src/app/components/ClientCard/QRCode.vue b/src/app/components/ClientCard/QRCode.vue index 11831c4f..3f3b1f2e 100644 --- a/src/app/components/ClientCard/QRCode.vue +++ b/src/app/components/ClientCard/QRCode.vue @@ -1,11 +1,11 @@ diff --git a/src/app/components/ClientCard/Switch.vue b/src/app/components/ClientCard/Switch.vue index ab5fc1f4..60e7b68a 100644 --- a/src/app/components/ClientCard/Switch.vue +++ b/src/app/components/ClientCard/Switch.vue @@ -17,22 +17,37 @@ const enabled = ref(props.client.enabled); const clientsStore = useClientsStore(); +const _disableClient = useSubmit( + `/api/client/${props.client.id}/disable`, + { + method: 'post', + }, + { + revert: async () => { + await clientsStore.refresh(); + }, + noSuccessToast: true, + } +); + +const _enableClient = useSubmit( + `/api/client/${props.client.id}/enable`, + { + method: 'post', + }, + { + revert: async () => { + await clientsStore.refresh(); + }, + noSuccessToast: true, + } +); + async function toggleClient() { - // Improve - try { - if (props.client.enabled) { - await $fetch(`/api/client/${props.client.id}/disable`, { - method: 'post', - }); - } else { - await $fetch(`/api/client/${props.client.id}/enable`, { - method: 'post', - }); - } - } catch (err) { - alert(err); - } finally { - clientsStore.refresh().catch(console.error); + if (props.client.enabled) { + await _disableClient(undefined); + } else { + await _enableClient(undefined); } } diff --git a/src/app/components/Form/DateField.vue b/src/app/components/Form/DateField.vue index 7b5e0248..a82d21a6 100644 --- a/src/app/components/Form/DateField.vue +++ b/src/app/components/Form/DateField.vue @@ -1,7 +1,7 @@ diff --git a/src/app/components/Form/Label.vue b/src/app/components/Form/Label.vue new file mode 100644 index 00000000..edb8a8c5 --- /dev/null +++ b/src/app/components/Form/Label.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/app/components/Form/NullTextField.vue b/src/app/components/Form/NullTextField.vue index 6493032a..7a97e7b2 100644 --- a/src/app/components/Form/NullTextField.vue +++ b/src/app/components/Form/NullTextField.vue @@ -1,8 +1,8 @@