From b311378b44f06f3ffc3f97d2d3de829be5dfd4f1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 27 Mar 2020 18:58:11 +0100 Subject: [PATCH] saving with satus bar notification --- Canvas.js | 1 + Spaces/CockpitSpace.js | 49 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Canvas.js b/Canvas.js index 170ba0c4a..e75a97714 100644 --- a/Canvas.js +++ b/Canvas.js @@ -276,6 +276,7 @@ function newCanvas () { if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'S' || event.key === 's')) { canvas.designSpace.workspace.save() + canvas.cockpitSpace.setStatus('Workspace Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) event.preventDefault() return } diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index a70fa8c73..8b9a3c8e4 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -1,11 +1,15 @@ function newCockpitSpace () { const MODULE_NAME = 'CockpitSpace' - + const STATUS_TYPES = { + ALL_GOOD: 1 + } let thisObject = { container: undefined, status: 'BOTTOM', fullscreen: undefined, + statusTypes: STATUS_TYPES, + setStatus: setStatus, toTop: toTop, toBottom: toBottom, toMiddle: toMiddle, @@ -31,6 +35,10 @@ let selfMouseClickEventSubscriptionId let canvasBrowserResizedEventSubscriptionId + let statusCounter = 0 + let statusText + let statusType + return thisObject function finalize () { @@ -72,6 +80,12 @@ } + function setStatus (text, counter, type) { + statusCounter = counter + statusText = text + statusType = type + } + function resize () { thisObject.container.frame.width = browserCanvas.width thisObject.container.frame.height = COCKPIT_SPACE_HEIGHT @@ -114,9 +128,19 @@ } } + function statusPhysics () { + statusCounter-- + if (statusCounter < 0) { + statusCounter = 0 + statusText = undefined, + statusType = undefined + } + } + function physics () { thisObjectPhysics() childrenPhysics() + statusPhysics() } function childrenPhysics () { @@ -195,13 +219,24 @@ zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint) - let barColor - let statusText - if (systemEventHandler.isConnected()) { - barColor = UI_COLOR.DARK_TURQUOISE - } else { + let barColor = UI_COLOR.DARK_TURQUOISE // default + let textColor + + if (statusType !== undefined) { + switch (statusType) { + case STATUS_TYPES.ALL_GOOD: + { + barColor = UI_COLOR.PATINATED_TURQUOISE + textColor = UI_COLOR.WHITE + break + } + } + } + + if (systemEventHandler.isConnected() !== true) { barColor = UI_COLOR.RED statusText = 'Lost connection with the local backend. Please check that all localhost servers are running.' + textColor = UI_COLOR.TITANIUM_YELLOW } browserCanvasContext.beginPath() @@ -227,7 +262,7 @@ x: thisObject.container.frame.width / 2, y: thisObject.container.frame.height / 2 + 5 } - printLabel(statusText, position.x, position.y, 1, 15, UI_COLOR.TITANIUM_YELLOW, true, thisObject.container) + printLabel(statusText, position.x, position.y, 1, 15, textColor, true, thisObject.container) } if (canvas.designSpace.workspace.enabled === true && statusText === undefined) {