From 918401ab42e31d8754a87fa326fc03161a9afbc8 Mon Sep 17 00:00:00 2001 From: Erki Aas Date: Mon, 12 Dec 2022 23:20:57 +0200 Subject: [PATCH] Dynamic column configuration depending on which reported by backend, added Camtiler column definition, Screenshot cell renderer and separate ExamineCamModal --- src/assets/main.css | 10 +- .../Grid/Main/ScreenshotRenderer.js | 20 +++ src/components/Grid/Main/configs/camtiler.js | 46 ++++++ .../Main/{config.js => configs/logmower.js} | 2 +- src/components/LogViewer.vue | 54 ++++-- src/components/Modal/ExamineCamModal.vue | 155 ++++++++++++++++++ 6 files changed, 269 insertions(+), 18 deletions(-) create mode 100644 src/components/Grid/Main/ScreenshotRenderer.js create mode 100644 src/components/Grid/Main/configs/camtiler.js rename src/components/Grid/Main/{config.js => configs/logmower.js} (96%) create mode 100644 src/components/Modal/ExamineCamModal.vue diff --git a/src/assets/main.css b/src/assets/main.css index a78e2b0..4363633 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -5,9 +5,12 @@ div#app { } .screenshots-drawer { - position: fixed; display: flex; - flex-direction: column; + flex-direction: row; +} + +.screenshots-drawer img { + margin-right: 0; } .ag-theme-material { @@ -21,6 +24,7 @@ div#app { .app-title { font-family: 'Montserrat'; + text-transform: capitalize; } .vc-container { @@ -44,4 +48,4 @@ div#app { .v--default-css .c-toast { font-family: 'Roboto Mono'!important; -} \ No newline at end of file +} diff --git a/src/components/Grid/Main/ScreenshotRenderer.js b/src/components/Grid/Main/ScreenshotRenderer.js new file mode 100644 index 0000000..b3f7987 --- /dev/null +++ b/src/components/Grid/Main/ScreenshotRenderer.js @@ -0,0 +1,20 @@ +export default { + template: `
+
+ +
+
`, + data: function () { + return { + screenshots: [], + }; + }, + beforeMount() { + this.updateImage(this.params); + }, + methods: { + updateImage(params) { + this.screenshots = params.value + }, + }, +}; diff --git a/src/components/Grid/Main/configs/camtiler.js b/src/components/Grid/Main/configs/camtiler.js new file mode 100644 index 0000000..ceaa75e --- /dev/null +++ b/src/components/Grid/Main/configs/camtiler.js @@ -0,0 +1,46 @@ +const config = { + defaultColDef: { + width: 120, + initialPinned: true, + resizable: true, + enableCellChangeFlash: true + }, + columnDefs: [ + { + field: '@timestamp', + width: 140, + sortable: true + }, + { + field: 'source', + tooltipValueGetter: (params) => params.value, + filter: 'ComboboxFilter', + filterParams: { + options: [], + field: 'source', + parentColumn: null, + } + }, + { + field: 'event', + tooltipValueGetter: (params) => params.value, + }, + { + field: 'started', + width: 140, + tooltipValueGetter: (params) => params.value, + }, + { + field: 'finished', + width: 140, + tooltipValueGetter: (params) => params.value, + }, + { + field: 'screenshots', + cellRenderer: 'ScreenshotRenderer', + width: 450, + }, + ], +} + +export default config \ No newline at end of file diff --git a/src/components/Grid/Main/config.js b/src/components/Grid/Main/configs/logmower.js similarity index 96% rename from src/components/Grid/Main/config.js rename to src/components/Grid/Main/configs/logmower.js index da89ec1..08c0293 100644 --- a/src/components/Grid/Main/config.js +++ b/src/components/Grid/Main/configs/logmower.js @@ -1,4 +1,4 @@ -import ComboboxFilter from "./Filter/ComboboxFilter"; +import ComboboxFilter from "../Filter/ComboboxFilter"; const config = { defaultColDef: { diff --git a/src/components/LogViewer.vue b/src/components/LogViewer.vue index 0eee891..0fc6a03 100644 --- a/src/components/LogViewer.vue +++ b/src/components/LogViewer.vue @@ -2,6 +2,7 @@
- + +
@@ -29,22 +31,25 @@ import "ag-grid-community/styles//ag-grid.css"; import "ag-grid-community/styles//ag-theme-material.css"; import { Resize } from 'vuetify/directives'; import ExamineLogModal from "./Modal/ExamineLogModal.vue"; +import ExamineCamModal from "./Modal/ExamineCamModal.vue"; import ComboboxFilter from "./Grid/Main/Filter/ComboboxFilter.js"; import MessageWithLevelRenderer from "./Grid/Main/MessageWithLevelRenderer"; +import ScreenshotRenderer from "./Grid/Main/ScreenshotRenderer"; import flattenObj from "../helpers/flattenObj"; import parseEventData from "../helpers/parseEventData"; import {mapActions, mapGetters} from 'vuex'; -import config from "./Grid/Main/config"; import loadingOverlay from "./Grid/Main/loadingOverlay"; import Header from "./Header/Header.vue"; export default { components: { Header, - ExamineLogModal, + ExamineLogModal, // TODO: dynamic loading + ExamineCamModal, AgGridVue, ComboboxFilter, MessageWithLevelRenderer, + ScreenshotRenderer, loadingOverlay }, directives: { @@ -53,12 +58,14 @@ export default { data() { return { examineLogContent: null, - ...config, gridApi: null, gridColumnApi: null, comboBoxOptions: {}, es: null, initialFilter: null, + defaultColDef: null, + columnDefs: null, + backend: 'logmower' } }, computed: { @@ -69,20 +76,40 @@ export default { }, watch: { filterQuery() { - this.setupStream() + if (this.backend) { + this.setupStream() + } }, streaming() { - this.setupStream() + if (this.backend) { + this.setupStream() + } }, }, created() { - let queryParams = new URLSearchParams(window.location.search); - queryParams = Object.fromEntries(queryParams); - this.initialFilter = queryParams - queryParams['initial'] = true - queryParams['from'] && (queryParams['from'] = Number(queryParams['from'])) - queryParams['to'] && (queryParams['to'] = Number(queryParams['to'])) - this.setFilterQuery(queryParams) + fetch('/events/backend') + .then((response) => response.text()) + .then((response) => { + this.backend = response + import( /* @vite-ignore */ './Grid/Main/configs/' + response) + .then(module => { + this.defaultColDef = module.default.defaultColDef + this.columnDefs = module.default.columnDefs + }).catch(err => { + console.error(err) + this.$toast.error(`Backend '${response}' not supported`, { + position: "top-right", + }); + }).then(() => { + let queryParams = new URLSearchParams(window.location.search); + queryParams = Object.fromEntries(queryParams); + this.initialFilter = queryParams + queryParams['initial'] = true + queryParams['from'] && (queryParams['from'] = Number(queryParams['from'])) + queryParams['to'] && (queryParams['to'] = Number(queryParams['to'])) + this.setFilterQuery(queryParams) + }); + }) }, methods: { ...mapActions({ @@ -239,7 +266,6 @@ export default { openExamineLog (row) { const selectedRow = row.data row.node.setSelected(false) - this.examineLog = true const flattened = flattenObj(selectedRow) const pairs = []; Object.keys(flattened).map((key) => { diff --git a/src/components/Modal/ExamineCamModal.vue b/src/components/Modal/ExamineCamModal.vue new file mode 100644 index 0000000..1c5912b --- /dev/null +++ b/src/components/Modal/ExamineCamModal.vue @@ -0,0 +1,155 @@ + + + + + \ No newline at end of file