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