Skip to content

Commit

Permalink
disable filterService if no global filters defined (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
davetsay authored Aug 14, 2023
1 parent cb8c7ae commit d68627e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
23 changes: 13 additions & 10 deletions src/historical/HistoricalProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,19 @@ define([
}

const filterService = filterServiceDefault.default();
const globalFilters = filterService.getActiveFilters();

Object.entries(globalFilters).forEach(([key, filter]) => {
const domainObjectFiltersKeys = Object.keys(params.filter);
if (domainObjectFiltersKeys.includes(key)) {
this.openmct.notifications.alert(`A view filter is overriding a global filter for '${key}'`);
} else {
params.filter[key] = filter['equals'];
}
})

if (filterService) {
const globalFilters = filterService.getActiveFilters();

Object.entries(globalFilters).forEach(([key, filter]) => {
const domainObjectFiltersKeys = Object.keys(params.filter);
if (domainObjectFiltersKeys.includes(key)) {
this.openmct.notifications.alert(`A view filter is overriding a global filter for '${key}'`);
} else {
params.filter[key] = filter['equals'];
}
});
}

if (provider.batchId) {
return this.doQueuedRequest(domainObject, options, params, provider);
Expand Down
17 changes: 10 additions & 7 deletions src/realtime/MCWSStreamProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ define([
this.sessions.listen(updateTopic);

// global filters
const updateGlobalFilters = function (filters) {
const serializedFilters = this.serializeFilters(filters);
this.notifyWorker('globalFilters', serializedFilters);
}.bind(this);

updateGlobalFilters(this.filterService.getActiveFilters());
if (this.filterService) {
const updateGlobalFilters = function (filters) {
const serializedFilters = this.serializeFilters(filters);
this.notifyWorker('globalFilters', serializedFilters);
}.bind(this);

updateGlobalFilters(this.filterService.getActiveFilters());

this.filterService.on('update', updateGlobalFilters);

this.filterService.on('update', updateGlobalFilters);
}

return worker;
};
Expand Down
8 changes: 6 additions & 2 deletions src/services/filtering/FilterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ class FilterService extends EventEmitter {
let filterServiceInstance = null;

export default function(openmct, config) {
if (!filterServiceInstance) {
filterServiceInstance = new FilterService(openmct, config);
if (filterServiceInstance) {
return filterServiceInstance;
}

if (config) {
filterServiceInstance = new FilterService(openmct, config);
}

return filterServiceInstance;
Expand Down

0 comments on commit d68627e

Please sign in to comment.