Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/247 global filter UI #249

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,28 @@
},

/**
* Enable global filters for ALL telemetry requests that support the filter
* Enable global filters for ALL telemetry requests that support the filter.
mudinthewater marked this conversation as resolved.
Show resolved Hide resolved
* Telemetry filters modify the 'filter' field in queries to MCWS.
*
* key property is required and other options are optional
* globalFilters: array, optional - list of global filters to configure.
* * key: string, required. Filter column, e.g. vcid
* * name: string, required. Identifier of the filter in the selection window.
* * icon: 'icon-flag', string, icon. Not implemented - potentially icon for minimized filter list.
mudinthewater marked this conversation as resolved.
Show resolved Hide resolved
* * filter: object, required. Filter object to implement
* * * comparator: string, required. currently supports 'equals'
* * * singleSelectionThreshold: boolean, required. currently supports true only.
* * * defaultLabel: string, optional. Defaults to 'None'. Label to show if filter inactive.
* * * possibleValues: array, required. List of values and labels for filter.
* * * * label: string, required. Label to show in filter selection dropdown.
* * * * value: string, required. value to set parameter to in filtered query.
* How to use:
* The global filters will be available from the Global Filters indicator
* The global filters will be available from the Global Filters indicator.
* Enable a filter by selecting the desired filter from the dropdown and hitting update.
* Outgoing requests that use the 'filter' parameter to MCWS will be modified with your filter.
* example below, selecting 'A side' will ensure that the filter parameter in mcws includes:
* vcid='1,2,3'. Note that poorly formatted filters may not pass MCWS API validation.
*
*/
/*
globalFilters: [
Expand All @@ -452,6 +470,7 @@
filter: {
comparator: 'equals',
singleSelectionThreshold: true,
defaultLabel: "A & B",
possibleValues: [
{
label: 'A Side',
Expand All @@ -470,6 +489,7 @@
filter: {
comparator: 'equals',
singleSelectionThreshold: true,
defaultLabel: "REC & RLT",
possibleValues: [
{
label: 'Realtime',
Expand Down
7 changes: 5 additions & 2 deletions src/globalFilters/FilterField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
name="setSelectionThreshold"
@change="updateFilterValueFromDropdown($event, filter.comparator, $event.target.value)"
>
<option key="NONE" value="NONE">
None
<option value="NONE">
{{ defaultLabel }}
davetsay marked this conversation as resolved.
Show resolved Hide resolved
</option>
<option
v-for="option in filter.possibleValues"
Expand Down Expand Up @@ -53,6 +53,9 @@ export default {
computed: {
name() {
return this.filterName || this.filterKey;
},
defaultLabel(){
return this.filter.defaultLabel ?? 'None';
}
},
data() {
Expand Down
8 changes: 5 additions & 3 deletions src/globalFilters/GlobalFilterSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
</button>
</div>
</div>

</template>

<script>
import FilterField from './FilterField.vue';
import { toRaw } from 'vue';

export default {
inject: [
Expand Down Expand Up @@ -68,8 +70,8 @@ export default {
};
},
mounted() {
this.updatedFilters = structuredClone(this.activeFilters);

this.updatedFilters = structuredClone(toRaw(this.activeFilters));
davetsay marked this conversation as resolved.
Show resolved Hide resolved
this.openOverlay();
},
methods: {
Expand All @@ -84,7 +86,7 @@ export default {
this.updatedFilters[key][comparator] = value;
},
updateFilters() {
this.$emit('update-filters', this.updatedFilters);
this.$emit('update-filters', toRaw(this.updatedFilters));

this.closeOverlay();
},
Expand All @@ -94,7 +96,7 @@ export default {
openOverlay() {
this.overlay = this.openmct.overlays.overlay({
element: this.$el,
size: 'small',
mudinthewater marked this conversation as resolved.
Show resolved Hide resolved
size: 'fit',
dismissable: true,
onDestroy: () => {
this.$emit('close-filter-selector');
Expand Down
4 changes: 1 addition & 3 deletions src/services/filtering/FilterService.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { EventEmitter } from 'eventemitter3';
import FilterURLHandler from './FilterUrlHandler';
import isEqual from 'lodash/isequal';
import pickBy from 'lodash/pickby';
import isEmpty from 'lodash/isempty';
import { isEqual, pickBy, isEmpty } from 'lodash';

class FilterService extends EventEmitter {
constructor(openmct, config) {
Expand Down
3 changes: 1 addition & 2 deletions src/services/filtering/FilterUrlHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import isEqual from 'lodash/isequal';
import isEmpty from 'lodash/isempty';
import { isEqual, isEmpty } from 'lodash';

const GLOBAL_FILTER_PARAM_PREFIX = "global_filter_"

Expand Down
Loading