mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 21:28:12 +00:00
* Notebook v2.0 Co-authored-by: charlesh88 <charlesh88@gmail.com>
This commit is contained in:
40
src/plugins/notebook/utils/notebook-storage.js
Normal file
40
src/plugins/notebook/utils/notebook-storage.js
Normal file
@ -0,0 +1,40 @@
|
||||
const NOTEBOOK_LOCAL_STORAGE = 'notebook-storage';
|
||||
|
||||
export function clearDefaultNotebook() {
|
||||
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, null);
|
||||
}
|
||||
|
||||
export function getDefaultNotebook() {
|
||||
const notebookStorage = window.localStorage.getItem(NOTEBOOK_LOCAL_STORAGE);
|
||||
|
||||
return JSON.parse(notebookStorage);
|
||||
}
|
||||
|
||||
export function setDefaultNotebook(domainObject, section, page) {
|
||||
const notebookMeta = {
|
||||
name: domainObject.name,
|
||||
identifier: domainObject.identifier
|
||||
};
|
||||
|
||||
const notebookStorage = {
|
||||
notebookMeta,
|
||||
section,
|
||||
page
|
||||
}
|
||||
|
||||
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage));
|
||||
}
|
||||
|
||||
export function setDefaultNotebookSection(section) {
|
||||
const notebookStorage = getDefaultNotebook();
|
||||
|
||||
notebookStorage.section = section;
|
||||
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage));
|
||||
|
||||
}
|
||||
|
||||
export function setDefaultNotebookPage(page) {
|
||||
const notebookStorage = getDefaultNotebook();
|
||||
notebookStorage.page = page;
|
||||
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage));
|
||||
}
|
Reference in New Issue
Block a user