From cab82049bf76238b97c2abb55b5c9849d2fe5c59 Mon Sep 17 00:00:00 2001 From: Erki Aas Date: Wed, 16 Nov 2022 13:16:11 +0200 Subject: [PATCH] Remove level column, display level as colored icon before message --- src/components/Grid/Main/ErrLevelRenderer.js | 26 ---------- .../Grid/Main/MessageWithLevelRenderer.js | 47 +++++++++++++++++++ src/components/Grid/Main/config.js | 5 +- src/components/LogViewer.vue | 4 +- 4 files changed, 50 insertions(+), 32 deletions(-) delete mode 100644 src/components/Grid/Main/ErrLevelRenderer.js create mode 100644 src/components/Grid/Main/MessageWithLevelRenderer.js diff --git a/src/components/Grid/Main/ErrLevelRenderer.js b/src/components/Grid/Main/ErrLevelRenderer.js deleted file mode 100644 index ff80604..0000000 --- a/src/components/Grid/Main/ErrLevelRenderer.js +++ /dev/null @@ -1,26 +0,0 @@ -import { VChip } from 'vuetify/components/VChip' - -export default { - template: ` - {{ displayValue }} - `, - components: { - VChip - }, - setup(props) { - let displayValue = props.params.value - let colors = { - 'error': 'red', - 'info': 'orange', - } - let color = colors[displayValue] - return { - displayValue, - color - }; - }, -}; \ No newline at end of file diff --git a/src/components/Grid/Main/MessageWithLevelRenderer.js b/src/components/Grid/Main/MessageWithLevelRenderer.js new file mode 100644 index 0000000..7176638 --- /dev/null +++ b/src/components/Grid/Main/MessageWithLevelRenderer.js @@ -0,0 +1,47 @@ +import { VRow, VCol } from 'vuetify/components/VGrid' +import { VIcon } from 'vuetify/components/VIcon' + +export default { + template: ` + + {{ icon }} + {{ message }} + + `, + components: { + VRow, + VCol, + VIcon + }, + setup(props) { + let message = props.params.data.message + let level = props.params.data.level + let icons = { + 'emergency': 'mdi-alert-circle', + 'alert': 'mdi-alert-circle', + 'critical': 'mdi-alert-circle', + 'error': 'mdi-alert-circle', + 'warning': 'mdi-alert-circle', + 'notice': 'mdi-alert-circle', + 'info': 'mdi-information', + 'debug': 'mdi-information', + } + let colors = { + 'emergency': 'red', + 'alert': 'red', + 'critical': 'red', + 'error': 'red', + 'warning': 'orange', + 'notice': 'orange', + 'info': 'green', + 'debug': 'green', + } + let color = colors[level] + let icon = icons[level] + return { + message, + color, + icon + }; + }, +}; \ No newline at end of file diff --git a/src/components/Grid/Main/config.js b/src/components/Grid/Main/config.js index 18824ca..da89ec1 100644 --- a/src/components/Grid/Main/config.js +++ b/src/components/Grid/Main/config.js @@ -49,12 +49,9 @@ const config = { { field: 'message', tooltipValueGetter: (params) => params.value, + cellRenderer: 'MessageWithLevelRenderer', width: 500, }, - { - field: 'level', - cellRenderer: 'ErrLevelRenderer', - }, ], } diff --git a/src/components/LogViewer.vue b/src/components/LogViewer.vue index 0057000..46c55c7 100644 --- a/src/components/LogViewer.vue +++ b/src/components/LogViewer.vue @@ -49,7 +49,7 @@ import { VRow, VCol } from 'vuetify/components/VGrid' import { Resize } from 'vuetify/directives'; import ExamineLogModal from "./Modal/ExamineLogModal.vue"; import ComboboxFilter from "./Grid/Main/Filter/ComboboxFilter.js"; -import ErrLevelRenderer from "./Grid/Main/ErrLevelRenderer"; +import MessageWithLevelRenderer from "./Grid/Main/MessageWithLevelRenderer"; import flattenObj from "../helpers/flattenObj"; import parseEventData from "../helpers/parseEventData"; import {mapActions, mapGetters} from 'vuex'; @@ -63,7 +63,7 @@ export default { ExamineLogModal, AgGridVue, ComboboxFilter, - ErrLevelRenderer, + MessageWithLevelRenderer, VBtn, VRow, VCol,