Overlay Service - rewritten/redesigned in Vue (#2190)

* modify overlay service to accept bottomBarButtons option, working annotate on snapshot view

* working blocking message

* move blocking message to overlay service

* return dismiss function on show

* added jsdocs for overlayService

* added progress bar, with setter and getter functions

* make reviewer requested changes

* re-overhaul of overlayAPI

* Integrate work in dialog-service-vue-style

- Markup in DialogComponent and OverlayComponent now up to date;
- Colors, constants;
- Notebook entry now passes correct buttons config;
- New bg data URIs added;
- u-icon-bg-* classes added to global.scss;

* Added deprecation comments to .vue files

* Removed styles from deprecated file

* Temp restore of CSS so that dialog doesn't break.

* remove old OverlayService

* Fixed to overlay CSS

- Fixed large, small, fit sizes;
- Added margin to overlay buttons;
- Code cleanup;

* Remove unused constants

* Tweak styles for __close-button

* Code cleanup

* small cleanup

* wip progressDialog

* Progress bar fixed and Vue-ized

- Markup, styles;
- Constants moved from theme files into _constants.scss;

* added jsdocs to new Overlay API

* remove unused example function

* use progressBar.vue in NotificationBanner.vue, wire up the maximize method with progressDialog and Dialog from OverlayAPI

* Styling in progress for status message banners

* openmct members are camelCase

* Remove unimplemented/unused apis
This commit is contained in:
Deep Tailor
2018-10-19 11:15:57 -07:00
committed by Pete Richards
parent 6f1b5b4ae3
commit 67883519ee
26 changed files with 921 additions and 545 deletions

View File

@ -1,7 +1,7 @@
<div class="c-ne__embed">
<div class="c-ne__embed__snap-thumb"
v-if="embed.snapshot"
v-on:click="openSnapshot">
v-on:click="openSnapshot(domainObject, entry, embed)">
<img v-bind:src="embed.snapshot.src">
</div>
<div class="c-ne__embed__info">

View File

@ -15,7 +15,7 @@
<div class="flex-elem holder flex-can-shrink s-snapshot-datetime">
SNAPSHOT {{formatTime(embed.createdOn, 'YYYY-MM-DD HH:mm:ss')}}
</div>
<a class="s-button icon-pencil" title="Annotate">
<a class="s-button icon-pencil" title="Annotate" @click="annotateSnapshot">
<span class="title-label">Annotate</span>
</a>
</div>
@ -23,7 +23,7 @@
<div class="abs object-holder t-image-holder s-image-holder">
<div
class="image-main s-image-main"
v-bind:style="{ backgroundImage: 'url(' + embed.snapshot.src + ')' }">
:style="{ backgroundImage: 'url(' + embed.snapshot.src + ')' }">
</div>
</div>
</div>

View File

@ -23,16 +23,16 @@
define([
'moment',
'zepto',
'../utils/SnapshotOverlay',
'../../res/templates/snapshotTemplate.html',
'vue'
'vue',
'painterro'
],
function (
Moment,
$,
SnapshotOverlay,
SnapshotTemplate,
Vue
Vue,
Painterro
) {
function EmbedController (openmct, domainObject) {
this.openmct = openmct;
@ -52,11 +52,101 @@ function (
EmbedController.prototype.navigate = function (embedType) {
this.objectService.getObjects([embedType]).then(function (objects) {
this.navigationService.setNavigation(objects[embedType]);
this.navigationService.setNavigation(objects[embedType]);
}.bind(this));
};
EmbedController.prototype.openSnapshot = function () {
EmbedController.prototype.openSnapshot = function (domainObject, entry, embed) {
function annotateSnapshot(openmct) {
return function () {
var save = false,
painterroInstance = {},
annotateOverlay = new Vue({
template: '<div id="snap-annotation"></div>'
}),
self = this;
openmct.overlays.overlay({
element: annotateOverlay.$mount().$el,
size: 'large',
buttons: [
{
label: 'Cancel',
callback: function () {
save = false;
painterroInstance.save();
}
},
{
label: 'Save',
callback: function () {
save = true;
painterroInstance.save();
}
}
],
onDestroy: function () {
annotateOverlay.$destroy(true);
}
});
painterroInstance = Painterro({
id: 'snap-annotation',
activeColor: '#ff0000',
activeColorAlpha: 1.0,
activeFillColor: '#fff',
activeFillColorAlpha: 0.0,
backgroundFillColor: '#000',
backgroundFillColorAlpha: 0.0,
defaultFontSize: 16,
defaultLineWidth: 2,
defaultTool: 'ellipse',
hiddenTools: ['save', 'open', 'close', 'eraser', 'pixelize', 'rotate', 'settings', 'resize'],
translation: {
name: 'en',
strings: {
lineColor: 'Line',
fillColor: 'Fill',
lineWidth: 'Size',
textColor: 'Color',
fontSize: 'Size',
fontStyle: 'Style'
}
},
saveHandler: function (image, done) {
if (save) {
var entryPos = self.findInArray(domainObject.entries, entry.id),
embedPos = self.findInArray(entry.embeds, embed.id);
if (entryPos !== -1 && embedPos !== -1) {
var url = image.asBlob(),
reader = new window.FileReader();
reader.readAsDataURL(url);
reader.onloadend = function () {
var snapshot = reader.result,
snapshotObject = {
src: snapshot,
type: url.type,
size: url.size,
modified: Date.now()
},
dirString = 'entries[' + entryPos + '].embeds[' + embedPos + '].snapshot';
openmct.objects.mutate(domainObject, dirString, snapshotObject);
};
}
} else {
console.log('You cancelled the annotation!!!');
}
done(true);
}
}).show(embed.snapshot.src);
};
}
var self = this,
snapshot = new Vue({
template: SnapshotTemplate,
@ -66,7 +156,9 @@ function (
};
},
methods: {
formatTime: self.formatTime
formatTime: self.formatTime,
annotateSnapshot: annotateSnapshot(self.openmct),
findInArray: self.findInArray
}
});
@ -74,7 +166,20 @@ function (
snapshot.$destroy(true);
}
this.openmct.OverlayService.show(snapshot.$mount().$el, {onDestroy: onDestroyCallback, cssClass: 'l-large-view'});
var snapshotOverlay = this.openmct.overlays.overlay({
element: snapshot.$mount().$el,
onDestroy: onDestroyCallback,
size: 'large',
buttons: [
{
label: 'Done',
emphasis: true,
callback: function () {
snapshotOverlay.dismiss();
}
}
]
});
};
EmbedController.prototype.formatTime = function (unixTime, timeFormat) {
@ -125,23 +230,24 @@ function (
var entryPosition = self.findInArray(self.domainObject.entries, entry.id),
embedPosition = self.findInArray(entry.embeds, embed.id);
var warningDialog = self.dialogService.showBlockingMessage({
severity: "error",
title: "This action will permanently delete this embed. Do you wish to continue?",
options: [{
label: "OK",
var dialog = self.openmct.overlays.dialog({
iconClass: "alert",
message: 'This Action will permanently delete this embed. Do you wish to continue?',
buttons: [{
label: "No",
callback: function () {
dialog.dismiss();
}
},
{
label: "Yes",
emphasis: true,
callback: function () {
entry.embeds.splice(embedPosition, 1);
var dirString = 'entries[' + entryPosition + '].embeds';
self.openmct.objects.mutate(self.domainObject, dirString, entry.embeds);
warningDialog.dismiss();
}
},{
label: "Cancel",
callback: function () {
warningDialog.dismiss();
dialog.dismiss();
}
}]
});
@ -207,7 +313,8 @@ function (
openSnapshot: self.openSnapshot,
formatTime: self.formatTime,
toggleActionMenu: self.toggleActionMenu,
actionToMenuDecorator: self.actionToMenuDecorator
actionToMenuDecorator: self.actionToMenuDecorator,
findInArray: self.findInArray
};
};

View File

@ -81,23 +81,26 @@ function (
if (entryPos !== -1) {
var errorDialog = this.dialogService.showBlockingMessage({
severity: "error",
title: "This action will permanently delete this Notebook entry. Do you wish to continue?",
options: [{
label: "OK",
callback: function () {
domainObject.entries.splice(entryPos, 1);
openmct.objects.mutate(domainObject, 'entries', domainObject.entries);
errorDialog.dismiss();
var dialog = this.openmct.overlays.dialog({
iconClass: 'alert',
message: 'This action will permanently delete this entry. Do you wish to continue?',
buttons: [
{
label: "Ok",
emphasis: true,
callback: function () {
domainObject.entries.splice(entryPos, 1);
openmct.objects.mutate(domainObject, 'entries', domainObject.entries);
dialog.dismiss();
}
},
{
label: "Cancel",
callback: function () {
dialog.dismiss();
}
}
},{
label: "Cancel",
callback: function () {
errorDialog.dismiss();
}
}]
]
});
}
};

View File

@ -60,7 +60,7 @@ function (
this.container = container;
var notebookEmbed = {
inject:['openmct'],
inject:['openmct', 'domainObject'],
props:['embed', 'entry'],
template: EmbedTemplate,
data: embedController.exposedData,
@ -81,7 +81,7 @@ function (
var notebookVue = Vue.extend({
template: NotebookTemplate,
provide: {openmct: self.openmct},
provide: {openmct: self.openmct, domainObject: self.domainObject},
components: {
'notebook-entry': entryComponent,
'search': search.default