generated from Seekra/repository-template
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
980805730a
|
|||
|
96d4d92f68
|
|||
|
f947c4bd33
|
|||
|
2c81a7cdf7
|
|||
|
1a13b78eff
|
|||
|
c38b38707c
|
|||
|
3ea55d24dc
|
|||
|
1f4037f64c
|
|||
|
cf781ff3f5
|
|||
|
8acb675a03
|
|||
|
8d6e87af16
|
|||
|
eea417013d
|
|||
|
192f3c37a9
|
|||
|
b729b85ad0
|
|||
|
a9f805e1fd
|
|||
|
af418197a4
|
|||
|
8a718b4bab
|
@@ -35,7 +35,7 @@ const copyrightPeriod =
|
|||||||
<template>
|
<template>
|
||||||
<footer class="global-footer">
|
<footer class="global-footer">
|
||||||
<div class="footer-segment">
|
<div class="footer-segment">
|
||||||
<RouterLink to="settings" class="link">
|
<RouterLink to="/settings" class="link">
|
||||||
{{ t('preferences.settings') }}
|
{{ t('preferences.settings') }}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<LanguageSwitchButton />
|
<LanguageSwitchButton />
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ limitations under the License.
|
|||||||
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
|
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} SettingsConfig
|
|
||||||
* @property {SettingConfigEntry[]} contents
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{ type: 'bool', name: string, i18n: string, description?: string, default: boolean }} BoolSettingConfig
|
* @typedef {{ type: 'bool', name: string, i18n: string, description?: string, default: boolean }} BoolSettingConfig
|
||||||
* @typedef {{ type: 'number', name: string, i18n: string, description?: string, default: number }} NumberSettingConfig
|
* @typedef {{ type: 'number', name: string, i18n: string, description?: string, default: number }} NumberSettingConfig
|
||||||
@@ -64,5 +60,6 @@ limitations under the License.
|
|||||||
* @typedef {{ type: 'selection', name: string, i18n: string, description?: string, default: string | string[], allowMultiple?: boolean, options: SelectionOption[] }} SelectionSettingConfig
|
* @typedef {{ type: 'selection', name: string, i18n: string, description?: string, default: string | string[], allowMultiple?: boolean, options: SelectionOption[] }} SelectionSettingConfig
|
||||||
* @typedef {{ type: 'section', name: string, i18n?: string, description?: string, content: SettingConfigEntry[] }} SectionSettingConfig
|
* @typedef {{ type: 'section', name: string, i18n?: string, description?: string, content: SettingConfigEntry[] }} SectionSettingConfig
|
||||||
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
|
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
|
||||||
* @typedef {{ contents: SettingConfigEntry[] }} SettingsConfig
|
* @typedef {{ contents: SettingConfigEntry[] }} FirstLevelSettingConfigEntry
|
||||||
|
* @typedef {{ contents: FirstLevelSettingConfigEntry[] }} SettingsConfig
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
{ raw: {
|
{ raw: {
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'general',
|
name: 'general',
|
||||||
i18n: 'settings.settings.general',
|
i18n: 'settings.settings.general',
|
||||||
content: [
|
content: [
|
||||||
@@ -49,7 +48,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
{ raw: {
|
{ raw: {
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'general',
|
name: 'general',
|
||||||
i18n: 'settings.settings.general',
|
i18n: 'settings.settings.general',
|
||||||
content: [
|
content: [
|
||||||
@@ -61,7 +59,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'copyOfGeneral',
|
name: 'copyOfGeneral',
|
||||||
i18n: 'settings.settings.copyOfGeneral',
|
i18n: 'settings.settings.copyOfGeneral',
|
||||||
content: [
|
content: [
|
||||||
@@ -77,7 +74,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
{ raw: {
|
{ raw: {
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'general',
|
name: 'general',
|
||||||
i18n: 'settings.settings.general',
|
i18n: 'settings.settings.general',
|
||||||
content: [
|
content: [
|
||||||
@@ -89,7 +85,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'copyOfGeneral',
|
name: 'copyOfGeneral',
|
||||||
i18n: 'settings.settings.copyOfGeneral',
|
i18n: 'settings.settings.copyOfGeneral',
|
||||||
content: [
|
content: [
|
||||||
@@ -102,7 +97,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'aSection',
|
name: 'aSection',
|
||||||
i18n: 'settings.settings.aSection',
|
i18n: 'settings.settings.aSection',
|
||||||
content: [
|
content: [
|
||||||
@@ -141,7 +135,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
{ raw: {
|
{ raw: {
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'general',
|
name: 'general',
|
||||||
i18n: 'settings.settings.general',
|
i18n: 'settings.settings.general',
|
||||||
content: [
|
content: [
|
||||||
@@ -153,7 +146,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'copyOfGeneral',
|
name: 'copyOfGeneral',
|
||||||
i18n: 'settings.settings.copyOfGeneral',
|
i18n: 'settings.settings.copyOfGeneral',
|
||||||
content: [
|
content: [
|
||||||
@@ -166,7 +158,6 @@ describe('validateSettingsConfig', () => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
|
||||||
name: 'aSection',
|
name: 'aSection',
|
||||||
i18n: 'settings.settings.aSection',
|
i18n: 'settings.settings.aSection',
|
||||||
content: [
|
content: [
|
||||||
@@ -203,6 +194,74 @@ describe('validateSettingsConfig', () => {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}, expected: true },
|
}, expected: true },
|
||||||
|
{ raw: {
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
type: 'bool',
|
||||||
|
name: 'aStandaloneBooleanSetting',
|
||||||
|
i18n: 'settings.settings.aStandaloneBooleanSetting',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'general',
|
||||||
|
i18n: 'settings.settings.general',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'bool',
|
||||||
|
name: 'Enable feature 42',
|
||||||
|
i18n: 'settings.settings.general.enableFeature42'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'copyOfGeneral',
|
||||||
|
i18n: 'settings.settings.copyOfGeneral',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'bool',
|
||||||
|
name: 'Enable feature 42',
|
||||||
|
default: false,
|
||||||
|
i18n: 'settings.settings.general.enableFeature42'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'aSection',
|
||||||
|
i18n: 'settings.settings.aSection',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'bool',
|
||||||
|
name: 'Enable feature 43',
|
||||||
|
i18n: 'settings.settings.aSection.enableFeature43'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
name: 'language',
|
||||||
|
i18n: 'settings.settings.aSection.language.label',
|
||||||
|
default: 'en',
|
||||||
|
allowMultiple: false,
|
||||||
|
options: [
|
||||||
|
{ name: 'en', i18n: 'settings.settings.aSection.language.options.en' },
|
||||||
|
{ name: 'de', i18n: 'settings.settings.aSection.language.options.de' },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'section',
|
||||||
|
name: 'section2',
|
||||||
|
i18n: 'settings.settings.aSection.section2.label',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'string',
|
||||||
|
i18n: 'settings.settings.aSection.sections.string',
|
||||||
|
default: 'str'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}, expected: false },
|
||||||
{ raw: {
|
{ raw: {
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,19 @@ export const validateEntry = function validateEntry (entry, path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const validateFirstLevelSection = function validateFirstLevelSection (section, path) {
|
||||||
|
assertString(section.name);
|
||||||
|
assertString(section.i18n);
|
||||||
|
|
||||||
|
if (!Array.isArray(section.content)) {
|
||||||
|
throw new Error(`[settings] "${path}.content" must be an array`);
|
||||||
|
};
|
||||||
|
|
||||||
|
section.content.forEach((entry, i) =>
|
||||||
|
validateEntry(entry, `${path}.content[${i}]`)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates a raw settings config object.
|
* Validates a raw settings config object.
|
||||||
* @param {unknown} raw
|
* @param {unknown} raw
|
||||||
@@ -97,7 +110,7 @@ export function validateSettingsConfig(raw) {
|
|||||||
throw new Error('[settings] "contents" must be an array');
|
throw new Error('[settings] "contents" must be an array');
|
||||||
}
|
}
|
||||||
raw.contents.forEach((entry, i) =>
|
raw.contents.forEach((entry, i) =>
|
||||||
validateEntry(entry, `contents[${i}]`)
|
validateFirstLevelSection(entry, `contents[${i}]`)
|
||||||
);
|
);
|
||||||
return { valid: true, config: raw };
|
return { valid: true, config: raw };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -17,9 +17,33 @@ limitations under the License.
|
|||||||
<script setup>
|
<script setup>
|
||||||
import LeftSidebarLayout from '@/layouts/LeftSidebarLayout.vue';
|
import LeftSidebarLayout from '@/layouts/LeftSidebarLayout.vue';
|
||||||
|
|
||||||
|
import { loadSettingsConfig } from '../utils/settingsParser';
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const settingsLoaded = ref(false)
|
||||||
|
const settings = ref([]);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
settings.value = (await loadSettingsConfig()).contents;
|
||||||
|
if (!settings.value.map((section) => section.name).includes(getActiveSection())) {
|
||||||
|
router.push('/settings');
|
||||||
|
};
|
||||||
|
settingsLoaded.value = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getActiveSection = function getActiveSection () {
|
||||||
|
const segments = route.path
|
||||||
|
.split('/')
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
return segments[1];
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -31,7 +55,23 @@ const { t } = useI18n();
|
|||||||
</header>
|
</header>
|
||||||
<LeftSidebarLayout class="layout">
|
<LeftSidebarLayout class="layout">
|
||||||
<template #sidebar>
|
<template #sidebar>
|
||||||
|
<ul class="sidebar-sections-list">
|
||||||
|
<li v-for="section in settings">
|
||||||
|
<RouterLink
|
||||||
|
:to="`/settings/${section.name}`"
|
||||||
|
class="button button-link link sidebar-section"
|
||||||
|
:class="{ active: getActiveSection() === section.name }"
|
||||||
|
>
|
||||||
|
{{ t(section.i18n) }}
|
||||||
|
</RouterLink>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
<div>
|
||||||
|
<div v-if="!settingsLoaded">
|
||||||
|
{{ t('loading') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</LeftSidebarLayout>
|
</LeftSidebarLayout>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -46,6 +86,10 @@ const { t } = useI18n();
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
background-color: var(--light-hover);
|
||||||
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
padding: var(--main-content-padding-y) var(--main-content-padding-x);
|
padding: var(--main-content-padding-y) var(--main-content-padding-x);
|
||||||
}
|
}
|
||||||
@@ -53,4 +97,21 @@ const { t } = useI18n();
|
|||||||
.header h1 {
|
.header h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-sections-list {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-section {
|
||||||
|
--padding: 0.8em;
|
||||||
|
border-radius: var(--padding);
|
||||||
|
padding: var(--padding);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
width: calc(100% - 2 * var(--padding));
|
||||||
|
text-align: start;
|
||||||
|
font-size: 1rem;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "Laden ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Suchen",
|
"submit": "Suchen",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "Loading ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Search",
|
"submit": "Search",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "Cargando ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Buscar",
|
"submit": "Buscar",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "Chargement ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Rechercher",
|
"submit": "Rechercher",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "Caricamento ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Cerca",
|
"submit": "Cerca",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"loading": "A carregar ...",
|
||||||
"search": {
|
"search": {
|
||||||
"searchBar": {
|
"searchBar": {
|
||||||
"submit": "Pesquisar",
|
"submit": "Pesquisar",
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ const routes = [
|
|||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
component: SettingsView,
|
component: SettingsView,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: ':rest(.*)',
|
||||||
|
component: SettingsView
|
||||||
|
}
|
||||||
|
],
|
||||||
meta: {
|
meta: {
|
||||||
title: () => i18n.global.t('preferences.settings')
|
title: () => i18n.global.t('preferences.settings')
|
||||||
}
|
}
|
||||||
@@ -59,6 +65,18 @@ const router = createRouter({
|
|||||||
routes
|
routes
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// remove trailing slash(es)
|
||||||
|
router.beforeEach((route) => {
|
||||||
|
if (route.path !== '/' && route.path.endsWith('/')) {
|
||||||
|
return {
|
||||||
|
path: route.path.replace(/\/+$/, ''),
|
||||||
|
query: route.query,
|
||||||
|
hash: route.hash,
|
||||||
|
replace: true
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// set page title
|
// set page title
|
||||||
router.afterEach(to => {
|
router.afterEach(to => {
|
||||||
const title =
|
const title =
|
||||||
|
|||||||
+28
-1
@@ -23,10 +23,23 @@ body {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.link:hover:not(.button-link) {
|
.link:hover:not(.button-link), .link:focus:not(.button-link) {
|
||||||
|
outline: none;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-link {
|
||||||
|
color: var(--dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-link:hover {
|
||||||
|
color: var(--dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-link:visited {
|
||||||
|
color: var(--dark);
|
||||||
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
}
|
}
|
||||||
@@ -34,4 +47,18 @@ input {
|
|||||||
.main-content-padding {
|
.main-content-padding {
|
||||||
padding: var(--main-content-padding);
|
padding: var(--main-content-padding);
|
||||||
width: calc(100% - var(--main-content-padding-x) * 2);
|
width: calc(100% - var(--main-content-padding-x) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
background-color: var(--light-bg);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:focus {
|
||||||
|
background-color: var(--light-hover);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background-color: var(--light-hover);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ const { t } = useI18n();
|
|||||||
.error-message{
|
.error-message{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 2vw;
|
font-size: 1.75rem;
|
||||||
}
|
}
|
||||||
#link {
|
#link {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user