mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 21:28:12 +00:00
1.7.8 master (#4373)
* Notebook conflict auto retry 1.7.7 (#4230) * Use timeFormatter.parse to get the timestamp of imagery since the source could be something other than key (#4238) * If there is a pending create request for an id, queue a duplicate request. (#4243) * [Telemetry Tables] Handling Request Loading (#4245) * Fix file selection on pressing enter key (#4246) * starting loading as false, since that makes sense (#4247) * Hide independent time conductor mode if only 1 mode option is available. (#4250) * Fix bargraph color selection (#4253) * snapshot clicked while in edit mode should open in preview mode #4115 (#4257) * Fix missing object handling in several vues (#4259) * Flexible Layouts display Condition Sets as their editing/browsing interface (#4179) * Flexible Layouts display Condition Sets as their editing/browsing interface #4141 * [Telemetry Table] Progress bar tests (#4249) * Remove alert styling and hide pause button if in Fixed Time mode. (#4263) * [Table/Collection Fixes] Clearing correctly, no mutating options, no duplicate requests (#4261) * Condition sets only persist if actively editing (#4262) * Imagery views should follow time context (#4264) * Equal stacked plot y widths for all it's sub-plots (#4267) * Fix Bar Graph related CSS (#4270) * Bar graph review comment fixes (#4232) * Mct4196 - Fixes Conditional Styling not being applied when editing a Condition Widget (#4255) * Fix plot zoom when child of time strip (#4272) * Resume plot if no pan, zoom, or drag action is taken (#4138) (#4256) * [Telemetry Collection] No duplicate requests on load (#4274) * doing the easy thing first (#4278) * Bargraph time metadata should consider 'source' (#4289) * Show clicked image in large view (#4280) * added icon for inspector (#4275) * Bar graph style nullcheck (#4291) * Stacked plots need to align the Y axis (#4286) * Duplicate Request Fixes (#4295) * Add braintree sanitize url lib and sanitize form urls (#4296) * Mct4177 fix for telemetry endpoints with '.' in the key (#4308) * Remove additional request to load plots when mounted. (#4314) * Fix plots dup requests (#4324) * Merging 1.7.8 into master. Co-authored-by: Andrew Henry <akhenry@gmail.com> Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov> Co-authored-by: Nikhil <nikhil.k.mandlik@nasa.gov> Co-authored-by: Khalid Adil <khalidadil29@gmail.com> Co-authored-by: Charles Hacskaylo <charlesh88@gmail.com> Co-authored-by: Scott Bell <scott@traclabs.com> Co-authored-by: Michael Rogers <michael@mhrogers.com>
This commit is contained in:
@ -180,9 +180,13 @@ export default {
|
||||
this.openmct.notifications.alert(message);
|
||||
}
|
||||
|
||||
const relativeHash = hash.slice(hash.indexOf('#'));
|
||||
const url = new URL(relativeHash, `${location.protocol}//${location.host}${location.pathname}`);
|
||||
this.openmct.router.navigate(url.hash);
|
||||
if (this.openmct.editor.isEditing()) {
|
||||
this.previewEmbed();
|
||||
} else {
|
||||
const relativeHash = hash.slice(hash.indexOf('#'));
|
||||
const url = new URL(relativeHash, `${location.protocol}//${location.host}${location.pathname}`);
|
||||
this.openmct.router.navigate(url.hash);
|
||||
}
|
||||
},
|
||||
formatTime(unixTime, timeFormat) {
|
||||
return Moment.utc(unixTime).format(timeFormat);
|
||||
|
72
src/plugins/notebook/monkeyPatchObjectAPIForNotebooks.js
Normal file
72
src/plugins/notebook/monkeyPatchObjectAPIForNotebooks.js
Normal file
@ -0,0 +1,72 @@
|
||||
import {NOTEBOOK_TYPE} from './notebook-constants';
|
||||
|
||||
export default function (openmct) {
|
||||
const apiSave = openmct.objects.save.bind(openmct.objects);
|
||||
|
||||
openmct.objects.save = async (domainObject) => {
|
||||
if (domainObject.type !== NOTEBOOK_TYPE) {
|
||||
return apiSave(domainObject);
|
||||
}
|
||||
|
||||
const localMutable = openmct.objects._toMutable(domainObject);
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = await apiSave(localMutable);
|
||||
} catch (error) {
|
||||
if (error instanceof openmct.objects.errors.Conflict) {
|
||||
result = resolveConflicts(localMutable, openmct);
|
||||
} else {
|
||||
result = Promise.reject(error);
|
||||
}
|
||||
} finally {
|
||||
openmct.objects.destroyMutable(localMutable);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function resolveConflicts(localMutable, openmct) {
|
||||
return openmct.objects.getMutable(localMutable.identifier).then((remoteMutable) => {
|
||||
const localEntries = localMutable.configuration.entries;
|
||||
remoteMutable.$refresh(remoteMutable);
|
||||
applyLocalEntries(remoteMutable, localEntries);
|
||||
|
||||
openmct.objects.destroyMutable(remoteMutable);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function applyLocalEntries(mutable, entries) {
|
||||
Object.entries(entries).forEach(([sectionKey, pagesInSection]) => {
|
||||
Object.entries(pagesInSection).forEach(([pageKey, localEntries]) => {
|
||||
const remoteEntries = mutable.configuration.entries[sectionKey][pageKey];
|
||||
const mergedEntries = [].concat(remoteEntries);
|
||||
let shouldMutate = false;
|
||||
|
||||
const locallyAddedEntries = _.differenceBy(localEntries, remoteEntries, 'id');
|
||||
const locallyModifiedEntries = _.differenceWith(localEntries, remoteEntries, (localEntry, remoteEntry) => {
|
||||
return localEntry.id === remoteEntry.id && localEntry.text === remoteEntry.text;
|
||||
});
|
||||
|
||||
locallyAddedEntries.forEach((localEntry) => {
|
||||
mergedEntries.push(localEntry);
|
||||
shouldMutate = true;
|
||||
});
|
||||
|
||||
locallyModifiedEntries.forEach((locallyModifiedEntry) => {
|
||||
let mergedEntry = mergedEntries.find(entry => entry.id === locallyModifiedEntry.id);
|
||||
if (mergedEntry !== undefined) {
|
||||
mergedEntry.text = locallyModifiedEntry.text;
|
||||
shouldMutate = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (shouldMutate) {
|
||||
mutable.$set(`configuration.entries.${sectionKey}.${pageKey}`, mergedEntries);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
@ -2,6 +2,7 @@ import CopyToNotebookAction from './actions/CopyToNotebookAction';
|
||||
import Notebook from './components/Notebook.vue';
|
||||
import NotebookSnapshotIndicator from './components/NotebookSnapshotIndicator.vue';
|
||||
import SnapshotContainer from './snapshot-container';
|
||||
import monkeyPatchObjectAPIForNotebooks from './monkeyPatchObjectAPIForNotebooks.js';
|
||||
|
||||
import { notebookImageMigration } from '../notebook/utils/notebook-migration';
|
||||
import { NOTEBOOK_TYPE } from './notebook-constants';
|
||||
@ -166,5 +167,7 @@ export default function NotebookPlugin() {
|
||||
return domainObject;
|
||||
}
|
||||
});
|
||||
|
||||
monkeyPatchObjectAPIForNotebooks(openmct);
|
||||
};
|
||||
}
|
||||
|
@ -158,6 +158,8 @@ describe("Notebook plugin:", () => {
|
||||
testObjectProvider.create.and.returnValue(Promise.resolve(notebookViewObject));
|
||||
openmct.objects.addProvider('test-namespace', testObjectProvider);
|
||||
testObjectProvider.observe.and.returnValue(() => {});
|
||||
testObjectProvider.create.and.returnValue(Promise.resolve(true));
|
||||
testObjectProvider.update.and.returnValue(Promise.resolve(true));
|
||||
|
||||
return openmct.objects.getMutable(notebookViewObject.identifier).then((mutableObject) => {
|
||||
mutableNotebookObject = mutableObject;
|
||||
|
@ -125,7 +125,7 @@ export function addNotebookEntry(openmct, domainObject, notebookStorage, embed =
|
||||
const newEntries = addEntryIntoPage(notebookStorage, entries, entry);
|
||||
|
||||
addDefaultClass(domainObject, openmct);
|
||||
openmct.objects.mutate(domainObject, 'configuration.entries', newEntries);
|
||||
domainObject.configuration.entries = newEntries;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
Reference in New Issue
Block a user