diff --git a/src/views/ConfigurationDevelopmentView.vue b/src/views/ConfigurationDevelopmentView.vue index 5364a8ca2..557a8a5b5 100644 --- a/src/views/ConfigurationDevelopmentView.vue +++ b/src/views/ConfigurationDevelopmentView.vue @@ -55,7 +55,18 @@ /> - + @@ -129,6 +143,33 @@ const downloadLog = async (logName: string): Promise => { const logBlob = new Blob([logParts], { type: 'application/json' }) saveAs(logBlob, logName) } + +const deleteLog = async (logName: string): Promise => { + await cockpitSytemLogsDB.removeItem(logName) + systemLogsData.value = systemLogsData.value.filter((log) => log.name !== logName) +} + +const deleteOldLogs = async (): Promise => { + const yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + + const logsToDelete: string[] = [] + await cockpitSytemLogsDB.iterate((log: SystemLog, logName: string) => { + const logDate = new Date(log.initialDate) + if (logDate < yesterday) { + logsToDelete.push(logName) + } + }) + + for (const logName of logsToDelete) { + await cockpitSytemLogsDB.removeItem(logName) + } + + systemLogsData.value = systemLogsData.value.filter((log) => { + const logDate = new Date(log.initialDate) + return logDate >= yesterday + }) +}