Initial query mechanism
This commit is contained in:
parent
63b2fb2c20
commit
258571a064
@ -71,7 +71,9 @@ export default {
|
||||
},
|
||||
created() {
|
||||
// TODO: monitor actual URL.
|
||||
this.setFilterQuery({})
|
||||
this.setFilterQuery({
|
||||
'initial': 'true'
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
@ -85,11 +87,13 @@ export default {
|
||||
for (const key in this.filterQuery) {
|
||||
url.searchParams.append(key, this.filterQuery[key]);
|
||||
}
|
||||
if (url.searchParams.keys().next()) {
|
||||
let es = new EventSource(url.toString());
|
||||
es.onmessage = (e) => this.handleReceiveMessage(e)
|
||||
es.addEventListener("filters", (e) => this.handleReceiveFilters(e))
|
||||
es.addEventListener("timeout", (e) => this.handleReceiveTimeout(e))
|
||||
this.es = es
|
||||
}
|
||||
},
|
||||
onGridReady(params) {
|
||||
this.gridApi = params.api;
|
||||
@ -125,6 +129,8 @@ export default {
|
||||
},
|
||||
handleReceiveMessage (event) {
|
||||
const eventData = parseEventData(event.data);
|
||||
// TODO: Duplicate rows might be added. I don't want to seek for every row to be included, but use other ways that would never pull duplicate rows.
|
||||
// Maybe it's still necessary to filter here, don't know yet.
|
||||
this.gridApi.applyTransactionAsync({
|
||||
add: [eventData]
|
||||
}, (res) => {
|
||||
|
@ -29,12 +29,17 @@ const store = createStore({
|
||||
state.filterOptions = payload
|
||||
},
|
||||
SET_FILTER_QUERY(state, payload) {
|
||||
state.filterQuery = payload
|
||||
let query = payload
|
||||
if (Object.keys(state.filterOptions).length) {
|
||||
query['initial'] = false
|
||||
}
|
||||
state.filterQuery = query
|
||||
},
|
||||
TOGGLE_FILTER_QUERY_STREAMING(state) {
|
||||
let query = state.filterQuery
|
||||
query['streaming'] = (query['streaming'] === undefined) ? false : query['streaming']
|
||||
query['streaming'] = !(query['streaming'])
|
||||
query['initial'] = false
|
||||
state.filterQuery = query
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user