mirror of
https://github.com/nasa/openmct.git
synced 2025-06-09 19:01:40 +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.Filters(['table', 'telemetry.plot.overlay']));
|
||||||
openmct.install(openmct.plugins.ObjectMigration());
|
openmct.install(openmct.plugins.ObjectMigration());
|
||||||
openmct.install(openmct.plugins.ClearData(
|
openmct.install(openmct.plugins.ClearData(
|
||||||
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked'],
|
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked', 'example.imagery'],
|
||||||
{indicator: true}
|
{indicator: true}
|
||||||
));
|
));
|
||||||
openmct.install(openmct.plugins.Clock({ enableClockIndicator: true }));
|
openmct.install(openmct.plugins.Clock({ enableClockIndicator: true }));
|
||||||
|
@ -185,10 +185,14 @@ describe('The Clear Data Plugin:', () => {
|
|||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
clearDataPlugin = new ClearDataPlugin(
|
clearDataPlugin = new ClearDataPlugin([
|
||||||
['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked'],
|
'table',
|
||||||
{indicator: true}
|
'telemetry.plot.overlay',
|
||||||
);
|
'telemetry.plot.stacked',
|
||||||
|
'example.imagery'
|
||||||
|
], {
|
||||||
|
indicator: true
|
||||||
|
});
|
||||||
openmct.install(clearDataPlugin);
|
openmct.install(clearDataPlugin);
|
||||||
appHolder = document.createElement('div');
|
appHolder = document.createElement('div');
|
||||||
document.body.appendChild(appHolder);
|
document.body.appendChild(appHolder);
|
||||||
|
@ -30,6 +30,7 @@ export default {
|
|||||||
this.timeSystemChange = this.timeSystemChange.bind(this);
|
this.timeSystemChange = this.timeSystemChange.bind(this);
|
||||||
this.setDataTimeContext = this.setDataTimeContext.bind(this);
|
this.setDataTimeContext = this.setDataTimeContext.bind(this);
|
||||||
this.setDataTimeContext();
|
this.setDataTimeContext();
|
||||||
|
this.openmct.objectViews.on('clearData', this.clearData);
|
||||||
|
|
||||||
// set
|
// set
|
||||||
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
@ -54,6 +55,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.stopFollowingDataTimeContext();
|
this.stopFollowingDataTimeContext();
|
||||||
|
this.openmct.objectViews.off('clearData', this.clearData);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setDataTimeContext() {
|
setDataTimeContext() {
|
||||||
@ -151,6 +153,25 @@ export default {
|
|||||||
this.imageHistory = imagery;
|
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() {
|
timeSystemChange() {
|
||||||
this.timeSystem = this.timeContext.timeSystem();
|
this.timeSystem = this.timeContext.timeSystem();
|
||||||
this.timeKey = this.timeSystem.key;
|
this.timeKey = this.timeSystem.key;
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
resetApplicationState,
|
resetApplicationState,
|
||||||
simulateKeyEvent
|
simulateKeyEvent
|
||||||
} from 'utils/testing';
|
} from 'utils/testing';
|
||||||
|
import ClearDataPlugin from '../clearData/plugin';
|
||||||
|
|
||||||
const ONE_MINUTE = 1000 * 60;
|
const ONE_MINUTE = 1000 * 60;
|
||||||
const TEN_MINUTES = ONE_MINUTE * 10;
|
const TEN_MINUTES = ONE_MINUTE * 10;
|
||||||
@ -83,6 +84,7 @@ describe("The Imagery View Layouts", () => {
|
|||||||
let telemetryPromise;
|
let telemetryPromise;
|
||||||
let telemetryPromiseResolve;
|
let telemetryPromiseResolve;
|
||||||
let cleanupFirst;
|
let cleanupFirst;
|
||||||
|
let isClearDataTriggered;
|
||||||
|
|
||||||
let openmct;
|
let openmct;
|
||||||
let parent;
|
let parent;
|
||||||
@ -201,6 +203,10 @@ describe("The Imagery View Layouts", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
spyOn(openmct.telemetry, 'request').and.callFake(() => {
|
spyOn(openmct.telemetry, 'request').and.callFake(() => {
|
||||||
|
if (isClearDataTriggered) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
telemetryPromiseResolve(imageTelemetry);
|
telemetryPromiseResolve(imageTelemetry);
|
||||||
|
|
||||||
return telemetryPromise;
|
return telemetryPromise;
|
||||||
@ -323,6 +329,8 @@ describe("The Imagery View Layouts", () => {
|
|||||||
let applicableViews;
|
let applicableViews;
|
||||||
let imageryViewProvider;
|
let imageryViewProvider;
|
||||||
let imageryView;
|
let imageryView;
|
||||||
|
let clearDataPlugin;
|
||||||
|
let clearDataAction;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
@ -330,16 +338,21 @@ describe("The Imagery View Layouts", () => {
|
|||||||
imageryViewProvider = applicableViews.find(viewProvider => viewProvider.key === imageryKey);
|
imageryViewProvider = applicableViews.find(viewProvider => viewProvider.key === imageryKey);
|
||||||
imageryView = imageryViewProvider.view(imageryObject, [imageryObject]);
|
imageryView = imageryViewProvider.view(imageryObject, [imageryObject]);
|
||||||
imageryView.show(child);
|
imageryView.show(child);
|
||||||
|
clearDataPlugin = new ClearDataPlugin(
|
||||||
|
['example.imagery'],
|
||||||
|
{indicator: true}
|
||||||
|
);
|
||||||
|
openmct.install(clearDataPlugin);
|
||||||
|
clearDataAction = openmct.actions.getAction('clear-data-action');
|
||||||
|
|
||||||
return Vue.nextTick();
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
afterEach(() => {
|
||||||
// afterEach(() => {
|
isClearDataTriggered = false;
|
||||||
// openmct.time.stopClock();
|
// openmct.time.stopClock();
|
||||||
// openmct.router.removeListener('change:hash', resolveFunction);
|
// openmct.router.removeListener('change:hash', resolveFunction);
|
||||||
//
|
|
||||||
// imageryView.destroy();
|
// imageryView.destroy();
|
||||||
// });
|
});
|
||||||
|
|
||||||
it("on mount should show the the most recent image", (done) => {
|
it("on mount should show the the most recent image", (done) => {
|
||||||
//Looks like we need Vue.nextTick here so that computed properties settle down
|
//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", () => {
|
describe("imagery time strip view", () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user