Store query as object not array
This commit is contained in:
		| @@ -26,7 +26,7 @@ import ExamineLogModal from "./Modal/ExamineLogModal.vue"; | |||||||
| import ComboboxFilter from "./Filter/ComboboxFilter.js"; | import ComboboxFilter from "./Filter/ComboboxFilter.js"; | ||||||
| import flattenObj from "../helpers/flattenObj"; | import flattenObj from "../helpers/flattenObj"; | ||||||
| import parseEventData from "../helpers/parseEventData"; | import parseEventData from "../helpers/parseEventData"; | ||||||
| import { mapActions } from 'vuex'; | import {mapActions, mapGetters} from 'vuex'; | ||||||
| import config from "./Grid/Main/config"; | import config from "./Grid/Main/config"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
| @@ -57,7 +57,7 @@ export default { | |||||||
|   }, |   }, | ||||||
|   created() { |   created() { | ||||||
|     // TODO: monitor actual URL |     // TODO: monitor actual URL | ||||||
|     this.setFilterQuery([]) |     this.setFilterQuery({}) | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|     ...mapActions({ |     ...mapActions({ | ||||||
| @@ -67,9 +67,9 @@ export default { | |||||||
|     setupStream() { |     setupStream() { | ||||||
|       this.es && this.es.close(); |       this.es && this.es.close(); | ||||||
|       let url = new URL('/events', window.location.href); |       let url = new URL('/events', window.location.href); | ||||||
|       this.filterQuery.map((e) => { |       for (const key in this.filterQuery) { | ||||||
|         url.searchParams.append(e.key, e.value); |         url.searchParams.append(key, this.filterQuery[key]); | ||||||
|       }) |       } | ||||||
|       let es = new EventSource(url.toString()); |       let es = new EventSource(url.toString()); | ||||||
|       es.onmessage = (e) => this.handleReceiveMessage(e) |       es.onmessage = (e) => this.handleReceiveMessage(e) | ||||||
|       es.addEventListener("filters", (e) => this.handleReceiveFilters(e)) |       es.addEventListener("filters", (e) => this.handleReceiveFilters(e)) | ||||||
| @@ -88,7 +88,7 @@ export default { | |||||||
|       this.gridApi.addGlobalListener((type, event) => { |       this.gridApi.addGlobalListener((type, event) => { | ||||||
|         if (type === 'filterChanged') { |         if (type === 'filterChanged') { | ||||||
|           let changedColumn = event.columns[0] ? (event.columns[0].colId) : null |           let changedColumn = event.columns[0] ? (event.columns[0].colId) : null | ||||||
|           let query = [] |           let query = {} | ||||||
|           let gridColumns = event.columnApi.columnModel.gridColumns |           let gridColumns = event.columnApi.columnModel.gridColumns | ||||||
|           gridColumns.map((column) => { |           gridColumns.map((column) => { | ||||||
|             // Reset child column filter if parent changed |             // Reset child column filter if parent changed | ||||||
| @@ -100,10 +100,7 @@ export default { | |||||||
|               this.gridApi.onFilterChanged(); |               this.gridApi.onFilterChanged(); | ||||||
|             } |             } | ||||||
|             if (column.filterActive) { |             if (column.filterActive) { | ||||||
|               query.push({ |               query[column.colId] = column.filterActive | ||||||
|                 key: column.colId, |  | ||||||
|                 value: column.filterActive |  | ||||||
|               }) |  | ||||||
|             } |             } | ||||||
|           }) |           }) | ||||||
|           this.setFilterQuery(query) |           this.setFilterQuery(query) | ||||||
|   | |||||||
| @@ -3,7 +3,12 @@ import { createStore } from "vuex" | |||||||
| const store = createStore({ | const store = createStore({ | ||||||
|   state: { |   state: { | ||||||
|     filterOptions: {}, |     filterOptions: {}, | ||||||
|     filterQuery: [] |     filterQuery: {} | ||||||
|  |   }, | ||||||
|  |   getters: { | ||||||
|  |     filterQuery (state) { | ||||||
|  |       return state.filterQuery | ||||||
|  |     } | ||||||
|   }, |   }, | ||||||
|   actions: { |   actions: { | ||||||
|     setFilterOptions(context, payload) { |     setFilterOptions(context, payload) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user