mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 23:12:23 +00:00
Notebook localstorage issue (#3545)
* Unable to edit Notebooks (Firefox) #3534 Unable to take a snapshot - snapshot dropdown not working #3533 * Navigating to a Notebook snapshot not working #3538 Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
parent
87751e882c
commit
d1656f8561
@ -118,7 +118,7 @@ export default {
|
||||
painterroInstance.show(this.embed.snapshot.src);
|
||||
},
|
||||
changeLocation() {
|
||||
const link = this.embed.historicLink;
|
||||
const hash = this.embed.historicLink;
|
||||
|
||||
const bounds = this.openmct.time.bounds();
|
||||
const isTimeBoundChanged = this.embed.bounds.start !== bounds.start
|
||||
@ -143,6 +143,7 @@ export default {
|
||||
this.openmct.notifications.alert(message);
|
||||
}
|
||||
|
||||
const link = `${location.host}${location.pathname}${hash}`;
|
||||
const url = new URL(link);
|
||||
window.location.href = url.hash;
|
||||
},
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
<script>
|
||||
import Snapshot from '../snapshot';
|
||||
import { getDefaultNotebook } from '../utils/notebook-storage';
|
||||
import { getDefaultNotebook, validateNotebookStorageObject } from '../utils/notebook-storage';
|
||||
import { NOTEBOOK_DEFAULT, NOTEBOOK_SNAPSHOT } from '../notebook-constants';
|
||||
|
||||
export default {
|
||||
@ -49,6 +49,8 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
validateNotebookStorageObject();
|
||||
|
||||
this.notebookSnapshot = new Snapshot(this.openmct);
|
||||
this.setDefaultNotebookStatus();
|
||||
},
|
||||
|
@ -67,3 +67,24 @@ export function setDefaultNotebookPage(page) {
|
||||
notebookStorage.page = page;
|
||||
saveDefaultNotebook(notebookStorage);
|
||||
}
|
||||
|
||||
export function validateNotebookStorageObject() {
|
||||
const notebookStorage = getDefaultNotebook();
|
||||
|
||||
let valid = false;
|
||||
if (notebookStorage) {
|
||||
Object.entries(notebookStorage).forEach(([key, value]) => {
|
||||
const validKey = key !== undefined && key !== null;
|
||||
const validValue = value !== undefined && value !== null;
|
||||
valid = validKey && validValue;
|
||||
});
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
return notebookStorage;
|
||||
}
|
||||
|
||||
console.warn('Invalid Notebook object, clearing default notebook storage');
|
||||
|
||||
clearDefaultNotebook();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user