Merge pull request #177 from Superalgos/develop

status bar implementation
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2020-03-27 19:27:41 +01:00
commit 65fe2979e4
7 files changed
+103 -14

No files matched your search

+10
View File
@@ -274,6 +274,16 @@ function newCanvas () {
return
}
if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'S' || event.key === 's')) {
let saved = canvas.designSpace.workspace.save()
if (saved === true) {
canvas.cockpitSpace.setStatus('Workspace Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
}
event.preventDefault()
return
}
let nodeOnFocus = canvas.designSpace.workspace.getNodeThatIsOnFocus()
if (nodeOnFocus !== undefined) {
if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) {
+14 -4
View File
@@ -7,10 +7,10 @@ function newWorkspace () {
let thisObject = {
workspaceNode: undefined,
tradingSystem: undefined,
container: undefined,
enabled: false,
nodeChildren: undefined,
save: saveWorkspace,
getHierarchyHeads: getHierarchyHeads,
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
getNodeByShortcutKey: getNodeByShortcutKey,
@@ -66,6 +66,9 @@ function newWorkspace () {
let circularProgressBar = newBusyProgressBar()
circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea
let droppedNode
let sessionTimestamp = (new Date()).valueOf()
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
console.log(sessionTimestamp)
return thisObject
@@ -90,7 +93,7 @@ function newWorkspace () {
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
thisObject.enabled = true
setInterval(saveWorkspace, 10000)
setInterval(saveWorkspace, 60000)
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
}
@@ -113,8 +116,15 @@ function newWorkspace () {
}
function saveWorkspace () {
let textToSave = stringifyWorkspace()
window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave)
let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp')
if (Number(savedSessionTimestamp) !== sessionTimestamp) {
canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING)
} else {
let textToSave = stringifyWorkspace()
window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave)
window.localStorage.setItem('Session Timestamp', sessionTimestamp)
return true
}
}
function physics () {
+1
View File
@@ -38,6 +38,7 @@ const DOUBLE_CLICK_ZOOM_IN_IN_LEVEL = 7
const DEBUG = {}
const ZOOM_OUT_THRESHOLD_FOR_NOT_HIDDING_PANELS = 12
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_PANELS = 7
const ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS = 7
const ZOOM_OUT_THRESHOLD_FOR_CHANGING_TIME_FRAME = 3 // This help regulate when to change the Time Frame base on the level of zoom out.
const ZOOM_OUT_THRESHOLD_FOR_PACKING_OBJECTS_AT_THE_BOTTOM_OR_TOP_OF_VIEWPORT = 2
const ZOOM_OUT_THRESHOLD_FOR_PLOTTING_IN_LOW_RESOLUTION = 3
+56 -3
View File
@@ -1,11 +1,16 @@
function newCockpitSpace () {
const MODULE_NAME = 'CockpitSpace'
const STATUS_TYPES = {
ALL_GOOD: 1,
WARNING: 2
}
let thisObject = {
container: undefined,
status: 'BOTTOM',
fullscreen: undefined,
statusTypes: STATUS_TYPES,
setStatus: setStatus,
toTop: toTop,
toBottom: toBottom,
toMiddle: toMiddle,
@@ -31,6 +36,10 @@
let selfMouseClickEventSubscriptionId
let canvasBrowserResizedEventSubscriptionId
let statusCounter = 0
let statusText
let statusType
return thisObject
function finalize () {
@@ -72,6 +81,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 +129,19 @@
}
}
function statusPhysics () {
statusCounter--
if (statusCounter < 0) {
statusCounter = 0
statusText = undefined,
statusType = undefined
}
}
function physics () {
thisObjectPhysics()
childrenPhysics()
statusPhysics()
}
function childrenPhysics () {
@@ -195,9 +220,29 @@
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint)
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
}
case STATUS_TYPES.WARNING:
{
barColor = UI_COLOR.RED
textColor = UI_COLOR.TITANIUM_YELLOW
break
}
}
}
browserCanvasContext.beginPath()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + opacity + ')'
browserCanvasContext.fillStyle = 'rgba(' + barColor + ', ' + opacity + ')'
browserCanvasContext.closePath()
browserCanvasContext.fill()
@@ -213,7 +258,15 @@
browserCanvasContext.closePath()
browserCanvasContext.fill()
if (canvas.designSpace.workspace.enabled === true) {
if (statusText !== undefined) {
let position = {
x: thisObject.container.frame.width / 2,
y: thisObject.container.frame.height / 2 + 5
}
printLabel(statusText, position.x, position.y, 1, 15, textColor, true, thisObject.container)
}
if (canvas.designSpace.workspace.enabled === true && statusText === undefined) {
arrow()
}
}
+13
View File
@@ -12,6 +12,7 @@ function newSystemEventHandler () {
let WEB_SOCKETS_CONNECTION
let thisObject = {
isConnected: isConnected,
initialize: initialize,
physics: physics,
createEventHandler: createEventHandler,
@@ -30,6 +31,14 @@ function newSystemEventHandler () {
setuptWebSockets(callBackFunction)
}
function isConnected () {
if (WEB_SOCKETS_CONNECTION.readyState === 1) {
return true
} else {
return false
}
}
function sendCommand (command, responseCallBack, eventsCallBack) {
if (command.action === 'listenToEvent') {
let key
@@ -110,6 +119,10 @@ function newSystemEventHandler () {
}
}
}
if (thisObject.isConnected() !== true) {
canvas.cockpitSpace.setStatus('Lost connection with the local backend. Please check that all localhost servers are running.', 100, canvas.cockpitSpace.statusTypes.WARNING)
}
}
function setuptWebSockets (callBackFunction) {
@@ -581,8 +581,10 @@
/* Situation Name */
let digit = record.begin.toFixed(0).substring(7,8)
let positionY = recordPoint3.y - (recordPoint3.y - recordPoint1.y) / 2 + (Number(digit) * 10 - 50)
if (record.triggerOnSituation !== "My Situation") {
printLabel(record.triggerOnSituation, recordPoint1.x + 5, positionY, '1', 12);
if (canvas.chartingSpace.viewport.zoomLevel >= ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS) {
if (record.triggerOnSituation !== "My Situation") {
printLabel(record.triggerOnSituation, recordPoint1.x + 5, positionY, '1', 12);
}
}
/* Draw the Sticks */
@@ -602,11 +602,11 @@
// we do not write any text
} else {
printLabel(line0, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line1.length * FONT_ASPECT_RATIO, point.y - 15, '1', 12);
printLabel(line1, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line1.length * FONT_ASPECT_RATIO, point.y, '1', 12);
printLabel(line2, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line2.length * FONT_ASPECT_RATIO, point.y + 15, '1', 12);
if (canvas.chartingSpace.viewport.zoomLevel >= ZOOM_OUT_THRESHOLD_FOR_HIDDING_CHARTS_LABELS) {
printLabel(line0, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line1.length * FONT_ASPECT_RATIO, point.y - 15, '1', 12);
printLabel(line1, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line1.length * FONT_ASPECT_RATIO, point.y, '1', 12);
printLabel(line2, recordPoint2.x - (recordPoint2.x - recordPoint1.x) / 2 - line2.length * FONT_ASPECT_RATIO, point.y + 15, '1', 12);
}
}
}