198 lines
6.8 KiB
Vue
198 lines
6.8 KiB
Vue
<template>
|
|
<form class="preferences-form" @submit="updateSettings">
|
|
<section class="card settings-section account-summary">
|
|
<div class="account-identity">
|
|
<AccountAvatar :user="authStore.user" />
|
|
<div>
|
|
<h2>{{ authStore.user?.profileName || authStore.user?.username }}</h2>
|
|
<p>{{ authStore.user?.email || authStore.user?.username }}</p>
|
|
</div>
|
|
</div>
|
|
<a
|
|
v-if="!noAuth"
|
|
class="button account-management"
|
|
:href="baseURL + '/auth/account'"
|
|
>{{ t("preferences.manage") }}<AppIcon name="north_east"
|
|
/></a>
|
|
</section>
|
|
<div class="settings-grid">
|
|
<section class="card settings-section">
|
|
<h2><AppIcon name="palette" />{{ t("preferences.appearance") }}</h2>
|
|
<label class="settings-field"
|
|
>{{ t("settings.themes.title")
|
|
}}<select
|
|
v-model="selectedTheme"
|
|
class="input"
|
|
@change="setTheme(selectedTheme)"
|
|
>
|
|
<option value="light">{{ t("settings.themes.light") }}</option>
|
|
<option value="dark">{{ t("settings.themes.dark") }}</option>
|
|
</select></label
|
|
>
|
|
<label class="settings-toggle"
|
|
><span>{{ t("settings.showPreviews") }}</span
|
|
><input type="checkbox" v-model="showPreviews"
|
|
/></label>
|
|
<label class="settings-toggle"
|
|
><span>{{ t("settings.hideDotfiles") }}</span
|
|
><input type="checkbox" v-model="hideDotfiles"
|
|
/></label>
|
|
</section>
|
|
<section class="card settings-section">
|
|
<h2><AppIcon name="mouse" />{{ t("preferences.behavior") }}</h2>
|
|
<label class="settings-toggle"
|
|
><span>{{ t("settings.singleClick") }}</span
|
|
><input type="checkbox" v-model="singleClick"
|
|
/></label>
|
|
<label class="settings-toggle"
|
|
><span>{{ t("settings.redirectAfterCopyMove") }}</span
|
|
><input type="checkbox" v-model="redirectAfterCopyMove"
|
|
/></label>
|
|
</section>
|
|
<section v-if="DICOM_3D_ENABLED" class="card settings-section">
|
|
<h2><AppIcon name="tune" />{{ t("preferences.dicom3D") }}</h2>
|
|
<label class="settings-field"
|
|
>{{ t("preferences.dicomQuality") }}
|
|
<select v-model="dicom3D.quality" class="input">
|
|
<option value="auto">{{ t("preferences.dicomAuto") }}</option>
|
|
<option value="original">
|
|
{{ t("preferences.dicomOriginal") }}
|
|
</option>
|
|
<option value="half">{{ t("preferences.dicomHalf") }}</option>
|
|
<option value="quarter">{{ t("preferences.dicomQuarter") }}</option>
|
|
</select>
|
|
</label>
|
|
<label class="settings-field"
|
|
>{{ t("preferences.dicomMemory") }}
|
|
<select v-model.number="dicom3D.memoryMiB" class="input">
|
|
<option
|
|
v-for="memory in [128, 256, 512, 1024, 1536]"
|
|
:key="memory"
|
|
:value="memory"
|
|
>
|
|
{{ memory }} MiB
|
|
</option>
|
|
</select>
|
|
</label>
|
|
<label class="settings-field"
|
|
>{{ t("preferences.dicomOpacity") }} ({{ dicom3D.opacity }}%)
|
|
<input
|
|
v-model.number="dicom3D.opacity"
|
|
class="input"
|
|
type="range"
|
|
min="5"
|
|
max="100"
|
|
step="5"
|
|
/>
|
|
</label>
|
|
<p class="settings-hint">{{ t("preferences.dicomHint") }}</p>
|
|
</section>
|
|
<section class="card settings-section">
|
|
<h2><AppIcon name="language" />{{ t("preferences.regional") }}</h2>
|
|
<label class="settings-field"
|
|
>{{ t("settings.language")
|
|
}}<Languages class="input" v-model:locale="locale"
|
|
/></label>
|
|
<label class="settings-toggle"
|
|
><span>{{ t("settings.setDateFormat") }}</span
|
|
><input type="checkbox" v-model="dateFormat"
|
|
/></label>
|
|
</section>
|
|
</div>
|
|
<div class="settings-save">
|
|
<button class="button" type="submit" :disabled="saving">
|
|
{{ t("buttons.save") }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { useAuthStore } from "@/stores/auth";
|
|
import { useLayoutStore } from "@/stores/layout";
|
|
import { users as api } from "@/api";
|
|
import Languages from "@/components/settings/Languages.vue";
|
|
import AccountAvatar from "@/components/AccountAvatar.vue";
|
|
import { baseURL, noAuth } from "@/utils/constants";
|
|
import { getTheme, getMediaPreference, setTheme } from "@/utils/theme";
|
|
import { dicomPreferences } from "@/utils/dicom-quality";
|
|
import { detectLocale } from "@/i18n";
|
|
import { DICOM_3D_ENABLED } from "@/utils/dicom-series";
|
|
import { inject, onMounted, ref } from "vue";
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
const layoutStore = useLayoutStore();
|
|
const authStore = useAuthStore();
|
|
const { t } = useI18n();
|
|
|
|
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
|
|
const $showError = inject<IToastError>("$showError")!;
|
|
|
|
const hideDotfiles = ref<boolean>(false);
|
|
const showPreviews = ref(true);
|
|
const singleClick = ref<boolean>(false);
|
|
const redirectAfterCopyMove = ref<boolean>(false);
|
|
const dateFormat = ref<boolean>(false);
|
|
const locale = ref<string>("");
|
|
const selectedTheme = ref<UserTheme>(getTheme() || getMediaPreference());
|
|
const saving = ref(false);
|
|
const dicom3D = ref(dicomPreferences());
|
|
|
|
onMounted(async () => {
|
|
layoutStore.loading = true;
|
|
if (authStore.user === null) {
|
|
layoutStore.loading = false;
|
|
return false;
|
|
}
|
|
locale.value = authStore.user.locale || detectLocale();
|
|
hideDotfiles.value = authStore.user.hideDotfiles;
|
|
showPreviews.value = !authStore.user.hidePreviews;
|
|
singleClick.value = authStore.user.singleClick;
|
|
redirectAfterCopyMove.value = authStore.user.redirectAfterCopyMove;
|
|
dateFormat.value = authStore.user.dateFormat;
|
|
dicom3D.value = dicomPreferences(authStore.user.dicom3D);
|
|
layoutStore.loading = false;
|
|
|
|
return true;
|
|
});
|
|
|
|
const updateSettings = async (event: Event) => {
|
|
event.preventDefault();
|
|
if (saving.value) return;
|
|
saving.value = true;
|
|
|
|
try {
|
|
if (authStore.user === null) throw new Error("User is not set!");
|
|
|
|
const data = {
|
|
...authStore.user,
|
|
id: authStore.user.id,
|
|
locale: locale.value,
|
|
hideDotfiles: hideDotfiles.value,
|
|
hidePreviews: !showPreviews.value,
|
|
singleClick: singleClick.value,
|
|
redirectAfterCopyMove: redirectAfterCopyMove.value,
|
|
dateFormat: dateFormat.value,
|
|
dicom3D: { ...dicom3D.value },
|
|
};
|
|
|
|
await api.update(data, [
|
|
"locale",
|
|
"hideDotfiles",
|
|
"hidePreviews",
|
|
"singleClick",
|
|
"redirectAfterCopyMove",
|
|
"dateFormat",
|
|
"dicom3D",
|
|
]);
|
|
authStore.updateUser(data);
|
|
$showSuccess(t("settings.settingsUpdated"));
|
|
} catch (err) {
|
|
if (err instanceof Error) {
|
|
$showError(err);
|
|
}
|
|
} finally {
|
|
saving.value = false;
|
|
}
|
|
};
|
|
</script>
|