Protection against more than one instance of UI

This commit is contained in:
Luis Fernando Molina committed 2020-03-27 19:26:18 +01:00
1 parent b311378b44
commit 6cf4572595
4 files changed
+29 -11

No files matched your search

+5 -2
View File
@@ -275,8 +275,11 @@ 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)
let saved = canvas.designSpace.workspace.save()
if (saved === true) {
canvas.cockpitSpace.setStatus('Workspace Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
}
event.preventDefault()
return
}
+12 -2
View File
@@ -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
@@ -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 () {
+8 -7
View File
@@ -2,7 +2,8 @@
function newCockpitSpace () {
const MODULE_NAME = 'CockpitSpace'
const STATUS_TYPES = {
ALL_GOOD: 1
ALL_GOOD: 1,
WARNING: 2
}
let thisObject = {
container: undefined,
@@ -230,15 +231,15 @@
textColor = UI_COLOR.WHITE
break
}
case STATUS_TYPES.WARNING:
{
barColor = UI_COLOR.RED
textColor = UI_COLOR.TITANIUM_YELLOW
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()
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y, thisObject.container.frame.width, thisObject.container.frame.height)
browserCanvasContext.fillStyle = 'rgba(' + barColor + ', ' + opacity + ')'
+4
View File
@@ -119,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) {