feat: refresh settings, sync account avatars and link account management

This commit is contained in:
SantaSpeen committed 2026-10-22 12:52:37 +03:00
1 parent fa1832dfa7
commit d3d164910b
22 files changed
+789 -407

No files matched your search

-1
View File
@@ -9,7 +9,6 @@
<button class="button sso-signin" @click="signIn">
<i class="material-icons">login</i>{{ $t("sso.signIn") }}
</button>
<small>{{ $t("sso.managed") }}</small>
</main>
</template>
<script setup lang="ts">
+23 -52
View File
@@ -1,66 +1,37 @@
<template>
<div class="dashboard">
<div class="dashboard settings-page">
<header-bar showMenu showLogo />
<div id="nav">
<div class="wrapper">
<ul>
<router-link to="/settings/profile"
><li :class="{ active: $route.path === '/settings/profile' }">
{{ t("settings.profileSettings") }}
</li></router-link
>
<router-link to="/settings/shares" v-if="user?.perm.share"
><li :class="{ active: $route.path === '/settings/shares' }">
{{ t("settings.shareManagement") }}
</li></router-link
>
<router-link to="/settings/global" v-if="user?.perm.admin"
><li :class="{ active: $route.path === '/settings/global' }">
{{ t("settings.globalSettings") }}
</li></router-link
>
<router-link to="/settings/users" v-if="user?.perm.admin"
><li
:class="{
active:
$route.path === '/settings/users' || $route.name === 'User',
}"
>
{{ t("settings.userManagement") }}
</li></router-link
>
</ul>
</div>
<div class="settings-page-heading">
<h1>{{ t("sidebar.settings") }}</h1>
</div>
<div v-if="loading">
<h2 class="message delayed">
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<span>{{ t("files.loading") }}</span>
</h2>
<div class="settings-tabs" :aria-label="t('sidebar.settings')">
<router-link to="/settings/profile"
><i class="material-icons">tune</i
>{{ t("settings.profileSettings") }}</router-link
>
<router-link v-if="authStore.user?.perm.share" to="/settings/shares"
><i class="material-icons">link</i
>{{ t("settings.shareManagement") }}</router-link
>
<router-link v-if="authStore.user?.perm.admin" to="/settings/global"
><i class="material-icons">dns</i
>{{ t("settings.globalSettings") }}</router-link
>
<router-link v-if="authStore.user?.perm.admin" to="/settings/users"
><i class="material-icons">group</i
>{{ t("settings.userManagement") }}</router-link
>
</div>
<router-view></router-view>
<p v-if="layout.loading" role="status">{{ t("files.loading") }}</p>
<router-view />
</div>
</template>
<script setup lang="ts">
import { useAuthStore } from "@/stores/auth";
import { useLayoutStore } from "@/stores/layout";
import HeaderBar from "@/components/header/HeaderBar.vue";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const authStore = useAuthStore();
const layoutStore = useLayoutStore();
const user = computed(() => authStore.user);
const loading = computed(() => layoutStore.loading);
const layout = useLayoutStore();
</script>
+119 -226
View File
@@ -1,233 +1,122 @@
<template>
<errors v-if="error" :errorCode="error.status" />
<div class="row" v-else-if="!layoutStore.loading && settings !== null">
<div class="column">
<form class="card" @submit.prevent="save">
<div class="card-title">
<h2>{{ t("settings.globalSettings") }}</h2>
</div>
<div class="card-content">
<p>
<input type="checkbox" v-model="settings.createUserDir" />
{{ t("settings.createUserDir") }}
</p>
<p>
<input type="checkbox" v-model="settings.hideLoginButton" />
{{ t("settings.hideLoginButton") }}
</p>
<p>
<label class="small">{{ t("settings.userHomeBasePath") }}</label>
<input
class="input input--block"
type="text"
v-model="settings.userHomeBasePath"
/>
</p>
<h3>{{ t("settings.rules") }}</h3>
<p class="small">{{ t("settings.globalRules") }}</p>
<rules v-model:rules="settings.rules" />
<div v-if="enableExec">
<h3>{{ t("settings.executeOnShell") }}</h3>
<p class="small">{{ t("settings.executeOnShellDescription") }}</p>
<input
class="input input--block"
type="text"
placeholder="bash -c, cmd /c, ..."
v-model="shellValue"
/>
</div>
<h3>{{ t("settings.branding") }}</h3>
<i18n-t
keypath="settings.brandingHelp"
tag="p"
class="small"
scope="global"
>
<a
class="link"
target="_blank"
href="https://github.com/filebrowser/filebrowser/blob/master/docs/customization.md#custom-branding"
>{{ t("settings.documentation") }}</a
>
</i18n-t>
<p>
<input
type="checkbox"
v-model="settings.branding.disableExternal"
id="branding-links"
/>
{{ t("settings.disableExternalLinks") }}
</p>
<p>
<input
type="checkbox"
v-model="settings.branding.disableUsedPercentage"
id="branding-used-disk"
/>
{{ t("settings.disableUsedDiskPercentage") }}
</p>
<p>
<label for="theme">{{ t("settings.themes.title") }}</label>
<themes
class="input input--block"
v-model:theme="settings.branding.theme"
id="theme"
></themes>
</p>
<p>
<label for="branding-name">{{ t("settings.instanceName") }}</label>
<input
class="input input--block"
type="text"
v-model="settings.branding.name"
id="branding-name"
/>
</p>
<p>
<label for="branding-files">{{
t("settings.brandingDirectoryPath")
}}</label>
<input
class="input input--block"
type="text"
v-model="settings.branding.files"
id="branding-files"
/>
</p>
<h3>{{ t("settings.tusUploads") }}</h3>
<p class="small">{{ t("settings.tusUploadsHelp") }}</p>
<div class="tusConditionalSettings">
<p>
<label for="tus-chunkSize">{{
t("settings.tusUploadsChunkSize")
}}</label>
<input
class="input input--block"
type="text"
v-model="formattedChunkSize"
id="tus-chunkSize"
/>
</p>
<p>
<label for="tus-retryCount">{{
t("settings.tusUploadsRetryCount")
}}</label>
<vue-number-input
controls
v-model.number="settings.tus.retryCount"
id="tus-retryCount"
:min="0"
/>
</p>
</div>
</div>
<div class="card-action">
<input
class="button button--flat"
type="submit"
:value="t('buttons.update')"
/>
</div>
</form>
</div>
<div class="column">
<form class="card" @submit.prevent="save">
<div class="card-title">
<h2>{{ t("settings.userDefaults") }}</h2>
</div>
<div class="card-content">
<p class="small">{{ t("settings.defaultUserDescription") }}</p>
<user-form
:isNew="false"
:isDefault="true"
v-model:user="settings.defaults"
/>
</div>
<div class="card-action">
<input
class="button button--flat"
type="submit"
:value="t('buttons.update')"
/>
</div>
</form>
</div>
<div class="column">
<form v-if="enableExec" class="card" @submit.prevent="save">
<div class="card-title">
<h2>{{ t("settings.commandRunner") }}</h2>
</div>
<div class="card-content">
<i18n-t
keypath="settings.commandRunnerHelp"
tag="p"
class="small"
scope="global"
>
<code>FILE</code>
<code>SCOPE</code>
<a
class="link"
target="_blank"
href="https://github.com/filebrowser/filebrowser/blob/master/docs/command-execution.md#hook-runner"
>{{ t("settings.documentation") }}</a
>
</i18n-t>
<div
v-for="(command, key) in settings.commands"
<form
v-else-if="!layoutStore.loading && settings"
class="preferences-form"
@submit.prevent="save"
>
<div class="settings-grid">
<section class="card settings-section">
<h2>
<i class="material-icons">palette</i>{{ t("preferences.appearance") }}
</h2>
<label class="settings-field"
>{{ t("settings.instanceName")
}}<input class="input" type="text" v-model="settings.branding.name"
/></label>
<label class="settings-field"
>{{ t("settings.themes.title")
}}<Themes class="input" v-model:theme="settings.branding.theme"
/></label>
<label class="settings-toggle"
><span>{{ t("settings.disableUsedDiskPercentage") }}</span
><input
type="checkbox"
v-model="settings.branding.disableUsedPercentage"
/></label>
</section>
<section class="card settings-section">
<h2>
<i class="material-icons">public</i>{{ t("preferences.publicPages") }}
</h2>
<label class="settings-toggle"
><span>{{ t("settings.hideLoginButton") }}</span
><input type="checkbox" v-model="settings.hideLoginButton"
/></label>
<label class="settings-toggle"
><span>{{ t("settings.disableExternalLinks") }}</span
><input type="checkbox" v-model="settings.branding.disableExternal"
/></label>
</section>
<section class="card settings-section">
<h2>
<i class="material-icons">folder_shared</i
>{{ t("preferences.homeFolders") }}
</h2>
<label class="settings-toggle"
><span>{{ t("settings.createUserDir") }}</span
><input type="checkbox" v-model="settings.createUserDir"
/></label>
<label class="settings-field"
>{{ t("settings.userHomeBasePath")
}}<input
class="input"
type="text"
v-model="settings.userHomeBasePath"
/></label>
</section>
<section class="card settings-section">
<h2>
<i class="material-icons">cloud_upload</i
>{{ t("settings.tusUploads") }}
</h2>
<label class="settings-field"
>{{ t("settings.tusUploadsChunkSize")
}}<input class="input" type="text" v-model="formattedChunkSize"
/></label>
<label class="settings-field"
>{{ t("settings.tusUploadsRetryCount")
}}<input
class="input"
type="number"
min="0"
max="1000"
v-model.number="settings.tus.retryCount"
/></label>
</section>
<section class="card settings-section settings-wide">
<h2>
<i class="material-icons">person_add</i
>{{ t("settings.userDefaults") }}
</h2>
<UserForm
:isNew="false"
:isDefault="true"
v-model:user="settings.defaults"
/>
</section>
<section class="card settings-section settings-wide">
<h2><i class="material-icons">policy</i>{{ t("settings.rules") }}</h2>
<p class="field-hint">{{ t("settings.globalRules") }}</p>
<Rules v-model:rules="settings.rules" />
</section>
<details class="card settings-section settings-wide">
<summary>{{ t("sso.advancedSettings") }}</summary>
<label class="settings-field"
>{{ t("settings.brandingDirectoryPath")
}}<input class="input" type="text" v-model="settings.branding.files"
/></label>
<template v-if="enableExec">
<label class="settings-field"
>{{ t("settings.executeOnShell")
}}<input class="input" type="text" v-model="shellValue"
/></label>
<h3>{{ t("settings.commandRunner") }}</h3>
<label
v-for="(_, key) in settings.commands"
:key="key"
class="collapsible"
>
<input :id="key" type="checkbox" />
<label :for="key">
<p>{{ capitalize(key) }}</p>
<i class="material-icons">arrow_drop_down</i>
</label>
<div class="collapse">
<textarea
class="input input--block input--textarea"
v-model.trim="commandObject[key]"
></textarea>
</div>
</div>
</div>
<div class="card-action">
<input
class="button button--flat"
type="submit"
:value="t('buttons.update')"
/>
</div>
</form>
class="settings-field"
>{{ capitalize(key)
}}<textarea class="input" v-model.trim="commandObject[key]" />
</label>
</template>
</details>
</div>
</div>
<div class="settings-save">
<button class="button" :disabled="saving">{{ t("buttons.save") }}</button>
</div>
</form>
</template>
<script setup lang="ts">
import { settings as api } from "@/api";
import { StatusError } from "@/api/utils";
@@ -244,6 +133,7 @@ import { useI18n } from "vue-i18n";
const error = ref<StatusError | null>(null);
const originalSettings = ref<ISettings | null>(null);
const settings = ref<ISettings | null>(null);
const saving = ref(false);
const debounceTimeout = ref<number | null>(null);
const pendingChunkSize = ref<string | null>(null);
@@ -311,7 +201,7 @@ const capitalize = (name: string, where: string | RegExp = "_") => {
};
const save = async () => {
if (settings.value === null) return false;
if (settings.value === null || saving.value) return false;
applyChunkSize();
const newSettings: ISettings = {
...settings.value,
@@ -349,11 +239,14 @@ const save = async () => {
setTheme(newSettings.branding.theme);
}
saving.value = true;
try {
await api.update(newSettings);
$showSuccess(t("settings.settingsUpdated"));
} catch (e: any) {
$showError(e);
} finally {
saving.value = false;
}
return true;
+93 -68
View File
@@ -1,77 +1,97 @@
<template>
<div class="row">
<div class="column">
<form class="card" @submit="updateSettings">
<div class="card-title">
<h2>{{ t("settings.profileSettings") }}</h2>
<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 class="card-content">
<div class="profile-summary">
<strong>{{ authStore.user?.username }}</strong
><span v-if="authStore.user?.profileName">{{
authStore.user.profileName
}}</span
><span v-if="authStore.user?.email">{{ authStore.user.email }}</span
><small>{{ t("sso.managed") }}</small>
</div>
<p>
<input type="checkbox" name="hideDotfiles" v-model="hideDotfiles" />
{{ t("settings.hideDotfiles") }}
</p>
<p>
<input type="checkbox" name="singleClick" v-model="singleClick" />
{{ t("settings.singleClick") }}
</p>
<p>
<label
><input
type="checkbox"
name="showPreviews"
v-model="showPreviews"
/>
{{ t("settings.showPreviews") }}</label
>
</p>
<p>
<input
type="checkbox"
name="redirectAfterCopyMove"
v-model="redirectAfterCopyMove"
/>
{{ t("settings.redirectAfterCopyMove") }}
</p>
<p>
<input type="checkbox" name="dateFormat" v-model="dateFormat" />
{{ t("settings.setDateFormat") }}
</p>
<h3>{{ t("settings.language") }}</h3>
<languages
class="input input--block"
v-model:locale="locale"
></languages>
<p class="field-hint">{{ t("sso.editorTheme") }}</p>
</div>
<div class="settings-account-links">
<div>
<span>{{ t("preferences.accountSettings") }}</span
><a class="button button--flat" :href="baseURL + '/auth/account'"
>{{ t("preferences.go")
}}<i class="material-icons">north_east</i></a
>
</div>
<div class="card-action">
<input
class="button button--flat"
type="submit"
name="submitProfile"
:value="t('buttons.update')"
/>
<div>
<span>{{ t("preferences.password") }}</span
><a class="button button--flat" :href="baseURL + '/auth/account'"
>{{ t("preferences.go")
}}<i class="material-icons">north_east</i></a
>
</div>
</form>
</div>
</section>
<div class="settings-grid">
<section class="card settings-section">
<h2>
<i class="material-icons">palette</i>{{ 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>
<i class="material-icons">mouse</i>{{ 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 class="card settings-section settings-wide">
<h2>
<i class="material-icons">language</i>{{ 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>
<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 } from "@/utils/constants";
import { getTheme, setTheme } from "@/utils/theme";
import { inject, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
@@ -88,18 +108,21 @@ const singleClick = ref<boolean>(false);
const redirectAfterCopyMove = ref<boolean>(false);
const dateFormat = ref<boolean>(false);
const locale = ref<string>("");
const aceEditorTheme = ref<string>("");
const selectedTheme = ref<UserTheme>(getTheme());
const saving = ref(false);
onMounted(async () => {
layoutStore.loading = true;
if (authStore.user === null) return false;
if (authStore.user === null) {
layoutStore.loading = false;
return false;
}
locale.value = authStore.user.locale;
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;
aceEditorTheme.value = authStore.user.aceEditorTheme;
layoutStore.loading = false;
return true;
@@ -107,6 +130,8 @@ onMounted(async () => {
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!");
@@ -120,7 +145,6 @@ const updateSettings = async (event: Event) => {
singleClick: singleClick.value,
redirectAfterCopyMove: redirectAfterCopyMove.value,
dateFormat: dateFormat.value,
aceEditorTheme: aceEditorTheme.value,
};
await api.update(data, [
@@ -130,7 +154,6 @@ const updateSettings = async (event: Event) => {
"singleClick",
"redirectAfterCopyMove",
"dateFormat",
"aceEditorTheme",
]);
authStore.updateUser(data);
$showSuccess(t("settings.settingsUpdated"));
@@ -138,6 +161,8 @@ const updateSettings = async (event: Event) => {
if (err instanceof Error) {
$showError(err);
}
} finally {
saving.value = false;
}
};
</script>
+5 -6
View File
@@ -4,8 +4,7 @@
<div class="card-title">
<h2>{{ user.displayName || user.username }}</h2>
</div>
<div class="card-content">
<p class="field-hint">{{ $t("sso.managed") }}</p>
<div class="card-content settings-section">
<label for="user-scope">{{ $t("settings.scope") }}</label>
<input
id="user-scope"
@@ -14,10 +13,10 @@
required
/>
<p v-for="permission in permissions" :key="permission">
<label
><input type="checkbox" v-model="user.perm[permission]" />
{{ $t("settings.perm." + permission) }}</label
>
<label class="settings-toggle"
><span>{{ $t("settings.perm." + permission) }}</span
><input type="checkbox" v-model="user.perm[permission]"
/></label>
</p>
<rules v-model:rules="user.rules" />
</div>
+3 -1
View File
@@ -19,7 +19,9 @@
<tr v-for="user in users" :key="user.id">
<td>
{{ user.displayName || user.username
}}<small class="user-record-id">ID {{ user.id }}</small>
}}<small v-if="user.email" class="user-record-id">{{
user.email
}}</small>
</td>
<td>{{ user.scope }}</td>
<td class="small">