Correctly handle customized server name in admin settings dialog.

This commit is contained in:
2026-02-04 20:15:56 +00:00
parent cc351bb992
commit 41686d1dd1
3 changed files with 34 additions and 10 deletions
+9
View File
@@ -163,6 +163,15 @@ def subscribe(uuid, ws):
) )
@bp.get("config")
async def get_config(request):
await auth.verify(request, privileged=True)
return json({
"name": config.config.name,
"public": config.config.public,
})
@bp.put("config/public") @bp.put("config/public")
async def update_public(request): async def update_public(request):
await auth.verify(request, privileged=True) await auth.verify(request, privileged=True)
@@ -75,7 +75,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, onMounted, watch } from 'vue' import { ref, reactive, onMounted, watch } from 'vue'
import { listUsers, createUser, updateUser, deleteUser, updatePublic, updateServerName } from '@/repositories/User' import { listUsers, createUser, updateUser, deleteUser, updatePublic, updateServerName, getServerConfig } from '@/repositories/User'
import type { ISimpleError } from '@/repositories/Client' import type { ISimpleError } from '@/repositories/Client'
import { useMainStore } from '@/stores/main' import { useMainStore } from '@/stores/main'
@@ -238,23 +238,33 @@ const debouncedUpdateServerName = () => {
nameDebounceTimer = setTimeout(updateServerNameSetting, 400) nameDebounceTimer = setTimeout(updateServerNameSetting, 400)
} }
// Initialize server settings // Load server config from admin API
const initServerSettings = () => { const loadServerConfig = async () => {
try {
const config = await getServerConfig()
serverSettings.name = config.name
serverSettings.public = config.public
} catch (e) {
// Fallback to store values if API fails
serverSettings.public = store.server.public || false serverSettings.public = store.server.public || false
// Start with empty name field - placeholder shows current effective name
serverSettings.name = '' serverSettings.name = ''
}
} }
onMounted(() => { onMounted(() => {
initServerSettings() serverSettings.public = store.server.public || false
serverSettings.name = ''
loading.value = false loading.value = false
}) })
// Load users when dialog opens (only in built-in auth mode) // Load users and config when dialog opens
watch(() => store.dialog, (newVal) => { watch(() => store.dialog, (newVal) => {
if (newVal === 'usermgmt' && !store.server.paskia) { if (newVal === 'usermgmt') {
loadServerConfig()
if (!store.server.paskia) {
loadUsers() loadUsers()
} }
}
}) })
watch(() => store.server.public, (newVal) => { watch(() => store.server.public, (newVal) => {
+5
View File
@@ -60,3 +60,8 @@ export async function updateServerName(name: string) {
const data = await Client.put('/api/config/name', { name }) const data = await Client.put('/api/config/name', { name })
return data return data
} }
export async function getServerConfig() {
const data = await Client.get('/api/config')
return data as { name: string, public: boolean }
}