Docs Placeholder Implementation woking.

This commit is contained in:
Luis Fernando Molina committed 2021-01-18 13:20:49 +01:00
1 parent f9461ee29b
commit a729512311
10 files changed
+257 -111

No files matched your search

@@ -0,0 +1,64 @@
{
"topic": "TS Task Errors",
"pageNumber": "1",
"type": "TS Task Error - Unexpected Error",
"definition": {
"text": "Write here a summary for this topic page."
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode."
},
{
"style": "Error",
"text": "Unexpected Error"
},
{
"style": "Title",
"text": "Error Message",
"updated": 1610971316249
},
{
"style": "Text",
"text": "The following is the Error Message of the Exception that occured at the TS:",
"updated": 1610971326601
},
{
"style": "Placeholder",
"text": "errorMessage",
"updated": 1610971337737
},
{
"style": "Title",
"text": "Error Stack",
"updated": 1610968600444
},
{
"style": "Text",
"text": "The following is the Error Stack of the Exception that occured at the TS:",
"updated": 1610968631281
},
{
"style": "Placeholder",
"text": "errorStack",
"updated": 1610968640796
},
{
"style": "Title",
"text": "Error Code"
},
{
"style": "Text",
"text": "The follwing is the Error Code of the Exception that occured at the TS:"
},
{
"style": "Placeholder",
"text": "errorCode"
},
{
"style": "Text",
"text": ""
}
]
}
@@ -818,6 +818,8 @@
}
} catch (err) {
TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] run -> err = " + err.stack);
clearTimeout(nextLoopTimeoutHandle);
@@ -576,6 +576,8 @@
}
catch (err) {
TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] run -> err = " + err.stack);
clearTimeout(nextLoopTimeoutHandle);
@@ -713,6 +713,8 @@
}
} catch (err) {
TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR = err
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] run -> err = " + err.stack);
clearTimeout(nextLoopTimeoutHandle);
@@ -9,18 +9,48 @@ exports.newSuperalgosFunctionLibrariesNodeJSFunctions = function () {
function exitProcess() {
let uiError
if (TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE !== undefined) {
TS.projects.superalgos.functionLibraries.taskFunctions.taskError(
undefined,
"An unexpected error caused the Task to stop. " + TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE,
{
project: 'Superalgos',
category: 'Topic',
type: 'TS Task Error - Unexpected Error'
}
)
uiError = "An unexpected error caused the Task to stop. " + TS.projects.superalgos.globals.taskVariables.FATAL_ERROR_MESSAGE
} else {
uiError = "An unexpected error caused the Task to stop."
}
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Task Error - Unexpected Error',
placeholder: {}
}
if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR !== undefined) {
if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.message !== undefined) {
docs.placeholder.errorMessage = {
style: 'Error',
text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.message
}
}
if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.stack !== undefined) {
docs.placeholder.errorStack = {
style: 'Javascript',
text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.stack
}
}
if (TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.code !== undefined) {
docs.placeholder.errorCode = {
style: 'Json',
text: TS.projects.superalgos.globals.taskVariables.UNEXPECTED_ERROR.code
}
}
}
TS.projects.superalgos.functionLibraries.taskFunctions.taskError(
undefined,
uiError,
docs
)
if (isNodeJsProcessShuttingDown === true) { return }
isNodeJsProcessShuttingDown = true
@@ -19,7 +19,8 @@ exports.newSuperalgosFunctionLibrariesTaskFunctions = function () {
}
} else {
event = {
errorMessage: errorMessage
errorMessage: errorMessage,
docs: docs
}
}
let key = TS.projects.superalgos.globals.taskConstants.TASK_NODE.name + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.type + '-' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.id
@@ -5,9 +5,10 @@ exports.newSuperalgosGlobalsTaskVariables = function () {
*/
let thisObject = {
IS_TASK_STOPPING: false,
LOGGER_MAP: new Map(), // We will put all the loggers in a map, so that we can eventually finalize them.
SESSION_MAP: new Map(), // We will put all the sessions in a map, so that we can eventually finalize them.
FATAL_ERROR_MESSAGE: undefined
LOGGER_MAP: new Map(), // We will put all the loggers in a map, so that we can eventually finalize them.
SESSION_MAP: new Map(), // We will put all the sessions in a map, so that we can eventually finalize them.
FATAL_ERROR_MESSAGE: undefined,
UNEXPECTED_ERROR: undefined, // This is where we store the latest unexpected task error.
}
return thisObject
@@ -61,7 +61,7 @@ function newSuperalgosDocSpace() {
setUpMenuItemsMap()
setupUserLanguage()
setupActiveBranch()
setupContributionsBranch()
setupContributionsBranch()
thisObject.searchEngine = newSuperalgosDocsSearchEngine()
thisObject.mainSearchPage = newSuperalgosDocsMainSearchPage()
@@ -186,7 +186,7 @@ function newSuperalgosDocSpace() {
function changeActiveBranch(branch) {
httpRequest(undefined, 'App/Checkout/' + branch, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Current Branch')
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
data = JSON.parse(data)
@@ -250,7 +250,9 @@ function newSuperalgosDocSpace() {
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category,
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type,
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor,
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId,
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder
)
}
}
@@ -269,19 +271,19 @@ function newSuperalgosDocSpace() {
}
}
function openSpaceAreaAndNavigateTo(project, category, type, anchor, nodeId) {
function openSpaceAreaAndNavigateTo(project, category, type, anchor, nodeId, placeholder) {
getReadyToNavigate(project, category, type, anchor, nodeId)
getReadyToNavigate(project, category, type, anchor, nodeId, placeholder)
thisObject.sidePanelTab.open()
}
function navigateTo(project, category, type, anchor, nodeId) {
function navigateTo(project, category, type, anchor, nodeId, placeholder) {
EDITOR_ON_FOCUS = false // forced exit
UI.projects.superalgos.spaces.docsSpace.paragraphMap = new Map()
getReadyToNavigate(project, category, type, anchor, nodeId)
getReadyToNavigate(project, category, type, anchor, nodeId, placeholder)
UI.projects.superalgos.spaces.docsSpace.documentPage.render()
@@ -296,16 +298,10 @@ function newSuperalgosDocSpace() {
}
}
function getReadyToNavigate(project, category, type, anchor, nodeId) {
function getReadyToNavigate(project, category, type, anchor, nodeId, placeholder) {
/* Replace the current object with this */
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered !== undefined) {
UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered = {
project: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
category: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category,
type: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type,
anchor: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.anchor,
nodeId: UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId
}
UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered = JSON.parse(JSON.stringify(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered))
}
if (category === 'Book') {
@@ -314,7 +310,8 @@ function newSuperalgosDocSpace() {
category: category,
type: type.replace('AMPERSAND', '\''),
anchor: anchor,
nodeId: nodeId
nodeId: nodeId,
placeholder: placeholder
}
}
@@ -323,7 +320,8 @@ function newSuperalgosDocSpace() {
category: category,
type: type.replace('AMPERSAND', '\''),
anchor: anchor,
nodeId: nodeId
nodeId: nodeId,
placeholder: placeholder
}
}
@@ -170,85 +170,7 @@ function newSuperalgosDocsDocumentPage() {
HTML = HTML + '</div>' // Clickeable Container Ends
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Topic') {
orderedTopicPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Topic',
thisObject.docsSchemaDocument.topic
)
/* Topic Title
titleLabel = thisObject.docsSchemaDocument.topic + ' Topic Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateTopicPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Topic Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.topic + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just read page <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> in the topic.</p>'
generateTopicMultiPageIndex()
HTML = HTML + '</div>' // END Container for Topic Navigation
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Tutorial') {
orderedTutorialPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Tutorial',
thisObject.docsSchemaDocument.tutorial
)
/* Tutorial Title
titleLabel = thisObject.docsSchemaDocument.tutorial + ' Tutorial Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateTutorialPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Tutorial Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.tutorial + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just did step <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> in the tutorial.</p>'
generateTutorialMultiPageIndex()
HTML = HTML + '</div>' // END Container for Tutorial Navigation
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Review') {
orderedReviewPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Review',
thisObject.docsSchemaDocument.review
)
/* Review Title
titleLabel = thisObject.docsSchemaDocument.review + ' Review Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateReviewPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Review Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.review + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just read page <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> of this review collection.</p>'
generateReviewMultiPageIndex()
HTML = HTML + '</div>' // END Container for Review Navigation
}
generateNavigationAndTableOfContents()
HTML = HTML + '</div>' // Common Style Container Ends
@@ -267,6 +189,87 @@ function newSuperalgosDocsDocumentPage() {
*/
addImages()
function generateNavigationAndTableOfContents() {
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Topic') {
orderedTopicPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Topic',
thisObject.docsSchemaDocument.topic
)
/* Topic Title
titleLabel = thisObject.docsSchemaDocument.topic + ' Topic Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateTopicPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Topic Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.topic + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just read page <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> in the topic.</p>'
generateTopicMultiPageIndex()
HTML = HTML + '</div>' // END Container for Topic Navigation
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Tutorial') {
orderedTutorialPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Tutorial',
thisObject.docsSchemaDocument.tutorial
)
/* Tutorial Title
titleLabel = thisObject.docsSchemaDocument.tutorial + ' Tutorial Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateTutorialPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Tutorial Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.tutorial + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just did step <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> in the tutorial.</p>'
generateTutorialMultiPageIndex()
HTML = HTML + '</div>' // END Container for Tutorial Navigation
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Review') {
orderedReviewPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex(
UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project,
'Review',
thisObject.docsSchemaDocument.review
)
/* Review Title
titleLabel = thisObject.docsSchemaDocument.review + ' Review Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateReviewPreviousAndNextPageNavigation()
HTML = HTML + '<div class="docs-topic-index">' // Container for Review Navigation including buttons, title and index
HTML = HTML + '<h3 class="docs-h3">' + thisObject.docsSchemaDocument.review + ' &mdash; TOC</h3>'
HTML = HTML + '<p style="margin-bottom: 15px;">You just read page <strong>' + thisObject.docsSchemaDocument.pageNumber + '</strong> of this review collection.</p>'
generateReviewMultiPageIndex()
HTML = HTML + '</div>' // END Container for Review Navigation
}
}
function addDefinitionTable(docsSchemaDocument, idPrefix, category, project, type) {
if (docsSchemaDocument.definition === undefined) {
docsSchemaDocument.definition = {
@@ -290,7 +293,7 @@ function newSuperalgosDocsDocumentPage() {
each node will have an icon. For the rest only if we could load an
image we use a table, otherwise we will render the definitaion as a Summary.
*/
if ((category === 'Topic' || category === 'Tutorial' || category === 'Review' || category === 'Concept' || category === 'Book') && testElement === undefined) {
if ((category === 'Topic' || category === 'Tutorial' || category === 'Review' || category === 'Concept' || category === 'Book') && testElement === undefined) {
HTML = HTML + '<div id="definition-summary-editable-paragraph" class="docs-summary"><b>Summary:</b> ' + UI.projects.superalgos.utilities.docs.addToolTips(definitionText, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) + '</div>'
} else {
HTML = HTML + '<div class="docs-definition-table">'
@@ -470,6 +473,21 @@ function newSuperalgosDocsDocumentPage() {
}
break
}
case "Placeholder": {
renderParagraph(paragraph, key)
editableParagraphIndex++
let error = addPlaceholdedParagraph(paragraph.text)
if (error !== undefined) {
paragraph = {
style: "Error",
text: error
}
key = 'error-paragraph-' + autoGeneratedParagraphIndex
renderParagraph(paragraph, key)
autoGeneratedParagraphIndex++
}
break
}
case "Chapter": {
renderParagraph(paragraph, key)
editableParagraphIndex++
@@ -590,6 +608,32 @@ function newSuperalgosDocsDocumentPage() {
}
}
function addPlaceholdedParagraph(propertyName) {
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder !== undefined) {
let placeholder = UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder[propertyName]
if (placeholder !== undefined) {
let paragraph = {
style: placeholder.style,
text: placeholder.text
}
let key = 'placeholded-paragraph-' + autoGeneratedParagraphIndex
renderParagraph(paragraph, key)
autoGeneratedParagraphIndex++
return
} else {
let paragraph = {
type: "Json",
text: JSON.stringify(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder, undefined, 4)
}
let key = 'placeholded-paragraph-' + autoGeneratedParagraphIndex
renderParagraph(paragraph, key)
autoGeneratedParagraphIndex++
return 'Property ' + propertyName + ' not found at the placeholder object.'
}
}
}
function addChapterIndex(chapterText) {
let splittedChapterText = chapterText.split('->')
let chapterNumber = splittedChapterText[0]
@@ -88,7 +88,9 @@ function newUiObjectMessage() {
thisObject.docs.project,
thisObject.docs.category,
thisObject.docs.type,
thisObject.docs.anchor
thisObject.docs.anchor,
thisObject.docs.nodeId,
thisObject.docs.placeholder
)
}
}