Initial query mechanism
This commit is contained in:
parent
63b2fb2c20
commit
258571a064
|
@ -71,7 +71,9 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// TODO: monitor actual URL.
|
// TODO: monitor actual URL.
|
||||||
this.setFilterQuery({})
|
this.setFilterQuery({
|
||||||
|
'initial': 'true'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
|
@ -85,11 +87,13 @@ export default {
|
||||||
for (const key in this.filterQuery) {
|
for (const key in this.filterQuery) {
|
||||||
url.searchParams.append(key, this.filterQuery[key]);
|
url.searchParams.append(key, this.filterQuery[key]);
|
||||||
}
|
}
|
||||||
|
if (url.searchParams.keys().next()) {
|
||||||
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))
|
||||||
es.addEventListener("timeout", (e) => this.handleReceiveTimeout(e))
|
es.addEventListener("timeout", (e) => this.handleReceiveTimeout(e))
|
||||||
this.es = es
|
this.es = es
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onGridReady(params) {
|
onGridReady(params) {
|
||||||
this.gridApi = params.api;
|
this.gridApi = params.api;
|
||||||
|
@ -125,6 +129,8 @@ export default {
|
||||||
},
|
},
|
||||||
handleReceiveMessage (event) {
|
handleReceiveMessage (event) {
|
||||||
const eventData = parseEventData(event.data);
|
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({
|
this.gridApi.applyTransactionAsync({
|
||||||
add: [eventData]
|
add: [eventData]
|
||||||
}, (res) => {
|
}, (res) => {
|
||||||
|
|
|
@ -29,12 +29,17 @@ const store = createStore({
|
||||||
state.filterOptions = payload
|
state.filterOptions = payload
|
||||||
},
|
},
|
||||||
SET_FILTER_QUERY(state, 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) {
|
TOGGLE_FILTER_QUERY_STREAMING(state) {
|
||||||
let query = state.filterQuery
|
let query = state.filterQuery
|
||||||
query['streaming'] = (query['streaming'] === undefined) ? false : query['streaming']
|
query['streaming'] = (query['streaming'] === undefined) ? false : query['streaming']
|
||||||
query['streaming'] = !(query['streaming'])
|
query['streaming'] = !(query['streaming'])
|
||||||
|
query['initial'] = false
|
||||||
state.filterQuery = query
|
state.filterQuery = query
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue