Merge branch 'master' into fix-any-telemetry

This commit is contained in:
Shefali Joshi 2020-04-02 10:06:37 -07:00 committed by GitHub
commit 58b4a6ebf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 58 deletions

View File

@ -238,7 +238,7 @@ export default class ConditionManager extends EventEmitter {
} }
requestLADConditionSetOutput() { requestLADConditionSetOutput() {
if (!this.conditionClassCollection.length || this.conditionClassCollection.length === 1) { if (!this.conditionClassCollection.length) {
return Promise.resolve([]); return Promise.resolve([]);
} }

View File

@ -217,18 +217,16 @@ export default {
populateActionMenu() { populateActionMenu() {
const self = this; const self = this;
const actions = [new PreviewAction(self.openmct)]; const actions = [new PreviewAction(self.openmct)];
self.openmct.objects.get(self.embed.type)
.then((domainObject) => { actions.forEach((action) => {
actions.forEach((action) => { self.actions.push({
self.actions.push({ cssClass: action.cssClass,
cssClass: action.cssClass, name: action.name,
name: action.name, perform: () => {
perform: () => { action.invoke(JSON.parse(self.embed.objectPath));
action.invoke([domainObject].concat(self.openmct.router.path)); }
}
});
});
}); });
});
}, },
removeEmbed(id) { removeEmbed(id) {
this.$emit('removeEmbed', id); this.$emit('removeEmbed', id);

View File

@ -80,10 +80,10 @@
</span> </span>
</div> </div>
<div v-if="selectedSection && selectedPage" <div v-if="selectedSection && selectedPage"
ref="notebookEntries"
class="c-notebook__entries" class="c-notebook__entries"
> >
<NotebookEntry v-for="entry in filteredAndSortedEntries" <NotebookEntry v-for="entry in filteredAndSortedEntries"
ref="notebookEntry"
:key="entry.id" :key="entry.id"
:entry="entry" :entry="entry"
:domain-object="internalDomainObject" :domain-object="internalDomainObject"
@ -122,6 +122,7 @@ export default {
defaultPageId: getDefaultNotebook() ? getDefaultNotebook().page.id : '', defaultPageId: getDefaultNotebook() ? getDefaultNotebook().page.id : '',
defaultSectionId: getDefaultNotebook() ? getDefaultNotebook().section.id : '', defaultSectionId: getDefaultNotebook() ? getDefaultNotebook().section.id : '',
defaultSort: this.domainObject.configuration.defaultSort, defaultSort: this.domainObject.configuration.defaultSort,
focusEntryId: null,
internalDomainObject: this.domainObject, internalDomainObject: this.domainObject,
search: '', search: '',
showTime: 0, showTime: 0,
@ -174,6 +175,11 @@ export default {
this.unlisten(); this.unlisten();
} }
}, },
updated: function () {
this.$nextTick(function () {
this.focusOnEntryId();
})
},
methods: { methods: {
addDefaultClass() { addDefaultClass() {
const classList = this.internalDomainObject.classList || []; const classList = this.internalDomainObject.classList || [];
@ -210,6 +216,20 @@ export default {
this.updateSection({ sections }); this.updateSection({ sections });
this.throttledSearchItem(''); this.throttledSearchItem('');
}, },
createNotebookStorageObject() {
const notebookMeta = {
name: this.internalDomainObject.name,
identifier: this.internalDomainObject.identifier
};
const page = this.getSelectedPage();
const section = this.getSelectedSection();
return {
notebookMeta,
section,
page
}
},
dragOver(event) { dragOver(event) {
event.preventDefault(); event.preventDefault();
event.dataTransfer.dropEffect = "copy"; event.dataTransfer.dropEffect = "copy";
@ -245,6 +265,20 @@ export default {
const embed = createNewEmbed(snapshotMeta); const embed = createNewEmbed(snapshotMeta);
this.newEntry(embed); this.newEntry(embed);
}, },
focusOnEntryId() {
if (!this.focusEntryId) {
return;
}
const element = this.$refs.notebookEntries.querySelector(`#${this.focusEntryId}`);
if (!element) {
return;
}
element.focus();
this.focusEntryId = null;
},
formatSidebar() { formatSidebar() {
/* /*
Determine if the sidebar should slide over content, or compress it Determine if the sidebar should slide over content, or compress it
@ -359,20 +393,12 @@ export default {
this.updateSection({ sections }); this.updateSection({ sections });
}, },
newEntry(embed = null) { newEntry(embed = null) {
const selectedSection = this.getSelectedSection();
const selectedPage = this.getSelectedPage();
this.search = ''; this.search = '';
const notebookStorage = this.createNotebookStorageObject();
this.updateDefaultNotebook(selectedSection, selectedPage); this.updateDefaultNotebook(notebookStorage);
const notebookStorage = getDefaultNotebook();
const id = addNotebookEntry(this.openmct, this.internalDomainObject, notebookStorage, embed); const id = addNotebookEntry(this.openmct, this.internalDomainObject, notebookStorage, embed);
this.focusEntryId = id;
this.$nextTick(() => { this.search = '';
const element = this.$el.querySelector(`#${id}`);
element.focus();
});
return id;
}, },
orientationChange() { orientationChange() {
this.formatSidebar(); this.formatSidebar();
@ -402,13 +428,13 @@ export default {
toggleNav() { toggleNav() {
this.showNav = !this.showNav; this.showNav = !this.showNav;
}, },
async updateDefaultNotebook(selectedSection, selectedPage) { async updateDefaultNotebook(notebookStorage) {
const defaultNotebookObject = await this.getDefaultNotebookObject(); const defaultNotebookObject = await this.getDefaultNotebookObject();
this.removeDefaultClass(defaultNotebookObject); this.removeDefaultClass(defaultNotebookObject);
setDefaultNotebook(this.internalDomainObject, selectedSection, selectedPage); setDefaultNotebook(notebookStorage);
this.addDefaultClass(); this.addDefaultClass();
this.defaultSectionId = selectedSection.id; this.defaultSectionId = notebookStorage.section.id;
this.defaultPageId = selectedPage.id; this.defaultPageId = notebookStorage.page.id;
}, },
updateDefaultNotebookPage(pages, id) { updateDefaultNotebookPage(pages, id) {
if (!id) { if (!id) {

View File

@ -95,7 +95,8 @@ export const createNewEmbed = (snapshotMeta, snapshot = '') => {
id: 'embed-' + date, id: 'embed-' + date,
name, name,
snapshot, snapshot,
type type,
objectPath: JSON.stringify(objectPath)
}; };
} }

View File

@ -10,18 +10,7 @@ export function getDefaultNotebook() {
return JSON.parse(notebookStorage); return JSON.parse(notebookStorage);
} }
export function setDefaultNotebook(domainObject, section, page) { export function setDefaultNotebook(notebookStorage) {
const notebookMeta = {
name: domainObject.name,
identifier: domainObject.identifier
};
const notebookStorage = {
notebookMeta,
section,
page
}
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage)); window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage));
} }

View File

@ -40,12 +40,6 @@
:current-view="currentView" :current-view="currentView"
@setView="setView" @setView="setView"
/> />
<button
v-if="notebookEnabled"
class="l-browse-bar__actions__edit c-button icon-notebook"
title="New Notebook entry"
@click="snapshot"
></button>
</div> </div>
</div> </div>
</div> </div>
@ -57,7 +51,6 @@
<script> <script>
import ContextMenuDropDown from '../../ui/components/contextMenuDropDown.vue'; import ContextMenuDropDown from '../../ui/components/contextMenuDropDown.vue';
import Snapshot from '@/plugins/notebook/snapshot';
import ViewSwitcher from '../../ui/layout/ViewSwitcher.vue'; import ViewSwitcher from '../../ui/layout/ViewSwitcher.vue';
export default { export default {
@ -94,20 +87,11 @@ export default {
mounted() { mounted() {
let view = this.openmct.objectViews.get(this.domainObject)[0]; let view = this.openmct.objectViews.get(this.domainObject)[0];
this.setView(view); this.setView(view);
if (this.openmct.types.get('notebook')) {
this.notebookSnapshot = new Snapshot(this.openmct);
this.notebookEnabled = true;
}
}, },
destroyed() { destroyed() {
this.view.destroy(); this.view.destroy();
}, },
methods: { methods: {
snapshot() {
let element = document.getElementsByClassName("l-preview-window__object-view")[0];
this.notebookSnapshot.capture(this.domainObject, element);
},
clear() { clear() {
if (this.view) { if (this.view) {
this.view.destroy(); this.view.destroy();