From df57e700efcfcc59d27272cfbb1f222c9087a5e1 Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 9 Feb 2024 15:28:40 +0100 Subject: [PATCH] chore: lint + add prettierignore + prettier json rules --- .prettierignore | 2 ++ .prettierrc | 16 ++++++++++++++- components/CustomLogo.vue | 2 +- components/PageTitle.vue | 2 +- composables/states.ts | 33 ++++++++++++++++++++++--------- docker-compose.yml | 1 - layouts/default.vue | 12 +++++++++--- maintenance/locales.json | 4 +--- middleware/auth.global.ts | 2 +- pages/index.vue | 41 ++++++++++++++++++++++++++------------- spa-loading-template.html | 4 ++-- 11 files changed, 84 insertions(+), 35 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..5cefc78 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.mypy_cache +README.md diff --git a/.prettierrc b/.prettierrc index 2a6e6ac..ad7671c 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,19 @@ { "semi": false, "tabWidth": 2, - "singleQuote": true + "singleQuote": true, + "overrides": [ + { + "files": "**/*.json", + "options": { + "tabWidth": 4 + } + }, + { + "files": "./*.json", + "options": { + "tabWidth": 2 + } + } + ] } diff --git a/components/CustomLogo.vue b/components/CustomLogo.vue index afa03bd..5a2827a 100644 --- a/components/CustomLogo.vue +++ b/components/CustomLogo.vue @@ -17,7 +17,7 @@ try { v-html="customLogo.src" /> useState('queryMsg', () => null) // SETTINGS +type AppsSettings = Record< + string, + { + label: string + url: string + description?: Record + logo?: string + } +> + export interface Settings { domain: string public: boolean - portal_logo?: { is: 'img' | 'svg', src: string } + portal_logo?: { is: 'img' | 'svg'; src: string } portal_theme: string portal_title?: string search_engine?: string @@ -89,7 +99,7 @@ export interface Settings { show_other_domains_apps: 0 | 1 portal_user_intro: string portal_public_intro: string - apps: Record, logo?: string }> + apps: AppsSettings } const useSettingsState = () => useState('settings') @@ -100,17 +110,22 @@ export const useSettings = async () => { if (!settings.value) { const { data } = await useApi('/public') - const logo = data.value.portal_logo + const logo = data.value!.portal_logo as unknown as string | undefined if (logo) { const src = `https://${data.value.domain}/yunohost/sso/customassets/${logo}` - const is = data.value.portal_logo.substr(-4) === '.svg' ? 'svg' : 'img' - data.value.portal_logo = { is, src: is === 'svg' ? '' : src } + const is = logo.slice(-4) === '.svg' ? 'svg' : 'img' + data.value!.portal_logo = { is, src: is === 'svg' ? '' : src } if (is === 'svg') { // Query file content to inject inline SVG so that CSS "currentColor" can cascade to it - $fetch(src).then((blob) => blob.text()).then((text) => { - data.value.portal_logo.src = text.replace('', '') - }) + $fetch(src) + .then((blob) => blob.text()) + .then((text) => { + data.value!.portal_logo!.src = text.replace( + '', + '', + ) + }) } } @@ -132,7 +147,7 @@ export interface User { mailalias: string[] mailforward: string[] groups: string[] - apps: Record + apps: AppsSettings } export const useUserState = () => useState('user', () => null) diff --git a/docker-compose.yml b/docker-compose.yml index 0385fee..0fcd4cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ services: - portal: build: . ports: diff --git a/layouts/default.vue b/layouts/default.vue index 59719d0..071ebce 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -71,9 +71,12 @@ async function logout() {
-
-
+ +
-

+

{{ settings.portal_title }}

diff --git a/maintenance/locales.json b/maintenance/locales.json index f15006f..e9710bb 100644 --- a/maintenance/locales.json +++ b/maintenance/locales.json @@ -18,9 +18,7 @@ { "code": "br", "dir": "ltr", - "fallback": [ - "fr" - ], + "fallback": ["fr"], "file": "br.json", "iso": "br", "name": "Brezhoneg" diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts index bab7768..0ade857 100644 --- a/middleware/auth.global.ts +++ b/middleware/auth.global.ts @@ -5,7 +5,7 @@ import { useSettings, } from '@/composables/states' -export default defineNuxtRouteMiddleware(async (to, from) => { +export default defineNuxtRouteMiddleware(async (to) => { const isLoggedIn = useIsLoggedIn() const settings = await useSettings() diff --git a/pages/index.vue b/pages/index.vue index 7339ce9..0d0a980 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -21,25 +21,22 @@ const intro = computed(() => { return isLoggedIn.value ? userIntro : isPublic ? publicIntro : null }) -const apps = Object.entries(appsData.value).map(([id, app]) => { +const apps = Object.values(appsData.value).map((app) => { return { ...app, url: '//' + app.url, - description: app.description[locale.value] || app.description.en + description: app.description?.[locale.value] || app.description?.en, } }) const search = ref('') async function onSearchSubmit() { - await navigateTo( - settings.value.search_engine + search.value, - { - open: { - target: '_blank', - } - } - ) + await navigateTo(settings.value.search_engine + search.value, { + open: { + target: '_blank', + }, + }) } @@ -49,14 +46,31 @@ async function onSearchSubmit() {
+ + + @@ -77,9 +91,10 @@ async function onSearchSubmit() { >

diff --git a/spa-loading-template.html b/spa-loading-template.html index 8054f29..05ef7f2 100644 --- a/spa-loading-template.html +++ b/spa-loading-template.html @@ -13,8 +13,8 @@ justify-content: center; @media (prefers-color-scheme: dark) { - background-color: rgb(29, 35, 42); - color: rgb(166, 173, 186); + background-color: rgb(29, 35, 42); + color: rgb(166, 173, 186); } }