mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
[MMGIS] Modify Independent time contexts, open in new tab action, and expose overlay plots to support MMGIS pivoting (#6025)
* Expose overlay plot so that it can be imported by an external plugin * If the current object has an independentContext, ignore any upstream independentContext * Accept any custom url param in open in new tab action
This commit is contained in:
parent
a168ce25cf
commit
19892aab53
@ -202,8 +202,13 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
|
||||
getUpstreamContext() {
|
||||
let timeContext = this.globalTimeContext;
|
||||
const objectKey = this.openmct.objects.makeKeyString(this.objectPath[this.objectPath.length - 1].identifier);
|
||||
const doesObjectHaveTimeContext = this.globalTimeContext.independentContexts.get(objectKey);
|
||||
if (doesObjectHaveTimeContext) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let timeContext = this.globalTimeContext;
|
||||
this.objectPath.some((item, index) => {
|
||||
const key = this.openmct.objects.makeKeyString(item.identifier);
|
||||
//last index is the view object itself
|
||||
|
@ -31,8 +31,8 @@ export default class OpenInNewTab {
|
||||
|
||||
this._openmct = openmct;
|
||||
}
|
||||
invoke(objectPath) {
|
||||
let url = objectPathToUrl(this._openmct, objectPath);
|
||||
invoke(objectPath, urlParams = undefined) {
|
||||
let url = objectPathToUrl(this._openmct, objectPath, urlParams);
|
||||
window.open(url);
|
||||
}
|
||||
}
|
||||
|
@ -383,10 +383,8 @@ export default {
|
||||
},
|
||||
setTimeContext() {
|
||||
this.stopFollowingTimeContext();
|
||||
|
||||
this.timeContext = this.openmct.time.getContextForView(this.path);
|
||||
this.followTimeContext();
|
||||
|
||||
},
|
||||
followTimeContext() {
|
||||
this.updateDisplayBounds(this.timeContext.bounds());
|
||||
|
@ -24,9 +24,27 @@
|
||||
* Module defining url handling.
|
||||
*/
|
||||
|
||||
export function paramsToArray(openmct) {
|
||||
// parse urlParams from an object to an array.
|
||||
function getUrlParams(openmct, customUrlParams = {}) {
|
||||
let urlParams = openmct.router.getParams();
|
||||
Object.entries(customUrlParams).forEach((urlParam) => {
|
||||
const [key, value] = urlParam;
|
||||
urlParams[key] = value;
|
||||
});
|
||||
|
||||
if (urlParams['tc.mode'] === 'fixed') {
|
||||
delete urlParams['tc.startDelta'];
|
||||
delete urlParams['tc.endDelta'];
|
||||
} else if (urlParams['tc.mode'] === 'local') {
|
||||
delete urlParams['tc.startBound'];
|
||||
delete urlParams['tc.endBound'];
|
||||
}
|
||||
|
||||
return urlParams;
|
||||
}
|
||||
|
||||
export function paramsToArray(openmct, customUrlParams = {}) {
|
||||
// parse urlParams from an object to an array.
|
||||
let urlParams = getUrlParams(openmct, customUrlParams);
|
||||
let newTabParams = [];
|
||||
for (let key in urlParams) {
|
||||
if ({}.hasOwnProperty.call(urlParams, key)) {
|
||||
@ -42,9 +60,9 @@ export function identifierToString(openmct, objectPath) {
|
||||
return '#/browse/' + openmct.objects.getRelativePath(objectPath);
|
||||
}
|
||||
|
||||
export default function objectPathToUrl(openmct, objectPath) {
|
||||
export default function objectPathToUrl(openmct, objectPath, customUrlParams = {}) {
|
||||
let url = identifierToString(openmct, objectPath);
|
||||
let urlParams = paramsToArray(openmct);
|
||||
let urlParams = paramsToArray(openmct, customUrlParams);
|
||||
if (urlParams.length) {
|
||||
url += '?' + urlParams.join('&');
|
||||
}
|
||||
|
@ -66,5 +66,14 @@ describe('the url tool', function () {
|
||||
const constructedURL = objectPathToUrl(openmct, mockObjectPath);
|
||||
expect(constructedURL).toContain('#/browse/mock-parent-folder/mock-folder');
|
||||
});
|
||||
it('can take params to set a custom url', () => {
|
||||
const customParams = {
|
||||
'tc.startBound': 1669911059,
|
||||
'tc.endBound': 1669911082,
|
||||
'tc.mode': 'fixed'
|
||||
};
|
||||
const constructedURL = objectPathToUrl(openmct, mockObjectPath, customParams);
|
||||
expect(constructedURL).toContain('tc.startBound=1669911059&tc.endBound=1669911082&tc.mode=fixed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
import ObjectView from './ObjectView.vue';
|
||||
import StackedPlot from '../../plugins/plot/stackedPlot/StackedPlot.vue';
|
||||
import Plot from '../../plugins/plot/Plot.vue';
|
||||
|
||||
export default {
|
||||
ObjectView,
|
||||
StackedPlot
|
||||
StackedPlot,
|
||||
Plot
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user