mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 22:20:51 +01:00
fix update vault name
This commit is contained in:
@ -8,9 +8,9 @@
|
|||||||
<div class="p-2">{{ t('design') }}</div>
|
<div class="p-2">{{ t('design') }}</div>
|
||||||
<div><UiDropdownTheme @select="onSelectThemeAsync" /></div>
|
<div><UiDropdownTheme @select="onSelectThemeAsync" /></div>
|
||||||
|
|
||||||
<div class="p-2">{{ t('vaultName') }}</div>
|
<div class="p-2">{{ t('vaultName.label') }}</div>
|
||||||
<div>
|
<div>
|
||||||
<UiInput v-model="currentVaultName" :placeholder="t('vaultName')">
|
<UiInput v-model="currentVaultName" :placeholder="t('vaultName.label')">
|
||||||
<template #append>
|
<template #append>
|
||||||
<UiTooltip :tooltip="t('save')">
|
<UiTooltip :tooltip="t('save')">
|
||||||
<UiButton class="btn-primary" @click="onSetVaultNameAsync">
|
<UiButton class="btn-primary" @click="onSetVaultNameAsync">
|
||||||
@ -38,27 +38,31 @@ const { currentVault, currentVaultName } = storeToRefs(useVaultStore())
|
|||||||
const { updateVaultNameAsync } = useVaultStore()
|
const { updateVaultNameAsync } = useVaultStore()
|
||||||
|
|
||||||
const onSelectLocaleAsync = async (locale: Locale) => {
|
const onSelectLocaleAsync = async (locale: Locale) => {
|
||||||
console.log('onSelectLocaleAsync', locale)
|
await currentVault.value?.drizzle
|
||||||
const update = await currentVault.value?.drizzle
|
|
||||||
.update(haexSettings)
|
.update(haexSettings)
|
||||||
.set({ key: 'locale', value: locale })
|
.set({ key: 'locale', value: locale })
|
||||||
.where(eq(haexSettings.key, 'locale'))
|
.where(eq(haexSettings.key, 'locale'))
|
||||||
await setLocale(locale)
|
await setLocale(locale)
|
||||||
console.log('update locale', update)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { currentTheme } = storeToRefs(useUiStore())
|
const { currentTheme } = storeToRefs(useUiStore())
|
||||||
|
|
||||||
const onSelectThemeAsync = async (theme: ITheme) => {
|
const onSelectThemeAsync = async (theme: ITheme) => {
|
||||||
const update = await currentVault.value?.drizzle
|
await currentVault.value?.drizzle
|
||||||
.update(haexSettings)
|
.update(haexSettings)
|
||||||
.set({ key: 'theme', value: theme.name })
|
.set({ key: 'theme', value: theme.name })
|
||||||
.where(eq(haexSettings.key, 'theme'))
|
.where(eq(haexSettings.key, 'theme'))
|
||||||
currentTheme.value = theme
|
currentTheme.value = theme
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSetVaultNameAsync = async (vaultName: string) => {
|
const { add } = useSnackbar()
|
||||||
updateVaultNameAsync(vaultName)
|
const onSetVaultNameAsync = async () => {
|
||||||
|
try {
|
||||||
|
await updateVaultNameAsync(currentVaultName.value)
|
||||||
|
add({ text: t('vaultName.update.success'), type: 'success' })
|
||||||
|
} catch (error) {
|
||||||
|
add({ text: t('vaultName.update.error'), type: 'error' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -66,12 +70,19 @@ const onSetVaultNameAsync = async (vaultName: string) => {
|
|||||||
de:
|
de:
|
||||||
language: Sprache
|
language: Sprache
|
||||||
design: Design
|
design: Design
|
||||||
vaultName: Vaultname
|
|
||||||
save: Änderung speichern
|
save: Änderung speichern
|
||||||
|
vaultName:
|
||||||
|
label: Vaultname
|
||||||
|
update:
|
||||||
|
success: Vaultname erfolgreich aktualisiert
|
||||||
|
error: Vaultname konnte nicht aktualisiert werden
|
||||||
en:
|
en:
|
||||||
language: Language
|
language: Language
|
||||||
design: Design
|
design: Design
|
||||||
vaultName: Vault Name
|
|
||||||
save: save changes
|
save: save changes
|
||||||
|
vaultName:
|
||||||
|
label: Vault Name
|
||||||
|
update:
|
||||||
|
success: Vault Name successfully updated
|
||||||
|
error: Vault name could not be updated
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import * as schema from "@/../src-tauri/database/schemas/vault";
|
import * as schema from "@/../src-tauri/database/schemas/vault";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { hostname, platform, type, version } from "@tauri-apps/plugin-os";
|
import { platform } from "@tauri-apps/plugin-os";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { drizzle, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
import { drizzle, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
||||||
|
|
||||||
@ -45,16 +45,9 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
|||||||
|
|
||||||
const openVaults = ref<IOpenVaults>({});
|
const openVaults = ref<IOpenVaults>({});
|
||||||
|
|
||||||
const currentVault = computed(() => openVaults.value?.[currentVaultId.value ?? ""]) //ref<IVault>();
|
const currentVault = computed(() => openVaults.value?.[currentVaultId.value ?? ""])
|
||||||
|
|
||||||
/* watch(
|
|
||||||
currentVaultId,
|
|
||||||
() => {
|
|
||||||
currentVault.value = openVaults.value?.[currentVaultId.value ?? ""];
|
|
||||||
}
|
|
||||||
); */
|
|
||||||
|
|
||||||
const hostKey = computedAsync(async () => "".concat(type(), version(), await hostname() ?? ""))
|
|
||||||
|
|
||||||
const openAsync = async ({ path = "", password }: { path: string; password: string }) => {
|
const openAsync = async ({ path = "", password }: { path: string; password: string }) => {
|
||||||
try {
|
try {
|
||||||
@ -213,6 +206,7 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updateVaultNameAsync = async (newVaultName?: string | null) => {
|
const updateVaultNameAsync = async (newVaultName?: string | null) => {
|
||||||
|
console.log("set new vaultName", newVaultName)
|
||||||
return currentVault.value?.drizzle.update(schema.haexSettings).set({ value: newVaultName ?? defaultVaultName.value }).where(eq(schema.haexSettings.key, "vaultName"))
|
return currentVault.value?.drizzle.update(schema.haexSettings).set({ value: newVaultName ?? defaultVaultName.value }).where(eq(schema.haexSettings.key, "vaultName"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +216,6 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
|||||||
currentVault,
|
currentVault,
|
||||||
currentVaultId,
|
currentVaultId,
|
||||||
currentVaultName,
|
currentVaultName,
|
||||||
hostKey,
|
|
||||||
openAsync,
|
openAsync,
|
||||||
openVaults,
|
openVaults,
|
||||||
read_only,
|
read_only,
|
||||||
|
|||||||
Reference in New Issue
Block a user