Merge pull request #1245 from Luis-Fernando-Molina/develop
Contribution: Big Mantainance Session: Loading of workspace reorganized, Language stored as Config Property of Workspace, removed from Browser Local Stoarage
This commit is contained in:
10 files changed
+293
-224
No files matched your search
@@ -21,6 +21,14 @@
|
||||
"actionFunction": "UI.projects.foundations.spaces.designSpace.workspace.backup",
|
||||
"ring": 1
|
||||
},
|
||||
{
|
||||
"action": "Configure",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration",
|
||||
"dontShowAtFullscreen": true,
|
||||
"actionFunction": "uiObject.configEditor.activate"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Workspace Projects",
|
||||
"label": "Add Missing Projects",
|
||||
@@ -31,6 +39,12 @@
|
||||
"actionFunction": "payload.executeAction"
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
"config": "{\"docsLanguage\": \"EN\"}"
|
||||
},
|
||||
"editors": {
|
||||
"config": true
|
||||
},
|
||||
"isTitleAllwaysVisible": true,
|
||||
"addLeftIcons": false,
|
||||
"isPinned": true,
|
||||
|
||||
@@ -32,6 +32,9 @@ function newFoundationsFunctionLibraryUiObjectsFromNodes() {
|
||||
learningSessionsFoundAtWorkspace = []
|
||||
tutorialsToPlay = []
|
||||
|
||||
/* Initializing the workspace config */
|
||||
if (node.config === undefined || node.config === 'undefined') { node.config = '{}' }
|
||||
|
||||
removeNullRootNodes()
|
||||
|
||||
function removeNullRootNodes() {
|
||||
|
||||
@@ -78,6 +78,7 @@ function newFoundationsChatSpace() {
|
||||
}
|
||||
|
||||
function getContainer(point, purpose) {
|
||||
if (thisObject.sidePanelTab === undefined) { return }
|
||||
let container
|
||||
|
||||
container = thisObject.sidePanelTab.getContainer(point, purpose)
|
||||
|
||||
@@ -25,42 +25,49 @@ function newFoundationsDesignSpace() {
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
loadIconCollection(onIconsReady)
|
||||
async function initialize() {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
|
||||
function onIconsReady() {
|
||||
buildIconByProjectAndTypeMap()
|
||||
thisObject.workspace = newWorkspace()
|
||||
thisObject.workspace.initialize()
|
||||
}
|
||||
loadIconCollection(onIconsReady)
|
||||
|
||||
function buildIconByProjectAndTypeMap() {
|
||||
/* Take types-icons relationships defined at the schema */
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let project = PROJECTS_SCHEMA[i].name
|
||||
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.appSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema)
|
||||
|
||||
function addSchemaTypes(schema) {
|
||||
for (let j = 0; j < schema.length; j++) {
|
||||
let schemaDocument = schema[j]
|
||||
let iconName = schemaDocument.icon
|
||||
if (iconName === undefined) {
|
||||
iconName = schemaDocument.type.toLowerCase()
|
||||
iconName = iconName.split(" ").join("-")
|
||||
}
|
||||
let icon = thisObject.getIconByProjectAndName(project, iconName)
|
||||
if (icon !== undefined) {
|
||||
let key = project + '-' + schemaDocument.type
|
||||
thisObject.iconsByProjectAndType.set(key, icon)
|
||||
async function onIconsReady() {
|
||||
buildIconByProjectAndTypeMap()
|
||||
thisObject.workspace = newWorkspace()
|
||||
await thisObject.workspace.initialize()
|
||||
resolve()
|
||||
}
|
||||
|
||||
function buildIconByProjectAndTypeMap() {
|
||||
/* Take types-icons relationships defined at the schema */
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let project = PROJECTS_SCHEMA[i].name
|
||||
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.appSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema)
|
||||
|
||||
function addSchemaTypes(schema) {
|
||||
for (let j = 0; j < schema.length; j++) {
|
||||
let schemaDocument = schema[j]
|
||||
let iconName = schemaDocument.icon
|
||||
if (iconName === undefined) {
|
||||
iconName = schemaDocument.type.toLowerCase()
|
||||
iconName = iconName.split(" ").join("-")
|
||||
}
|
||||
let icon = thisObject.getIconByProjectAndName(project, iconName)
|
||||
if (icon !== undefined) {
|
||||
let key = project + '-' + schemaDocument.type
|
||||
thisObject.iconsByProjectAndType.set(key, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return promise
|
||||
|
||||
}
|
||||
|
||||
function loadIconCollection(callBack) {
|
||||
|
||||
@@ -20,7 +20,7 @@ function newWorkspace() {
|
||||
getHierarchyHeads: getHierarchyHeads,
|
||||
getHierarchyHeadsById: getHierarchyHeadsById,
|
||||
getHierarchyHeadByNodeType: getHierarchyHeadByNodeType,
|
||||
getHierarchyHeadsByNodeType: getHierarchyHeadsByNodeType,
|
||||
getHierarchyHeadsByNodeType: getHierarchyHeadsByNodeType,
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
|
||||
getNodeByShortcutKey: getNodeByShortcutKey,
|
||||
getNodeById: getNodeById,
|
||||
@@ -59,78 +59,72 @@ function newWorkspace() {
|
||||
actionSwitchesByProject = undefined
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
try {
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Initializing...")
|
||||
async function initialize() {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
|
||||
/* Set up the action switches map */
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let project = PROJECTS_SCHEMA[i].name
|
||||
let actionSwitch = eval('new' + project + 'ActionSwitch()')
|
||||
actionSwitchesByProject.set(project, actionSwitch)
|
||||
}
|
||||
try {
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Initializing...")
|
||||
|
||||
/* Check which was the last workspace. */
|
||||
let lastUsedWorkspace = window.localStorage.getItem('Last Used Workspace')
|
||||
/* Set up the action switches map */
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let project = PROJECTS_SCHEMA[i].name
|
||||
let actionSwitch = eval('new' + project + 'ActionSwitch()')
|
||||
actionSwitchesByProject.set(project, actionSwitch)
|
||||
}
|
||||
|
||||
if (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) {
|
||||
/* Check which was the last workspace. */
|
||||
let lastUsedWorkspace = window.localStorage.getItem('Last Used Workspace')
|
||||
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Loading Workspace " + lastUsedWorkspace + "...")
|
||||
if (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) {
|
||||
|
||||
httpRequest(undefined, 'LoadMyWorkspace' + '/' + lastUsedWorkspace, onFileReceived)
|
||||
function onFileReceived(err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING)
|
||||
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Loading Workspace " + lastUsedWorkspace + "...")
|
||||
|
||||
httpRequest(undefined, 'LoadMyWorkspace' + '/' + lastUsedWorkspace, onFileReceived)
|
||||
function onFileReceived(err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING)
|
||||
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
|
||||
thisObject.workspaceNode.project = 'Foundations'
|
||||
recreateWorkspace()
|
||||
return
|
||||
}
|
||||
thisObject.workspaceNode = JSON.parse(text)
|
||||
thisObject.workspaceNode.project = 'Foundations'
|
||||
recreateWorkspace()
|
||||
return
|
||||
}
|
||||
thisObject.workspaceNode = JSON.parse(text)
|
||||
} else {
|
||||
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
|
||||
thisObject.workspaceNode.project = 'Foundations'
|
||||
recreateWorkspace()
|
||||
}
|
||||
} else {
|
||||
thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system.
|
||||
thisObject.workspaceNode.project = 'Foundations'
|
||||
recreateWorkspace()
|
||||
}
|
||||
|
||||
function recreateWorkspace() {
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Connecting all the workspace nodes...")
|
||||
executeAction({ node: thisObject.workspaceNode, name: 'Recreate Workspace', project: 'Foundations', callBackFunction: finishInitialization })
|
||||
}
|
||||
|
||||
function finishInitialization() {
|
||||
/*
|
||||
We will help the Docs Space finish its initialization, since it is
|
||||
waiting for the workspace to be done.
|
||||
*/
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Setting up Docs Search Engine...")
|
||||
setTimeout(theEnd, 100)
|
||||
function theEnd() {
|
||||
UI.projects.education.spaces.docsSpace.searchEngine.setUpSearchEngine(onIndexingFinished)
|
||||
|
||||
function onIndexingFinished() {
|
||||
setupEventsServerClients()
|
||||
runTasksAndSessions()
|
||||
|
||||
thisObject.enabled = true
|
||||
UI.projects.foundations.spaces.cockpitSpace.initializePosition()
|
||||
CAN_SPACES_DRAW = true
|
||||
|
||||
thisObject.isInitialized = true
|
||||
|
||||
playTutorials()
|
||||
|
||||
savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000)
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Displaying the UI...")
|
||||
}
|
||||
function recreateWorkspace() {
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Connecting all the workspace nodes...")
|
||||
executeAction({ node: thisObject.workspaceNode, name: 'Recreate Workspace', project: 'Foundations', callBackFunction: finishInitialization })
|
||||
}
|
||||
|
||||
function finishInitialization() {
|
||||
|
||||
setupEventsServerClients()
|
||||
runTasksAndSessions()
|
||||
|
||||
thisObject.enabled = true
|
||||
UI.projects.foundations.spaces.cockpitSpace.initializePosition()
|
||||
CAN_SPACES_DRAW = true
|
||||
|
||||
thisObject.isInitialized = true
|
||||
|
||||
savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000)
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Displaying the UI...")
|
||||
|
||||
resolve()
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
|
||||
}
|
||||
})
|
||||
|
||||
return promise
|
||||
}
|
||||
|
||||
function runTasksAndSessions() {
|
||||
@@ -139,10 +133,6 @@ function newWorkspace() {
|
||||
executeAction({ name: 'Syncronize Learning Sessions', project: 'Foundations' })
|
||||
}
|
||||
|
||||
function playTutorials() {
|
||||
executeAction({ name: 'Play Tutorials', project: 'Foundations' })
|
||||
}
|
||||
|
||||
function setupEventsServerClients() {
|
||||
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
|
||||
let rootNode = thisObject.workspaceNode.rootNodes[i]
|
||||
@@ -373,21 +363,15 @@ function newWorkspace() {
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus('Reindexing Search Engine...')
|
||||
setTimeout(takeAction, 100)
|
||||
workingAtTask = 0
|
||||
UI.projects.foundations.spaces.floatingSpace.inMapMode = false
|
||||
thisObject.isInitialized = true
|
||||
|
||||
await UI.projects.education.spaces.docsSpace.reset()
|
||||
await UI.projects.education.spaces.tutorialSpace.reset()
|
||||
|
||||
function takeAction() {
|
||||
UI.projects.education.spaces.docsSpace.reset()
|
||||
UI.projects.education.spaces.docsSpace.searchEngine.setUpSearchEngine(onIndexingFinished) // The docs needs to index the loaded workspace.
|
||||
function onIndexingFinished() {
|
||||
UI.projects.foundations.spaces.floatingSpace.inMapMode = false
|
||||
thisObject.isInitialized = true
|
||||
saveWorkspace()
|
||||
runTasksAndSessions()
|
||||
playTutorials()
|
||||
}
|
||||
}
|
||||
saveWorkspace()
|
||||
runTasksAndSessions()
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -411,6 +395,7 @@ function newWorkspace() {
|
||||
let workspace = {
|
||||
type: 'Workspace',
|
||||
name: thisObject.workspaceNode.name,
|
||||
config: thisObject.workspaceNode.config,
|
||||
rootNodes: stringifyReadyNodes
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ function newFoundationsSideSpace() {
|
||||
}
|
||||
|
||||
function getContainer(point, purpose) {
|
||||
if (thisObject.sidePanelTab === undefined) { return }
|
||||
let container
|
||||
|
||||
container = thisObject.sidePanelTab.getContainer(point, purpose)
|
||||
|
||||
Reference in new issue
Block a user