|
13 | 13 | step="1" |
14 | 14 | thumb-label="always" |
15 | 15 | /> |
| 16 | + <v-data-table :items="systemLogsData" :headers="headers" class="max-w-[80%] max-h-[60%]"> |
| 17 | + <template #item.actions="{ item }"> |
| 18 | + <div class="text-center cursor-pointer icon-btn mdi mdi-download" @click="downloadLog(item.name)" /> |
| 19 | + </template> |
| 20 | + </v-data-table> |
16 | 21 | </template> |
17 | 22 | </BaseConfigurationView> |
18 | 23 | </template> |
19 | 24 |
|
20 | 25 | <script setup lang="ts"> |
| 26 | +// @ts-nocheck |
| 27 | +// TODO: As of now Vuetify does not export the necessary types for VDataTable, so we can't fix the type error. |
| 28 | +
|
| 29 | +import { saveAs } from 'file-saver' |
| 30 | +import { onBeforeMount } from 'vue' |
| 31 | +import { ref } from 'vue' |
| 32 | +
|
| 33 | +import { type SystemLog, cockpitSytemLogsDB } from '@/libs/system-logging' |
21 | 34 | import { useDevelopmentStore } from '@/stores/development' |
22 | 35 |
|
23 | 36 | import BaseConfigurationView from './BaseConfigurationView.vue' |
24 | | -
|
25 | 37 | const devStore = useDevelopmentStore() |
| 38 | +
|
| 39 | +/* eslint-disable jsdoc/require-jsdoc */ |
| 40 | +interface SystemLogsData { |
| 41 | + name: string |
| 42 | + initialTime: string |
| 43 | + initialDate: string |
| 44 | + nEvents: number |
| 45 | +} |
| 46 | +/* eslint-enable jsdoc/require-jsdoc */ |
| 47 | +
|
| 48 | +const systemLogsData = ref<SystemLogsData[]>([]) |
| 49 | +
|
| 50 | +const headers = [ |
| 51 | + { title: 'Name', value: 'name' }, |
| 52 | + { title: 'Time (initial)', value: 'initialTime' }, |
| 53 | + { title: 'Date (initial)', value: 'initialDate' }, |
| 54 | + { title: 'N. events', value: 'nEvents' }, |
| 55 | + { title: 'Download', value: 'actions' }, |
| 56 | +] |
| 57 | +
|
| 58 | +onBeforeMount(async () => { |
| 59 | + await cockpitSytemLogsDB.iterate((log: SystemLog, logName) => { |
| 60 | + systemLogsData.value.push({ |
| 61 | + name: logName, |
| 62 | + initialTime: log.initialTime, |
| 63 | + initialDate: log.initialDate, |
| 64 | + nEvents: log.events.length, |
| 65 | + }) |
| 66 | + }) |
| 67 | +}) |
| 68 | +
|
| 69 | +const downloadLog = async (logName: string): Promise<void> => { |
| 70 | + const log = await cockpitSytemLogsDB.getItem(logName) |
| 71 | + const logParts = JSON.stringify(log, null, 2) |
| 72 | + const logBlob = new Blob([logParts], { type: 'application/json' }) |
| 73 | + saveAs(logBlob, logName) |
| 74 | +} |
26 | 75 | </script> |
0 commit comments