mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 03:11:39 +00:00
Allow user to set machine-based preferences for main object views.
- Browse.js now sets currentViewKey in the right spot. - Changes in #viewObject reset.
This commit is contained in:
parent
2ae0982af1
commit
44e5021ec9
@ -379,7 +379,6 @@ export default {
|
|||||||
return JSON.parse(window.localStorage.getItem(LOCALSTORAGE_VIEW_PREFS)) || {};
|
return JSON.parse(window.localStorage.getItem(LOCALSTORAGE_VIEW_PREFS)) || {};
|
||||||
},
|
},
|
||||||
storeViewPrefs(view) {
|
storeViewPrefs(view) {
|
||||||
console.log('storeViewPrefs',this.domainObject.type,view);
|
|
||||||
let storedViews = this.retrieveViewPrefs();
|
let storedViews = this.retrieveViewPrefs();
|
||||||
storedViews[this.domainObject.type] = view;
|
storedViews[this.domainObject.type] = view;
|
||||||
window.localStorage.setItem(LOCALSTORAGE_VIEW_PREFS, JSON.stringify(storedViews));
|
window.localStorage.setItem(LOCALSTORAGE_VIEW_PREFS, JSON.stringify(storedViews));
|
||||||
|
@ -68,21 +68,16 @@ class Browse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#viewObject(object, viewProvider) {
|
#viewObject(object, viewProvider) {
|
||||||
// viewProvider is setting the 'view' param before this function is called.
|
|
||||||
this.#currentObjectPath = this.#openmct.router.path;
|
this.#currentObjectPath = this.#openmct.router.path;
|
||||||
// console.log('getSearchParam', this.#openmct.router.getSearchParam('view'));
|
|
||||||
console.log('#viewObject', this.#currentObjectPath, object, viewProvider);
|
|
||||||
const viewPrefs = JSON.parse(window.localStorage.getItem('openmct-stored-view-prefs')) || {};
|
|
||||||
const viewKey = viewPrefs[object.type] ? viewPrefs[object.type] : viewProvider.key;
|
|
||||||
|
|
||||||
this.#openmct.layout.$refs.browseObject.show(
|
this.#openmct.layout.$refs.browseObject.show(
|
||||||
object,
|
object,
|
||||||
viewKey,
|
viewProvider.key,
|
||||||
true,
|
true,
|
||||||
this.#currentObjectPath
|
this.#currentObjectPath
|
||||||
);
|
);
|
||||||
this.#openmct.layout.$refs.browseBar.domainObject = object;
|
this.#openmct.layout.$refs.browseBar.domainObject = object;
|
||||||
this.#openmct.layout.$refs.browseBar.viewKey = viewKey;
|
this.#openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
#handleBrowseObjectUpdate(newObject) {
|
#handleBrowseObjectUpdate(newObject) {
|
||||||
@ -126,6 +121,11 @@ class Browse {
|
|||||||
'*',
|
'*',
|
||||||
this.#handleBrowseObjectUpdate.bind(this)
|
this.#handleBrowseObjectUpdate.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!currentViewKey) {
|
||||||
|
currentViewKey = this.#getPreferredViewForObjectType(this.#browseObject);
|
||||||
|
}
|
||||||
|
|
||||||
const currentProvider = this.#openmct.objectViews.getByProviderKey(currentViewKey);
|
const currentProvider = this.#openmct.objectViews.getByProviderKey(currentViewKey);
|
||||||
if (currentProvider && currentProvider.canView(this.#browseObject, this.#openmct.router.path)) {
|
if (currentProvider && currentProvider.canView(this.#browseObject, this.#openmct.router.path)) {
|
||||||
this.#viewObject(this.#browseObject, currentProvider);
|
this.#viewObject(this.#browseObject, currentProvider);
|
||||||
@ -153,6 +153,11 @@ class Browse {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getPreferredViewForObjectType(obj) {
|
||||||
|
const storedViewPrefs = JSON.parse(window.localStorage.getItem('openmct-stored-view-prefs')) || {};
|
||||||
|
return storedViewPrefs[obj.type]? storedViewPrefs[obj.type] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
async #navigateToFirstChildOfRoot() {
|
async #navigateToFirstChildOfRoot() {
|
||||||
try {
|
try {
|
||||||
const rootObject = await this.#openmct.objects.get('ROOT');
|
const rootObject = await this.#openmct.objects.get('ROOT');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user