Mavrag
5 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with
40 additions and
3 deletions
-
src/app/app.vue
-
src/app/pages/admin/general.vue
-
src/i18n/locales/en.json
-
src/server/database/migrations/0002_add_site_title.sql
-
src/server/database/migrations/meta/_journal.json
-
src/server/database/repositories/general/schema.ts
-
src/server/database/repositories/general/service.ts
-
src/server/database/repositories/general/types.ts
|
@ -19,6 +19,12 @@ toast.setToast(toastRef); |
|
|
// make sure to fetch release early |
|
|
// make sure to fetch release early |
|
|
useGlobalStore(); |
|
|
useGlobalStore(); |
|
|
|
|
|
|
|
|
|
|
|
// Fetch site title from general configuration with a key for refreshing |
|
|
|
|
|
const { data: generalConfig } = await useFetch('/api/admin/general', { key: 'site-title' }); |
|
|
|
|
|
|
|
|
|
|
|
// Compute the title with fallback |
|
|
|
|
|
const siteTitle = computed(() => generalConfig.value?.siteTitle || 'WireGuard'); |
|
|
|
|
|
|
|
|
useHead({ |
|
|
useHead({ |
|
|
bodyAttrs: { |
|
|
bodyAttrs: { |
|
|
class: 'bg-gray-50 dark:bg-neutral-800', |
|
|
class: 'bg-gray-50 dark:bg-neutral-800', |
|
@ -52,6 +58,6 @@ useHead({ |
|
|
content: 'black-translucent', |
|
|
content: 'black-translucent', |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
title: 'WireGuard', |
|
|
title: siteTitle, |
|
|
}); |
|
|
}); |
|
|
</script> |
|
|
</script> |
|
|
|
@ -1,6 +1,14 @@ |
|
|
<template> |
|
|
<template> |
|
|
<main v-if="data"> |
|
|
<main v-if="data"> |
|
|
<FormElement @submit.prevent="submit"> |
|
|
<FormElement @submit.prevent="submit"> |
|
|
|
|
|
<FormGroup> |
|
|
|
|
|
<FormNullTextField |
|
|
|
|
|
id="site-title" |
|
|
|
|
|
v-model="data.siteTitle" |
|
|
|
|
|
label="Site Title" |
|
|
|
|
|
description="Custom title for browser tabs. Leave empty to use the default 'WireGuard' title." |
|
|
|
|
|
/> |
|
|
|
|
|
</FormGroup> |
|
|
<FormGroup> |
|
|
<FormGroup> |
|
|
<FormNumberField |
|
|
<FormNumberField |
|
|
id="session" |
|
|
id="session" |
|
@ -53,8 +61,12 @@ const _submit = useSubmit( |
|
|
{ revert } |
|
|
{ revert } |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
function submit() { |
|
|
async function submit() { |
|
|
return _submit(data.value); |
|
|
// Submit the form data |
|
|
|
|
|
await _submit(data.value); |
|
|
|
|
|
|
|
|
|
|
|
// Refresh the site-title data globally to update the browser tab title |
|
|
|
|
|
await refreshNuxtData('site-title'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function revert() { |
|
|
async function revert() { |
|
|
|
@ -140,6 +140,8 @@ |
|
|
}, |
|
|
}, |
|
|
"admin": { |
|
|
"admin": { |
|
|
"general": { |
|
|
"general": { |
|
|
|
|
|
"siteTitle": "Site Title", |
|
|
|
|
|
"siteTitleDesc": "Custom title for the web interface", |
|
|
"sessionTimeout": "Session Timeout", |
|
|
"sessionTimeout": "Session Timeout", |
|
|
"sessionTimeoutDesc": "Session duration for Remember Me (seconds)", |
|
|
"sessionTimeoutDesc": "Session duration for Remember Me (seconds)", |
|
|
"metrics": "Metrics", |
|
|
"metrics": "Metrics", |
|
|
|
@ -0,0 +1 @@ |
|
|
|
|
|
ALTER TABLE general_table ADD COLUMN site_title text; |
|
@ -15,6 +15,13 @@ |
|
|
"when": 1748427001203, |
|
|
"when": 1748427001203, |
|
|
"tag": "0001_classy_the_stranger", |
|
|
"tag": "0001_classy_the_stranger", |
|
|
"breakpoints": true |
|
|
"breakpoints": true |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"idx": 2, |
|
|
|
|
|
"version": "6", |
|
|
|
|
|
"when": 1748427002000, |
|
|
|
|
|
"tag": "0002_add_site_title", |
|
|
|
|
|
"breakpoints": true |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
@ -13,6 +13,8 @@ export const general = sqliteTable('general_table', { |
|
|
metricsJson: int('metrics_json', { mode: 'boolean' }).notNull(), |
|
|
metricsJson: int('metrics_json', { mode: 'boolean' }).notNull(), |
|
|
metricsPassword: text('metrics_password'), |
|
|
metricsPassword: text('metrics_password'), |
|
|
|
|
|
|
|
|
|
|
|
siteTitle: text('site_title'), |
|
|
|
|
|
|
|
|
createdAt: text('created_at') |
|
|
createdAt: text('created_at') |
|
|
.notNull() |
|
|
.notNull() |
|
|
.default(sql`(CURRENT_TIMESTAMP)`), |
|
|
.default(sql`(CURRENT_TIMESTAMP)`), |
|
|
|
@ -36,6 +36,7 @@ function createPreparedStatement(db: DBType) { |
|
|
metricsPrometheus: true, |
|
|
metricsPrometheus: true, |
|
|
metricsJson: true, |
|
|
metricsJson: true, |
|
|
metricsPassword: true, |
|
|
metricsPassword: true, |
|
|
|
|
|
siteTitle: true, |
|
|
}, |
|
|
}, |
|
|
}) |
|
|
}) |
|
|
.prepare(), |
|
|
.prepare(), |
|
|
|
@ -13,11 +13,17 @@ const metricsPassword = z |
|
|
.min(1, { message: t('zod.general.metricsPassword') }) |
|
|
.min(1, { message: t('zod.general.metricsPassword') }) |
|
|
.nullable(); |
|
|
.nullable(); |
|
|
|
|
|
|
|
|
|
|
|
const siteTitle = z |
|
|
|
|
|
.string({ message: 'Site Title' }) |
|
|
|
|
|
.nullable(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const GeneralUpdateSchema = z.object({ |
|
|
export const GeneralUpdateSchema = z.object({ |
|
|
sessionTimeout: sessionTimeout, |
|
|
sessionTimeout: sessionTimeout, |
|
|
metricsPrometheus: metricsEnabled, |
|
|
metricsPrometheus: metricsEnabled, |
|
|
metricsJson: metricsEnabled, |
|
|
metricsJson: metricsEnabled, |
|
|
metricsPassword: metricsPassword, |
|
|
metricsPassword: metricsPassword, |
|
|
|
|
|
siteTitle: siteTitle, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
export type GeneralUpdateType = z.infer<typeof GeneralUpdateSchema>; |
|
|
export type GeneralUpdateType = z.infer<typeof GeneralUpdateSchema>; |
|
|