mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
3175 - Enable listening to clearData action for Imagery (#4733)
* Add clearData listener for imageryData module * Remove commented out code * Updated imagery clear data test * Adjusted telemetry stub to return empty array if data cleared * Remove forced test * Restub telemetry before * Cleanup and reset clear data boolean after * Remove double blank line Co-authored-by: Scott Bell <scott@traclabs.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
parent
d4429f9686
commit
384e36920c
@ -190,7 +190,7 @@
|
||||
openmct.install(openmct.plugins.Filters(['table', 'telemetry.plot.overlay']));
|
||||
openmct.install(openmct.plugins.ObjectMigration());
|
||||
openmct.install(openmct.plugins.ClearData(
|
||||
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked'],
|
||||
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked', 'example.imagery'],
|
||||
{indicator: true}
|
||||
));
|
||||
openmct.install(openmct.plugins.Clock({ enableClockIndicator: true }));
|
||||
|
@ -185,10 +185,14 @@ describe('The Clear Data Plugin:', () => {
|
||||
beforeEach((done) => {
|
||||
openmct = createOpenMct();
|
||||
|
||||
clearDataPlugin = new ClearDataPlugin(
|
||||
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked'],
|
||||
{indicator: true}
|
||||
);
|
||||
clearDataPlugin = new ClearDataPlugin([
|
||||
'table',
|
||||
'telemetry.plot.overlay',
|
||||
'telemetry.plot.stacked',
|
||||
'example.imagery'
|
||||
], {
|
||||
indicator: true
|
||||
});
|
||||
openmct.install(clearDataPlugin);
|
||||
appHolder = document.createElement('div');
|
||||
document.body.appendChild(appHolder);
|
||||
|
@ -30,6 +30,7 @@ export default {
|
||||
this.timeSystemChange = this.timeSystemChange.bind(this);
|
||||
this.setDataTimeContext = this.setDataTimeContext.bind(this);
|
||||
this.setDataTimeContext();
|
||||
this.openmct.objectViews.on('clearData', this.clearData);
|
||||
|
||||
// set
|
||||
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
@ -54,6 +55,7 @@ export default {
|
||||
}
|
||||
|
||||
this.stopFollowingDataTimeContext();
|
||||
this.openmct.objectViews.off('clearData', this.clearData);
|
||||
},
|
||||
methods: {
|
||||
setDataTimeContext() {
|
||||
@ -151,6 +153,25 @@ export default {
|
||||
this.imageHistory = imagery;
|
||||
}
|
||||
},
|
||||
clearData(domainObjectToClear) {
|
||||
// global clearData button is accepted therefore no truthy check on inputted param
|
||||
const clearDataForObjectSelected = Boolean(domainObjectToClear);
|
||||
if (clearDataForObjectSelected) {
|
||||
const idsEqual = this.openmct.objects.areIdsEqual(
|
||||
domainObjectToClear.identifier,
|
||||
this.domainObject.identifier
|
||||
);
|
||||
if (!idsEqual) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// splice array to encourage garbage collection
|
||||
this.imageHistory.splice(0, this.imageHistory.length);
|
||||
|
||||
// requesting history effectively clears imageHistory array
|
||||
return this.requestHistory();
|
||||
},
|
||||
timeSystemChange() {
|
||||
this.timeSystem = this.timeContext.timeSystem();
|
||||
this.timeKey = this.timeSystem.key;
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
resetApplicationState,
|
||||
simulateKeyEvent
|
||||
} from 'utils/testing';
|
||||
import ClearDataPlugin from '../clearData/plugin';
|
||||
|
||||
const ONE_MINUTE = 1000 * 60;
|
||||
const TEN_MINUTES = ONE_MINUTE * 10;
|
||||
@ -83,6 +84,7 @@ describe("The Imagery View Layouts", () => {
|
||||
let telemetryPromise;
|
||||
let telemetryPromiseResolve;
|
||||
let cleanupFirst;
|
||||
let isClearDataTriggered;
|
||||
|
||||
let openmct;
|
||||
let parent;
|
||||
@ -201,6 +203,10 @@ describe("The Imagery View Layouts", () => {
|
||||
});
|
||||
|
||||
spyOn(openmct.telemetry, 'request').and.callFake(() => {
|
||||
if (isClearDataTriggered) {
|
||||
return [];
|
||||
}
|
||||
|
||||
telemetryPromiseResolve(imageTelemetry);
|
||||
|
||||
return telemetryPromise;
|
||||
@ -323,6 +329,8 @@ describe("The Imagery View Layouts", () => {
|
||||
let applicableViews;
|
||||
let imageryViewProvider;
|
||||
let imageryView;
|
||||
let clearDataPlugin;
|
||||
let clearDataAction;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -330,16 +338,21 @@ describe("The Imagery View Layouts", () => {
|
||||
imageryViewProvider = applicableViews.find(viewProvider => viewProvider.key === imageryKey);
|
||||
imageryView = imageryViewProvider.view(imageryObject, [imageryObject]);
|
||||
imageryView.show(child);
|
||||
clearDataPlugin = new ClearDataPlugin(
|
||||
['example.imagery'],
|
||||
{indicator: true}
|
||||
);
|
||||
openmct.install(clearDataPlugin);
|
||||
clearDataAction = openmct.actions.getAction('clear-data-action');
|
||||
|
||||
return Vue.nextTick();
|
||||
});
|
||||
|
||||
// afterEach(() => {
|
||||
// openmct.time.stopClock();
|
||||
// openmct.router.removeListener('change:hash', resolveFunction);
|
||||
//
|
||||
// imageryView.destroy();
|
||||
// });
|
||||
afterEach(() => {
|
||||
isClearDataTriggered = false;
|
||||
// openmct.time.stopClock();
|
||||
// openmct.router.removeListener('change:hash', resolveFunction);
|
||||
// imageryView.destroy();
|
||||
});
|
||||
|
||||
it("on mount should show the the most recent image", (done) => {
|
||||
//Looks like we need Vue.nextTick here so that computed properties settle down
|
||||
@ -470,6 +483,21 @@ describe("The Imagery View Layouts", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
it('clear data action is installed', () => {
|
||||
expect(clearDataAction).toBeDefined();
|
||||
});
|
||||
|
||||
it('on clearData action should clear data for object is selected', (done) => {
|
||||
expect(parent.querySelectorAll('.c-imagery__thumb').length).not.toBe(0);
|
||||
openmct.objectViews.on('clearData', async (_domainObject) => {
|
||||
await Vue.nextTick();
|
||||
expect(parent.querySelectorAll('.c-imagery__thumb').length).toBe(0);
|
||||
done();
|
||||
});
|
||||
// stubbed telemetry data will return empty array when true
|
||||
isClearDataTriggered = true;
|
||||
clearDataAction.invoke(imageryObject);
|
||||
});
|
||||
});
|
||||
|
||||
describe("imagery time strip view", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user