save error level in cookie

This commit is contained in:
jb-alvarado 2024-09-03 16:12:29 +02:00
parent 8d8ab58ef4
commit 1c7f6892fd
4 changed files with 359 additions and 423 deletions

736
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "ffplayout-frontend",
"version": "0.12.0",
"version": "0.12.1",
"description": "Web GUI for ffplayout",
"author": "Jonathan Baecker",
"private": true,
@ -30,18 +30,18 @@
"video.js": "^8.17.3"
},
"devDependencies": {
"@nuxt/eslint": "^0.5.3",
"@nuxt/eslint": "^0.5.5",
"@nuxtjs/i18n": "^8.5.1",
"@nuxtjs/tailwindcss": "^6.12.1",
"@types/lodash": "^4.17.7",
"@types/video.js": "^7.3.58",
"daisyui": "^4.12.10",
"mini-svg-data-uri": "^1.4.4",
"postcss": "^8.4.41",
"postcss": "^8.4.44",
"postcss-loader": "^8.1.1",
"sass": "^1.77.8",
"sass-loader": "^16.0.1",
"vue": "^3.4.38",
"vue": "^3.5.0",
"vue-router": "^4.4.3"
}
}

View File

@ -4,10 +4,10 @@
<div class="join">
<select v-model="errorLevel" class="join-item select select-sm select-bordered w-full max-w-xs">
<option
v-for="(index, value) in severityLevels"
v-for="(index, value) in indexStore.severityLevels"
:key="index"
:value="value"
:selected="value === 'INFO' ? true : false"
:selected="value === errorLevel"
>
{{ value }}
</option>
@ -45,6 +45,8 @@ import { storeToRefs } from 'pinia'
const colorMode = useColorMode()
const { locale, t } = useI18n()
const indexStore = useIndex()
useHead({
title: `${t('button.logging')} | ffplayout`,
})
@ -58,13 +60,21 @@ const currentLog = ref('')
const listDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
const { formatLog } = stringFormatter()
const errorLevel = ref('INFO')
const severityLevels: { [key: string]: number } = {
DEBUG: 1,
INFO: 2,
WARN: 3,
ERROR: 4,
}
const levelCookie = useCookie('error_level', {
path: '/',
maxAge: 60 * 60 * 24 * 365,
sameSite: 'lax',
})
const errorLevel = computed({
get() {
return levelCookie.value || 'INFO'
},
set(value) {
levelCookie.value = value
},
})
onMounted(async () => {
await getLog()
@ -79,7 +89,7 @@ const calendarFormat = (date: Date) => {
}
function filterLogsBySeverity(logString: string, minSeverity: string): string {
const minLevel = severityLevels[minSeverity]
const minLevel = indexStore.severityLevels[minSeverity]
const logLines = logString.trim().split(/\r?\n/)
const filteredLogs = logLines.filter((log) => {
@ -87,7 +97,7 @@ function filterLogsBySeverity(logString: string, minSeverity: string): string {
if (match) {
const logLevel = match[1]
return severityLevels[logLevel] >= minLevel
return indexStore.severityLevels[logLevel] >= minLevel
}
return false
})

View File

@ -7,6 +7,12 @@ export const useIndex = defineStore('index', {
alertVariant: 'success',
alertMsg: '',
sseConnected: false,
severityLevels: {
DEBUG: 1,
INFO: 2,
WARN: 3,
ERROR: 4,
} as { [key: string]: number }
}),
getters: {},