mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +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:
@ -202,8 +202,13 @@ class IndependentTimeContext extends TimeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUpstreamContext() {
|
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) => {
|
this.objectPath.some((item, index) => {
|
||||||
const key = this.openmct.objects.makeKeyString(item.identifier);
|
const key = this.openmct.objects.makeKeyString(item.identifier);
|
||||||
//last index is the view object itself
|
//last index is the view object itself
|
||||||
|
@ -31,8 +31,8 @@ export default class OpenInNewTab {
|
|||||||
|
|
||||||
this._openmct = openmct;
|
this._openmct = openmct;
|
||||||
}
|
}
|
||||||
invoke(objectPath) {
|
invoke(objectPath, urlParams = undefined) {
|
||||||
let url = objectPathToUrl(this._openmct, objectPath);
|
let url = objectPathToUrl(this._openmct, objectPath, urlParams);
|
||||||
window.open(url);
|
window.open(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,10 +383,8 @@ export default {
|
|||||||
},
|
},
|
||||||
setTimeContext() {
|
setTimeContext() {
|
||||||
this.stopFollowingTimeContext();
|
this.stopFollowingTimeContext();
|
||||||
|
|
||||||
this.timeContext = this.openmct.time.getContextForView(this.path);
|
this.timeContext = this.openmct.time.getContextForView(this.path);
|
||||||
this.followTimeContext();
|
this.followTimeContext();
|
||||||
|
|
||||||
},
|
},
|
||||||
followTimeContext() {
|
followTimeContext() {
|
||||||
this.updateDisplayBounds(this.timeContext.bounds());
|
this.updateDisplayBounds(this.timeContext.bounds());
|
||||||
|
@ -24,9 +24,27 @@
|
|||||||
* Module defining url handling.
|
* Module defining url handling.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function paramsToArray(openmct) {
|
function getUrlParams(openmct, customUrlParams = {}) {
|
||||||
// parse urlParams from an object to an array.
|
|
||||||
let urlParams = openmct.router.getParams();
|
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 = [];
|
let newTabParams = [];
|
||||||
for (let key in urlParams) {
|
for (let key in urlParams) {
|
||||||
if ({}.hasOwnProperty.call(urlParams, key)) {
|
if ({}.hasOwnProperty.call(urlParams, key)) {
|
||||||
@ -42,9 +60,9 @@ export function identifierToString(openmct, objectPath) {
|
|||||||
return '#/browse/' + openmct.objects.getRelativePath(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 url = identifierToString(openmct, objectPath);
|
||||||
let urlParams = paramsToArray(openmct);
|
let urlParams = paramsToArray(openmct, customUrlParams);
|
||||||
if (urlParams.length) {
|
if (urlParams.length) {
|
||||||
url += '?' + urlParams.join('&');
|
url += '?' + urlParams.join('&');
|
||||||
}
|
}
|
||||||
|
@ -66,5 +66,14 @@ describe('the url tool', function () {
|
|||||||
const constructedURL = objectPathToUrl(openmct, mockObjectPath);
|
const constructedURL = objectPathToUrl(openmct, mockObjectPath);
|
||||||
expect(constructedURL).toContain('#/browse/mock-parent-folder/mock-folder');
|
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 ObjectView from './ObjectView.vue';
|
||||||
import StackedPlot from '../../plugins/plot/stackedPlot/StackedPlot.vue';
|
import StackedPlot from '../../plugins/plot/stackedPlot/StackedPlot.vue';
|
||||||
|
import Plot from '../../plugins/plot/Plot.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ObjectView,
|
ObjectView,
|
||||||
StackedPlot
|
StackedPlot,
|
||||||
|
Plot
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user