Get all possible filters from backend
This commit is contained in:
parent
97ad29ade0
commit
be79d178ff
@ -32,6 +32,12 @@ async function run() {
|
||||
changeStream = collection.watch(pipeline, options);
|
||||
console.log("Started watching changes in database");
|
||||
|
||||
const filterOptions = {
|
||||
'kubernetes.namespace': await collection.distinct('kubernetes.namespace'),
|
||||
'kubernetes.pod.name': await collection.distinct('kubernetes.pod.name'),
|
||||
'kubernetes.container.name': await collection.distinct('kubernetes.container.name')
|
||||
}
|
||||
|
||||
const writeMessage = (response, blob) => {
|
||||
const id = blob._id || null
|
||||
const message = `id: ${id}\nevent: message\ndata: ${JSON.stringify(blob)}\n\n`
|
||||
@ -45,6 +51,9 @@ async function run() {
|
||||
const header = { 'Content-Type': 'text/event-stream', 'Connection': 'keep-alive' };
|
||||
response.writeHead(200, "OK", header);
|
||||
|
||||
const message = `id: 1\nevent: filters\ndata: ${JSON.stringify(filterOptions)}\n\n`
|
||||
response.write(message)
|
||||
|
||||
const historyCursor = collection.find()
|
||||
.sort({$natural:-1})
|
||||
.limit(historyNumber).toArray().then((res) => {
|
||||
|
@ -44,6 +44,7 @@ export default {
|
||||
enableCellChangeFlash: true
|
||||
},
|
||||
currentRowCount: 0,
|
||||
comboBoxOptions: {},
|
||||
viewRowCount: 20,
|
||||
comboBoxOptions: [],
|
||||
columnDefs: [
|
||||
@ -88,6 +89,7 @@ export default {
|
||||
setupStream() {
|
||||
let es = new EventSource('/events');
|
||||
es.onmessage = (e) => this.handleReceiveMessage(e)
|
||||
es.addEventListener("filters", (e) => this.handleReceiveFilters(e))
|
||||
},
|
||||
onGridReady(params) {
|
||||
this.gridApi = params.api;
|
||||
@ -102,6 +104,9 @@ export default {
|
||||
this.gridApi.flashCells({ rowNodes: [rowNode]});
|
||||
this.gridApi.sizeColumnsToFit()
|
||||
},
|
||||
handleReceiveFilters (event) {
|
||||
this.comboBoxOptions = this.parseEventData(event.data);
|
||||
},
|
||||
parseEventData (eventData) {
|
||||
try {
|
||||
let json = JSON.parse(eventData)
|
||||
|
Loading…
Reference in New Issue
Block a user