2022-10-05 14:44:28 +00:00
|
|
|
<template>
|
|
|
|
<div style="height: 100%; width: 100%">
|
|
|
|
<ag-grid-vue
|
|
|
|
style="width: 100%; height: 100%;"
|
2022-10-11 16:15:29 +00:00
|
|
|
class="ag-theme-material"
|
2022-10-05 14:44:28 +00:00
|
|
|
@grid-ready="onGridReady"
|
|
|
|
:defaultColDef="defaultColDef"
|
|
|
|
:columnDefs="columnDefs"
|
2022-10-10 23:50:03 +00:00
|
|
|
:pagination="true"
|
|
|
|
:paginationAutoPageSize=true
|
2022-10-05 14:44:28 +00:00
|
|
|
:row-data="null"
|
2022-10-11 16:16:27 +00:00
|
|
|
row-selection="single"
|
2022-10-11 16:43:12 +00:00
|
|
|
:onRowSelected="openExamineLog"
|
2022-10-05 14:44:28 +00:00
|
|
|
:supress-horisontal-scroll="true"
|
|
|
|
:enable-scrolling="true"
|
2022-10-10 23:27:31 +00:00
|
|
|
></ag-grid-vue>
|
2022-10-11 16:16:27 +00:00
|
|
|
<v-dialog
|
|
|
|
v-model="examineLog"
|
|
|
|
>
|
|
|
|
<v-card>
|
|
|
|
<v-card-text>
|
|
|
|
<v-table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="text-left">
|
|
|
|
Key
|
|
|
|
</th>
|
|
|
|
<th class="text-left">
|
|
|
|
Value
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr
|
|
|
|
v-for="item in examineLogContent"
|
|
|
|
:key="item.name"
|
|
|
|
>
|
|
|
|
<td>{{ item.key }}</td>
|
|
|
|
<td>
|
|
|
|
<span> {{ item.value }} </span>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</v-table>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-btn color="primary" block @click="examineLog = null">Close Dialog</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
2022-10-05 14:44:28 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { AgGridVue } from "ag-grid-vue3";
|
|
|
|
import "ag-grid-community/styles//ag-grid.css";
|
2022-10-11 16:15:29 +00:00
|
|
|
import "ag-grid-community/styles//ag-theme-material.css";
|
2022-10-05 14:44:28 +00:00
|
|
|
import ScreenshotCell from "./ScreenshotCell.js";
|
2022-10-11 16:16:27 +00:00
|
|
|
import { VCard, VCardText, VCardActions } from 'vuetify/components/VCard'
|
|
|
|
import { VDialog } from 'vuetify/components/VDialog'
|
|
|
|
import { VBtn } from 'vuetify/components/VBtn'
|
|
|
|
import { VTable } from 'vuetify/components/VTable'
|
2022-10-05 14:44:28 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
AgGridVue,
|
2022-10-11 16:16:27 +00:00
|
|
|
VCard,
|
|
|
|
VCardText,
|
|
|
|
VCardActions,
|
|
|
|
VBtn,
|
|
|
|
VDialog,
|
|
|
|
VTable,
|
2022-10-11 00:21:32 +00:00
|
|
|
ScreenshotCell: ScreenshotCell
|
2022-10-05 14:44:28 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-10-11 16:16:27 +00:00
|
|
|
examineLog: null,
|
|
|
|
examineLogContent: null,
|
|
|
|
copied: false,
|
2022-10-05 14:44:28 +00:00
|
|
|
gridApi: null,
|
|
|
|
gridColumnApi: null,
|
|
|
|
rowData: [],
|
|
|
|
defaultColDef: {
|
|
|
|
width: 50,
|
|
|
|
initialPinned: true,
|
2022-10-11 16:43:46 +00:00
|
|
|
resizable: true,
|
|
|
|
enableCellChangeFlash: true
|
2022-10-05 14:44:28 +00:00
|
|
|
},
|
2022-10-10 23:27:31 +00:00
|
|
|
currentRowCount: 0,
|
|
|
|
viewRowCount: 20,
|
|
|
|
comboBoxOptions: [],
|
2022-10-05 14:44:28 +00:00
|
|
|
columnDefs: [
|
|
|
|
{
|
|
|
|
field: '_id',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'kubernetes.namespace',
|
|
|
|
headerName: 'namespace',
|
2022-10-11 16:16:03 +00:00
|
|
|
tooltipValueGetter: (params) => params.value,
|
2022-10-11 00:20:12 +00:00
|
|
|
filter: true,
|
2022-10-05 14:44:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'kubernetes.pod.name',
|
|
|
|
headerName: 'pod',
|
2022-10-11 16:16:03 +00:00
|
|
|
tooltipValueGetter: (params) => params.value,
|
2022-10-11 00:20:12 +00:00
|
|
|
filter: true,
|
2022-10-05 14:44:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'kubernetes.container.name',
|
|
|
|
headerName: 'container',
|
2022-10-11 16:16:03 +00:00
|
|
|
tooltipValueGetter: (params) => params.value,
|
2022-10-11 00:20:12 +00:00
|
|
|
filter: true,
|
2022-10-05 14:44:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'message',
|
2022-10-11 16:16:03 +00:00
|
|
|
tooltipValueGetter: (params) => params.value,
|
2022-10-05 14:44:28 +00:00
|
|
|
width: 500,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'stream',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: '@timestamp',
|
2022-10-11 00:20:12 +00:00
|
|
|
width: 70,
|
|
|
|
sortable: true
|
2022-10-05 14:44:28 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.setupStream()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setupStream() {
|
|
|
|
let es = new EventSource('/events');
|
|
|
|
es.onmessage = (e) => this.handleReceiveMessage(e)
|
|
|
|
},
|
|
|
|
onGridReady(params) {
|
|
|
|
this.gridApi = params.api;
|
|
|
|
this.gridColumnApi = params.columnApi;
|
|
|
|
},
|
|
|
|
handleReceiveMessage (event) {
|
|
|
|
const eventData = this.parseEventData(event.data);
|
2022-10-11 16:43:46 +00:00
|
|
|
const res = this.gridApi.applyTransaction({
|
|
|
|
add: [eventData]
|
2022-10-10 23:27:31 +00:00
|
|
|
});
|
2022-10-11 16:43:46 +00:00
|
|
|
const rowNode = res.add[0]
|
|
|
|
this.gridApi.flashCells({ rowNodes: [rowNode]});
|
2022-10-05 14:44:28 +00:00
|
|
|
this.gridApi.sizeColumnsToFit()
|
|
|
|
},
|
|
|
|
parseEventData (eventData) {
|
|
|
|
try {
|
|
|
|
let json = JSON.parse(eventData)
|
|
|
|
if (!json.message) {
|
|
|
|
json.message = JSON.stringify(json.json)
|
|
|
|
}
|
|
|
|
return json
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e, eventData)
|
|
|
|
}
|
|
|
|
},
|
2022-10-11 16:43:12 +00:00
|
|
|
openExamineLog (row) {
|
|
|
|
const selectedRow = row.data
|
|
|
|
row.node.setSelected(false)
|
2022-10-11 16:16:27 +00:00
|
|
|
this.examineLog = true
|
|
|
|
const flattened = flattenObj(selectedRow)
|
|
|
|
const pairs = [];
|
|
|
|
Object.keys(flattened).map((key) => {
|
|
|
|
pairs.push({
|
|
|
|
key: key,
|
|
|
|
value: flattened[key]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.examineLogContent = pairs
|
|
|
|
}
|
|
|
|
},
|
2022-10-05 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
2022-10-11 16:16:27 +00:00
|
|
|
const flattenObj = (ob) => {
|
|
|
|
let result = {};
|
|
|
|
for (const i in ob) {
|
|
|
|
if ((typeof ob[i]) === 'object' && !Array.isArray(ob[i])) {
|
|
|
|
const temp = flattenObj(ob[i]);
|
|
|
|
for (const j in temp) {
|
|
|
|
result[i + '.' + j] = temp[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result[i] = ob[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
2022-10-05 14:44:28 +00:00
|
|
|
</script>
|