From e4f2539dca586254931069cf740b2b72bd3b187f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 08:08:07 +0100 Subject: [PATCH 01/17] Page renamed --- Projects/Superalgos/UI/Utilities/{CreditsPage.js => StatusBar.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Projects/Superalgos/UI/Utilities/{CreditsPage.js => StatusBar.js} (100%) diff --git a/Projects/Superalgos/UI/Utilities/CreditsPage.js b/Projects/Superalgos/UI/Utilities/StatusBar.js similarity index 100% rename from Projects/Superalgos/UI/Utilities/CreditsPage.js rename to Projects/Superalgos/UI/Utilities/StatusBar.js From 4dba3767a4b600255edb8848fc4da14af65ddef5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 11:45:55 +0100 Subject: [PATCH 02/17] Reviews Implementation. Adding, Deleting, Searching, etc. reviews. --- Client/WebServer/css/docs.css | 4 +- Client/httpInterface.js | 39 +++++ ...superalgos-review-leave-your-feedback.json | 51 +++++++ .../docs-commands-003-docs-add-command.json | 73 ++++++--- ...docs-commands-004-docs-delete-command.json | 58 ++++++-- ...7-no-matching-topic-or-tutorial-found.json | 2 +- .../UI/Spaces/Docs-Space/CommandInterface.js | 139 +++++++++++++++++- .../UI/Spaces/Docs-Space/DocsSpace.js | 2 +- .../UI/Spaces/Docs-Space/DocumentPage.js | 105 ++++++++++++- .../UI/Spaces/Docs-Space/MainSearchPage.js | 2 +- .../UI/Spaces/Docs-Space/SearchEngine.js | 20 ++- .../UI/Spaces/Docs-Space/SearchResultsPage.js | 15 +- Projects/Superalgos/UI/Utilities/Docs.js | 14 ++ UI/AppPostLoader.js | 22 +++ 14 files changed, 504 insertions(+), 42 deletions(-) create mode 100644 Projects/Superalgos/Schemas/Docs-Reviews/superalgos-project-review-001-superalgos-review-leave-your-feedback.json diff --git a/Client/WebServer/css/docs.css b/Client/WebServer/css/docs.css index 35c0f52b2..8e4d568a3 100644 --- a/Client/WebServer/css/docs.css +++ b/Client/WebServer/css/docs.css @@ -816,7 +816,7 @@ width: 100%; .docs-search-results-header-tabs-container { display: table; - padding-left: 240px; + padding-left: 180px; margin-top: 20px; } @@ -848,7 +848,7 @@ width: 100%; /* Search Results Page Content */ .docs-search-result-content { border-top: 1px solid #0295aa; -margin-left: -240px; +margin-left: -180px; } .docs-search-result-content > div { diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 84f1f1961..868755e4d 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -424,6 +424,36 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } break } + case 'Save-Review-Schema': { + getBody(processRequest) + + async function processRequest(body) { + try { + let docsSchema = JSON.parse(body) + let project = requestParameters[3] + let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Reviews' + + if (checkAllSchmemaDocuments('Review', docsSchema, filePath) === true) { + respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) + } else { + respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + } + + } catch (err) { + console.log('[ERROR] httpInterface -> Docs -> Save-Review-Schema -> Method call produced an error.') + console.log('[ERROR] httpInterface -> Docs -> Save-Review-Schema -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> Docs -> Save-Review-Schema -> Params Received = ' + body) + + let error = { + result: 'Fail Because', + message: err.message, + stack: err.stack + } + respondWithContent(JSON.stringify(error), httpResponse) + } + } + break + } case 'Save-Book-Schema': { getBody(processRequest) @@ -479,6 +509,11 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE fileName = cleanFileName(fileName) break } + case 'Review': { + fileName = schemaDocument.review.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase() + fileName = cleanFileName(fileName) + break + } } fileName = fileName + '.json' @@ -1370,6 +1405,10 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE folder = 'Docs-Tutorials' break } + case 'DocsReviewSchema': { + folder = 'Docs-Reviews' + break + } case 'DocsBookSchema': { folder = 'Docs-Books' break diff --git a/Projects/Superalgos/Schemas/Docs-Reviews/superalgos-project-review-001-superalgos-review-leave-your-feedback.json b/Projects/Superalgos/Schemas/Docs-Reviews/superalgos-project-review-001-superalgos-review-leave-your-feedback.json new file mode 100644 index 000000000..e4d79991e --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Reviews/superalgos-project-review-001-superalgos-review-leave-your-feedback.json @@ -0,0 +1,51 @@ +{ + "review": "Superalgos Project Review", + "pageNumber": "1", + "type": "Superalgos Review - Leave Your Feedback!", + "definition": { + "text": "This is the place where you can leave your feedback and impressions about the project, for others to find and read.", + "updated": 1610701752995 + }, + "paragraphs": [ + { + "style": "Success", + "text": "After you create your own review page as part of this collection, you will be able to edit it over time, and add more info as your experience evolves with the system. So, don't worry is right now you can just write your first impressions. You will allways be able to come back and extend your page.", + "updated": 1610701884353 + }, + { + "style": "Title", + "text": "How to add your own Review", + "updated": 1610702480960 + }, + { + "style": "Text", + "text": "In order to add your own review page of the Superalgos Project, copy and paste the following code at the search bar:" + }, + { + "style": "Json", + "text": "docs.add Review to Superalgos: Superalgos Project Review->Superalgos Review - YOUR REVIEW TITLE", + "updated": 1610702550459 + }, + { + "style": "List", + "text": "YOUR REVIEW TITLE: Replace this placeholder text for a short title for your Review Page." + }, + { + "style": "Important", + "text": "You need to sign your Review Page. At the en of the text, type your Github.com username. This needs to be present in order for the Review to be added to the next release of Superalgos.", + "updated": 1610702866522 + }, + { + "style": "Text", + "text": "Your review will be merged into the main repository once you send it as a contribution. For that you need to execute:" + }, + { + "style": "Json", + "text": "docs.save" + }, + { + "style": "Json", + "text": "app.contribute" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-003-docs-add-command.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-003-docs-add-command.json index cb1740f15..af0429480 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-003-docs-add-command.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-003-docs-add-command.json @@ -13,26 +13,26 @@ "updated": 1609150474236 }, { - "style": "Text", + "style": "Subtitle", "text": "Option 1: ", "updated": 1609149432117 }, { - "style": "Javascript", + "style": "Json", "text": "docs.add Node to Project: Docs Page Name", "updated": 1609149799453 }, { - "style": "Text", + "style": "Subtitle", "text": "Example: ", "updated": 1609149442319 }, { - "style": "Javascript", + "style": "Json", "text": "docs.add Node to Superalgos" }, { - "style": "Text", + "style": "Subtitle", "text": "Option 2: ", "updated": 1609149450546 }, @@ -42,7 +42,7 @@ "updated": 1609149807897 }, { - "style": "Text", + "style": "Subtitle", "text": "Example: ", "updated": 1609149457691 }, @@ -51,7 +51,7 @@ "text": "docs.add Concept to Superalgos" }, { - "style": "Text", + "style": "Subtitle", "text": "Option 3: ", "updated": 1609149464103 }, @@ -61,7 +61,7 @@ "updated": 1609149846658 }, { - "style": "Text", + "style": "Subtitle", "text": "Example: ", "updated": 1609149471266 }, @@ -71,31 +71,68 @@ "updated": 1609149878993 }, { - "style": "Title", - "text": "Parameters", - "updated": 1609150484701 + "style": "Subtitle", + "text": "Option 4:", + "updated": 1610706520317 }, { - "style": "Text", + "style": "Json", + "text": "docs.add Topic to Project: Docs Tutorial Name->Docs Page Name->Docs Page Number", + "updated": 1610706514194 + }, + { + "style": "Subtitle", + "text": "Example:" + }, + { + "style": "Json", + "text": "docs.add Tutorial to Superalgos: How to Build Indicators->Intro", + "updated": 1610706570716 + }, + { + "style": "Subtitle", + "text": "Option 5:", + "updated": 1610706652124 + }, + { + "style": "Json", + "text": "docs.add Review to Project: Docs Review Name->Docs Page Name->Docs Page Number", + "updated": 1610706722998 + }, + { + "style": "Subtitle", + "text": "Example:" + }, + { + "style": "Json", + "text": "docs.add Review to Project: Superalgos Project Review->Superalgos Review - Great Project!", + "updated": 1610706675495 + }, + { + "style": "Title", + "text": "Parameters" + }, + { + "style": "List", "text": "Project : Is the project where the Node, Concept or Topic is defined." }, { - "style": "Text", + "style": "List", "text": "Docs Page Category : Node, Concept or Topic." }, { - "style": "Text", + "style": "List", "text": "Docs Topic Name: The name of the topic which the new page will belong to.", "updated": 1609149944222 }, { - "style": "Text", + "style": "List", "text": "Docs Page Name : For Nodes it is the type of node, for Concepts, the concept name, for topics, the topic's page name." }, { - "style": "Text", - "text": "Docs Page Numer: A page number that you would like to assing the new page. This will impact only at the position of the Topic Index.", - "updated": 1609149987475 + "style": "List", + "text": "Docs Page Numer: Optional. A page number that you would like to assing the new page. This will impact only at the position of the Topic Index. If you don't provide one, it will be automatically assigned the last page number in the collection plus 1.", + "updated": 1610706305834 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-004-docs-delete-command.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-004-docs-delete-command.json index 532c2a96d..b6a103240 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-004-docs-delete-command.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-004-docs-delete-command.json @@ -13,7 +13,7 @@ "updated": 1609152160707 }, { - "style": "Text", + "style": "Subtitle", "text": "Option 1:", "updated": 1609152344322 }, @@ -23,7 +23,7 @@ "updated": 1609152359725 }, { - "style": "Text", + "style": "Subtitle", "text": "Example:" }, { @@ -32,16 +32,16 @@ "updated": 1609152405379 }, { - "style": "Text", + "style": "Subtitle", "text": "Option 2:" }, { - "style": "Javascript", + "style": "Json", "text": "docs.delete Concept from Project: Docs Page Name", "updated": 1609152445366 }, { - "style": "Text", + "style": "Subtitle", "text": "Example:" }, { @@ -50,7 +50,7 @@ "updated": 1609152464312 }, { - "style": "Text", + "style": "Subtitle", "text": "Option 3:" }, { @@ -59,7 +59,7 @@ "updated": 1609152484236 }, { - "style": "Text", + "style": "Subtitle", "text": "Example:" }, { @@ -67,20 +67,58 @@ "text": "docs.delete Topic from Superalgos: Docs Styles->Docs Text Style->1", "updated": 1609152521245 }, + { + "style": "Subtitle", + "text": "Option 4:", + "updated": 1610706965604 + }, + { + "style": "Json", + "text": "docs.delete Tutorial from Project: Docs Tutorial Name->Docs Page Name->Docs Page Number", + "updated": 1610706951438 + }, + { + "style": "Subtitle", + "text": "Example:" + }, + { + "style": "Json", + "text": "docs.delete Tutorial from Superalgos: How to Build Indicatiors->Intro->1", + "updated": 1610707006603 + }, + { + "style": "Subtitle", + "text": "Option 5:", + "updated": 1610707021714 + }, + { + "style": "Json", + "text": "docs.delete Review from Project: Docs Review Name->Docs Page Name->Docs Page Number", + "updated": 1610707068615 + }, + { + "style": "Subtitle", + "text": "Example:" + }, + { + "style": "Json", + "text": "docs.delete Review from Project: Superalgos Project Review->Awasome!->2", + "updated": 1610707101903 + }, { "style": "Title", "text": "Parameters" }, { - "style": "Text", + "style": "List", "text": "Project : Is the project where the Node, Concept or Topic is defined." }, { - "style": "Text", + "style": "List", "text": "Docs Page Category : Node, Concept or Topic." }, { - "style": "Text", + "style": "List", "text": "Docs Page Name : For Nodes it is the type of node, for Concepts, the concept name, for topics, the topic's page name." } ] diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-errors-017-no-matching-topic-or-tutorial-found.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-errors-017-no-matching-topic-or-tutorial-found.json index e6f5dd070..fc2940a96 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-errors-017-no-matching-topic-or-tutorial-found.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-commands-errors-017-no-matching-topic-or-tutorial-found.json @@ -1,7 +1,7 @@ { "topic": "Docs Commands Errors", "pageNumber": "17", - "type": "No Matching Topic Or Tutorial Found", + "type": "No Matching Topic, Tutorial or Review Found", "definition": { "text": "The Topic or Tutorial you specified did not produce any match of pages within that Topic or Tutorial.", "updated": 1610398888306 diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index f61cbfbba..8a01632ae 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -202,6 +202,10 @@ function newSuperalgosDocsCommmandInterface() { docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type) break } + case 'Review': { + docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + break + } case 'book': { docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type) break @@ -272,7 +276,7 @@ function newSuperalgosDocsCommmandInterface() { } case 'topic': { let splittedSecondaryCommand = secondaryCommand.split('->') - if (splittedSecondaryCommand.length < 3) { + if (splittedSecondaryCommand.length < 2) { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Paramenters') return } @@ -281,13 +285,22 @@ function newSuperalgosDocsCommmandInterface() { } case 'tutorial': { let splittedSecondaryCommand = secondaryCommand.split('->') - if (splittedSecondaryCommand.length < 3) { + if (splittedSecondaryCommand.length < 2) { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Paramenters') return } addTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2]) return } + case 'review': { + let splittedSecondaryCommand = secondaryCommand.split('->') + if (splittedSecondaryCommand.length < 2) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Paramenters') + return + } + addReview(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2]) + return + } case 'book': { addBook(splittedPrimaryCommand[3], secondaryCommand) return @@ -366,6 +379,15 @@ function newSuperalgosDocsCommmandInterface() { deleteTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2]) return } + case 'review': { + let splittedSecondaryCommand = secondaryCommand.split('->') + if (splittedSecondaryCommand.length < 3) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Paramenters') + return + } + deleteReview(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2]) + return + } case 'book': { deleteBook(splittedPrimaryCommand[3], secondaryCommand) return @@ -429,6 +451,10 @@ function newSuperalgosDocsCommmandInterface() { repaginate(splittedPrimaryCommand[3], 'Tutorial', secondaryCommand) return } + case 'review': { + repaginate(splittedPrimaryCommand[3], 'Review', secondaryCommand) + return + } case 'book': { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid') return @@ -488,6 +514,10 @@ function newSuperalgosDocsCommmandInterface() { httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Tutorial-Schema/' + project, onResponse) requestsSent++ + docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema + httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Review-Schema/' + project, onResponse) + requestsSent++ + docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Book-Schema/' + project, onResponse) requestsSent++ @@ -580,6 +610,21 @@ function newSuperalgosDocsCommmandInterface() { } SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema = documents + /* Reviews */ + documents = [] + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.length; i++) { + docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema[i] + docsSchemaDocument.updated = undefined + docsSchemaDocument.created = undefined + + if (docsSchemaDocument.deleted === true) { + SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.delete(docsSchemaDocument.type) + } else { + documents.push(docsSchemaDocument) + } + } + SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema = documents + /* Books */ documents = [] for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) { @@ -611,7 +656,7 @@ function newSuperalgosDocsCommmandInterface() { ) if (orderedArray.length = 0) { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'No Matching Topic Or Tutorial Found') + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'No Matching Topic, Tutorial or Review Found') return } @@ -681,6 +726,17 @@ function newSuperalgosDocsCommmandInterface() { } function addTopic(project, topic, type, pageNumber) { + if (pageNumber === undefined) { + + let orderedArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex( + project, + 'Topic', + review + ) + + pageNumber = orderedArray.length + 1 + } + let template = { created: true, topic: topic, @@ -710,6 +766,17 @@ function newSuperalgosDocsCommmandInterface() { } function addTutorial(project, tutorial, type, pageNumber) { + if (pageNumber === undefined) { + + let orderedArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex( + project, + 'Tutorial', + review + ) + + pageNumber = orderedArray.length + 1 + } + let template = { created: true, tutorial: tutorial, @@ -738,6 +805,46 @@ function newSuperalgosDocsCommmandInterface() { UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Tutorial', type) } + function addReview(project, review, type, pageNumber) { + if (pageNumber === undefined) { + + let orderedArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex( + project, + 'Review', + review + ) + + pageNumber = orderedArray.length + 1 + } + + let template = { + created: true, + review: review, + pageNumber: pageNumber, + type: type, + definition: { text: "Write here a summary for this review page." }, + paragraphs: [ + { + style: "Text", + text: UI.projects.superalgos.globals.docs.NEW_PARAGRAPH_TEXT + } + ] + } + if (SCHEMAS_BY_PROJECT.get(project) === undefined) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist') + return + } + let exist = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + if (exist !== undefined) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists') + return + } + + SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.push(template) + SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.set(type, template) + UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Review', type) + } + function addBook(project, type) { let template = { created: true, @@ -852,6 +959,32 @@ function newSuperalgosDocsCommmandInterface() { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message - Deleting Succeed') } + function deleteReview(project, review, type, pageNumber) { + if (SCHEMAS_BY_PROJECT.get(project) === undefined) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist') + return + } + let exist = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + if (exist === undefined) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist') + return + } else { + if (exist.pageNumber !== pageNumber) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Page Number Mismatch', 'Anchor Page Number Mismatch') + return + } + if (exist.review !== review) { + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Review Mismatch', 'Anchor Review Mismatch') + return + } + } + + let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + schemaDocument.deleted = true + + UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message - Deleting Succeed') + } + function deleteBook(project, type) { if (SCHEMAS_BY_PROJECT.get(project) === undefined) { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist') diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 4348dc086..3b2391304 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -18,7 +18,7 @@ function newSuperalgosDocSpace() { currentDocumentBeingRendered: undefined, previousDocumentBeingRendered: undefined, currentBookBeingRendered: undefined, - paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials or Books Schema in order to find it when we need to update them. + paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials, Reviews or Books Schema in order to find it when we need to update them. textArea: undefined, changeLanguage: changeLanguage, changeActiveBranch: changeActiveBranch, diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index 2922d1e02..2c73f6048 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -49,6 +49,10 @@ function newSuperalgosDocsDocumentPage() { thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsTutorialSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) break } + case 'Review': { + thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsReviewSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) + break + } case 'Workspace': { thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.workspaceSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId) break @@ -124,6 +128,7 @@ function newSuperalgosDocsDocumentPage() { let hierarchyImagesArray = [] let orderedTopicPageIndexArray = [] let orderedTutorialPageIndexArray = [] + let orderedReviewPageIndexArray = [] let HTML = '' HTML = HTML + '
' @@ -218,6 +223,32 @@ function newSuperalgosDocsDocumentPage() { HTML = HTML = HTML + '' // 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 + '

' + titleLabel + '

' + */ + + generateReviewPreviousAndNextPageNavigation() + + HTML = HTML = HTML + '
' // Container for Review Navigation including buttons, title and index + + HTML = HTML + '

' + thisObject.docsSchemaDocument.review + ' — TOC

' + + HTML = HTML + '

You just read page ' + thisObject.docsSchemaDocument.pageNumber + ' of this review collection.

' + + generateReviewMultiPageIndex() + + HTML = HTML = HTML + '
' // END Container for Review Navigation + } + HTML = HTML + '' // Common Style Container Ends /* @@ -258,7 +289,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 === 'Concept' || category === 'Book') && testElement === undefined) { + if ((category === 'Topic' || category === 'Tutorial' || category === 'Review' || category === 'Concept' || category === 'Book') && testElement === undefined) { HTML = HTML + '
Summary: ' + UI.projects.superalgos.utilities.docs.addToolTips(definitionText, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) + '
' } else { HTML = HTML + '
' @@ -374,6 +405,52 @@ function newSuperalgosDocsDocumentPage() { } } + function generateReviewPreviousAndNextPageNavigation() { + let previousPage + let nextPage + + for (let i = 0; i < orderedReviewPageIndexArray.length; i++) { + let arrayItem = orderedReviewPageIndexArray[i] + + if (thisObject.docsSchemaDocument.type === arrayItem.type) { + previousPage = orderedReviewPageIndexArray[i - 1] + nextPage = orderedReviewPageIndexArray[i + 1] + + HTML = HTML + '
' + if (previousPage !== undefined) { + HTML = HTML + '
' + previousPage.type + } + HTML = HTML + '
' + if (nextPage !== undefined) { + HTML = HTML + '
' + nextPage.type + } + HTML = HTML + '
' + return + } + } + } + + function generateReviewMultiPageIndex() { + /* + We will go through all the schema docuents array for the current project and pick + the documents that share the same key thatn the document we are rendering now. + With the info on those picked document we will build the index. + */ + let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex + let paragraph + + for (let i = 0; i < orderedReviewPageIndexArray.length; i++) { + let arrayItem = orderedReviewPageIndexArray[i] + key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex + paragraph = { + style: "Title", + text: "" + arrayItem.type + "" + } + autoGeneratedParagraphIndex++ + HTML = HTML + '

' + arrayItem.pageNumber + '. ' + '' + paragraph.text + '

' + } + } + function addContent() { HTML = HTML + '
' if (thisObject.docsSchemaDocument.paragraphs !== undefined) { @@ -458,11 +535,15 @@ function newSuperalgosDocsDocumentPage() { includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type) break } + case 'Review': { + includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + break + } case 'Book': { includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type) break } - default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic, Tutorial or Book instead.' + default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic, Review or Book instead.' } if (includedSchemaDocument === undefined) { return category + ' document ' + type + ' not found at project ' + project @@ -531,8 +612,8 @@ function newSuperalgosDocsDocumentPage() { return 'Chapter paragraph style Syntax Error. The Project ' + project + ' could not be found. Check the Docs Chapter Style Syntax. This error message will dissapear as soon as you fix the problem.' } - if (category !== 'Topic' && category !== 'Tutorial') { - return 'Category must be either Topic or Tutorial. Found: ' + category + '' + if (category !== 'Topic' && category !== 'Tutorial' && category !== 'Review') { + return 'Category must be either Topic, Tutorial or Review. Found: ' + category + '' } switch (category) { @@ -560,6 +641,18 @@ function newSuperalgosDocsDocumentPage() { } break } + case 'Review': { + orderedReviewPageIndexArray = UI.projects.superalgos.utilities.docs.buildOrderedPageIndex( + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project, + 'Review', + chapterName + ) + + if (orderedReviewPageIndexArray.length === 0) { + return 'Chapter paragraph style Syntax Error. The Review ' + chapterName + ' could not be found. Check the Docs Chapter Style Syntax. This error message will dissapear as soon as you fix the problem.' + } + break + } } HTML = HTML = HTML + '
' // Container for Topic Index @@ -598,6 +691,10 @@ function newSuperalgosDocsDocumentPage() { generateTutorialMultiPageIndex() break } + case 'Review': { + generateReviewMultiPageIndex() + break + } } HTML = HTML = HTML + '
' // Container for Topic Index diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js index 7361caa12..5b652eb47 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js @@ -53,7 +53,7 @@ function newSuperalgosDocsMainSearchPage() { if (event.key === "Enter" || event.keyCode === 13) { UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered = undefined UI.projects.superalgos.spaces.docsSpace.contextMenu.forceOutClick() - UI.projects.superalgos.spaces.docsSpace.commandInterface.command = element.value + UI.projects.superalgos.spaces.docsSpace.commandInterface.command = element.value.trim() UI.projects.superalgos.spaces.docsSpace.commandInterface.detectCommands() } }); diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js index 05f6b8f4b..8b6c3659d 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js @@ -18,7 +18,7 @@ function newSuperalgosDocsSearchEngine() { function setUpSearchEngine() { - setUpWorkspaceSchemas() + setUpWorkspaceSchemas() thisObject.docsIndex = [] for (let j = 0; j < PROJECTS_ARRAY.length; j++) { @@ -70,6 +70,17 @@ function newSuperalgosDocsSearchEngine() { indexDocument(documentIndex) thisObject.docsIndex.push(documentIndex) } + /* Search in Reviews */ + for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.length; i++) { + documentIndex = { + phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count. + docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema[i], + category: 'Review', + project: project + } + indexDocument(documentIndex) + thisObject.docsIndex.push(documentIndex) + } /* Search in Books */ for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) { documentIndex = { @@ -114,6 +125,13 @@ function newSuperalgosDocsSearchEngine() { } indexParagraph(paragraph) } + if (documentIndex.docsSchemaDocument.review !== undefined) { + let paragraph = { + style: 'Review', + text: documentIndex.docsSchemaDocument.review + } + indexParagraph(paragraph) + } if (documentIndex.docsSchemaDocument.type !== undefined) { let paragraph = { style: 'Type', diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchResultsPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchResultsPage.js index a227fadbc..8d1a631dd 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchResultsPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchResultsPage.js @@ -49,6 +49,11 @@ function newSuperalgosDocsSearchResultsPage() { documentPoints = documentPoints + thisPhraseCount * 200 } } + if (documentIndex.docsSchemaDocument.review !== undefined) { + if (key === UI.projects.superalgos.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.review.toLowerCase())) { + documentPoints = documentPoints + thisPhraseCount * 200 + } + } switch (style) { case 'topic': { @@ -59,6 +64,10 @@ function newSuperalgosDocsSearchResultsPage() { documentPoints = documentPoints + thisPhraseCount * 100 break } + case 'review': { + documentPoints = documentPoints + thisPhraseCount * 100 + break + } case 'type': { documentPoints = documentPoints + thisPhraseCount * 50 break @@ -194,7 +203,7 @@ function newSuperalgosDocsSearchResultsPage() { } function buildHTML() { - const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Tutorials', 'Books', 'Workspace'] + const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Tutorials', 'Reviews', 'Books', 'Workspace'] let HTML = '' HTML = HTML + '
' HTML = HTML + UI.projects.superalgos.spaces.docsSpace.mainSearchPage.addSearchHeader() @@ -265,6 +274,10 @@ function newSuperalgosDocsSearchResultsPage() { mainLink = result.documentIndex.docsSchemaDocument.tutorial + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type break } + case 'Review': { + mainLink = result.documentIndex.docsSchemaDocument.review + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type + break + } default: { mainLink = result.documentIndex.docsSchemaDocument.type } diff --git a/Projects/Superalgos/UI/Utilities/Docs.js b/Projects/Superalgos/UI/Utilities/Docs.js index 7d434ded7..6fada327c 100644 --- a/Projects/Superalgos/UI/Utilities/Docs.js +++ b/Projects/Superalgos/UI/Utilities/Docs.js @@ -40,6 +40,10 @@ function newSuperalgosUtilitiesDocs() { schemaArray = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema break } + case 'Review': { + schemaArray = SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema + break + } } for (let i = 0; i < schemaArray.length; i++) { @@ -54,6 +58,10 @@ function newSuperalgosUtilitiesDocs() { if (arrayItem.tutorial !== query) { continue } break } + case 'Review': { + if (arrayItem.review !== query) { continue } + break + } } let itemAdded = false @@ -563,6 +571,11 @@ function newSuperalgosUtilitiesDocs() { found = true break } + docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) + if (docsSchemaDocument !== undefined) { + found = true + break + } docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type) if (docsSchemaDocument !== undefined) { found = true @@ -645,6 +658,7 @@ function newSuperalgosUtilitiesDocs() { searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema) searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema) searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema) + searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema) searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema) function searchInSchema(docSchema) { diff --git a/UI/AppPostLoader.js b/UI/AppPostLoader.js index fb00686ee..efd38aba4 100644 --- a/UI/AppPostLoader.js +++ b/UI/AppPostLoader.js @@ -44,6 +44,7 @@ function newAppPostLoader() { docsConceptSchema: [], docsTopicSchema: [], docsTutorialSchema: [], + docsReviewSchema: [], docsBookSchema: [] }, map: { @@ -52,6 +53,7 @@ function newAppPostLoader() { docsConceptSchema: new Map(), docsTopicSchema: new Map(), docsTutorialSchema: new Map(), + docsReviewSchema: new Map(), docsBookSchema: new Map() } } @@ -157,6 +159,26 @@ function newAppPostLoader() { if (webServerResponses === totalWebServerCalls) { startCanvas() } } + totalWebServerCalls++ + httpRequest(undefined, 'Schema/' + project + '/DocsReviewSchema', onResponseReviewSchema) + + function onResponseReviewSchema(err, schema) { + try { + schemas.array.docsReviewSchema = JSON.parse(schema) + + for (let j = 0; j < schemas.array.docsReviewSchema.length; j++) { + let schemaDocument = schemas.array.docsReviewSchema[j] + let key = schemaDocument.type + schemas.map.docsReviewSchema.set(key, schemaDocument) + } + } catch (err) { + console.log(err.stack) + } + + webServerResponses++ + if (webServerResponses === totalWebServerCalls) { startCanvas() } + } + totalWebServerCalls++ httpRequest(undefined, 'Schema/' + project + '/DocsBookSchema', onResponseBookSchema) From 9b6d0a9a21e6f2a0f403a5a0877e044f0e2442e0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 11:52:50 +0100 Subject: [PATCH 03/17] This is my contribution to Superalgos --- .../UI/Spaces/Docs-Space/CommandInterface.js | 2 +- .../UI/Spaces/Docs-Space/DocumentPage.js | 27 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 8a01632ae..0f9c82b1e 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -202,7 +202,7 @@ function newSuperalgosDocsCommmandInterface() { docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type) break } - case 'Review': { + case 'review': { docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type) break } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index 2c73f6048..cd9423cf1 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -186,7 +186,7 @@ function newSuperalgosDocsDocumentPage() { */ generateTopicPreviousAndNextPageNavigation() - HTML = HTML = HTML + '
' // Container for Topic Navigation including buttons, title and index + HTML = HTML + '
' // Container for Topic Navigation including buttons, title and index HTML = HTML + '

' + thisObject.docsSchemaDocument.topic + ' — TOC

' @@ -194,7 +194,7 @@ function newSuperalgosDocsDocumentPage() { generateTopicMultiPageIndex() - HTML = HTML = HTML + '
' // END Container for Topic Navigation + HTML = HTML + '
' // END Container for Topic Navigation } if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Tutorial') { @@ -212,7 +212,7 @@ function newSuperalgosDocsDocumentPage() { generateTutorialPreviousAndNextPageNavigation() - HTML = HTML = HTML + '
' // Container for Tutorial Navigation including buttons, title and index + HTML = HTML + '
' // Container for Tutorial Navigation including buttons, title and index HTML = HTML + '

' + thisObject.docsSchemaDocument.tutorial + ' — TOC

' @@ -220,7 +220,7 @@ function newSuperalgosDocsDocumentPage() { generateTutorialMultiPageIndex() - HTML = HTML = HTML + '
' // END Container for Tutorial Navigation + HTML = HTML + '
' // END Container for Tutorial Navigation } if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Review') { @@ -238,7 +238,7 @@ function newSuperalgosDocsDocumentPage() { generateReviewPreviousAndNextPageNavigation() - HTML = HTML = HTML + '
' // Container for Review Navigation including buttons, title and index + HTML = HTML + '
' // Container for Review Navigation including buttons, title and index HTML = HTML + '

' + thisObject.docsSchemaDocument.review + ' — TOC

' @@ -246,7 +246,7 @@ function newSuperalgosDocsDocumentPage() { generateReviewMultiPageIndex() - HTML = HTML = HTML + '
' // END Container for Review Navigation + HTML = HTML + '
' // END Container for Review Navigation } HTML = HTML + '
' // Common Style Container Ends @@ -341,14 +341,11 @@ function newSuperalgosDocsDocumentPage() { the documents that share the same key thatn the document we are rendering now. With the info on those picked document we will build the index. */ - let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex let paragraph - - for (let i = 0; i < orderedTopicPageIndexArray.length; i++) { let arrayItem = orderedTopicPageIndexArray[i] - key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex + let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex paragraph = { style: "Title", text: "" + arrayItem.type + "" @@ -390,12 +387,11 @@ function newSuperalgosDocsDocumentPage() { the documents that share the same key thatn the document we are rendering now. With the info on those picked document we will build the index. */ - let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex let paragraph for (let i = 0; i < orderedTutorialPageIndexArray.length; i++) { let arrayItem = orderedTutorialPageIndexArray[i] - key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex + let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex paragraph = { style: "Title", text: "" + arrayItem.type + "" @@ -436,12 +432,11 @@ function newSuperalgosDocsDocumentPage() { the documents that share the same key thatn the document we are rendering now. With the info on those picked document we will build the index. */ - let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex let paragraph for (let i = 0; i < orderedReviewPageIndexArray.length; i++) { let arrayItem = orderedReviewPageIndexArray[i] - key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex + let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex paragraph = { style: "Title", text: "" + arrayItem.type + "" @@ -655,7 +650,7 @@ function newSuperalgosDocsDocumentPage() { } } - HTML = HTML = HTML + '
' // Container for Topic Index + HTML = HTML + '
' // Container for Topic Index let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex paragraph = { @@ -697,7 +692,7 @@ function newSuperalgosDocsDocumentPage() { } } - HTML = HTML = HTML + '
' // Container for Topic Index + HTML = HTML + '
' // Container for Topic Index } } From 1291917c94fdba44dc24de9bf5cc4fe7f1a3b9a8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 12:32:13 +0100 Subject: [PATCH 04/17] This is my contribution to Superalgos --- .../app-commands-002-app-update-command.json | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json index 3c7341b28..58aae238a 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-002-app-update-command.json @@ -14,16 +14,8 @@ }, { "style": "Json", - "text": "docs.update Message" - }, - { - "style": "Title", - "text": "Parameters" - }, - { - "style": "List", - "text": "Message: This is optional. It is the message that is going to be recorded at Github.com when we merge for you the branch of the main repository into the branch of your fork.", - "updated": 1610449466750 + "text": "docs.update", + "updated": 1610710006400 }, { "style": "Title", From b83348c75ae5f534a04c018a6f803576df3f9420 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:23:34 +0100 Subject: [PATCH 05/17] But Fixed: Tutorial crashes app when referenced page was not found. --- ...-001-app-message-contribution-succeed.json | 4 +-- .../UI/Spaces/Tutorial-Space/TutorialSpace.js | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-001-app-message-contribution-succeed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-001-app-message-contribution-succeed.json index 8f881d306..18854cefb 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-001-app-message-contribution-succeed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-001-app-message-contribution-succeed.json @@ -9,8 +9,8 @@ "paragraphs": [ { "style": "Success", - "text": "There is no further action from you required. Someone will review your changes and merge them into the latest version of the software. If your changes are rejected for any reason, you will have to follow the issue at the Github.com web site.", - "updated": 1610478538194 + "text": "There is no further action from you required. Someone will review your changes and merge them into the latest version of the software. If your changes are rejected for any reason, you will have to follow the issue at the Github.com web site. ", + "updated": 1610712264828 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js b/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js index cf4b88bd2..21392d411 100644 --- a/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js +++ b/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js @@ -1142,6 +1142,37 @@ function newSuperalgosTutorialSpace() { let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(nodeConfig.docs.type) + if (schemaDocument === undefined) { + schemaDocument = { + type: 'Tutorial', + definition: { + text: "You need to reference a page at the docs at the config of this node. Use the docs property for that." + }, + icon: { + project: "Superalgos", + name: "warning" + }, + paragraphs: [ + { + style: "Title", + text: "Example" + }, + { + style: "Json", + text: ' \"docs\": { \n' + + '\"project\": \"Superalgos\",\n' + + '\"category\": \"Tutorial\",\n' + + '\"type\": \"Tutorial Step - Bla Bla\"\n' + + '}' + }, + { + style: "Note", + text: "If you did, then that page was not found." + }, + ] + } + } + newConfig = currentNode.config newDocument = JSON.stringify(schemaDocument) + ' - ' + UI.projects.superalgos.spaces.docsSpace.language From 4647ab2758a5c518f0db2bfc8b0dc9f5795a2eb4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:37:45 +0100 Subject: [PATCH 06/17] This is my contribution to Superalgos --- Client/httpInterface.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 868755e4d..c1d69da31 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -599,8 +599,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE contribute() async function contribute() { - await doGit() - await doGithub() + if (await doGit() === false) { + respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + } + if (await doGithub() === false) { + respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } @@ -617,10 +621,14 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE await git.add('./*') await git.commit(commitMessage) await git.push('origin', currentBranch) + return true } catch (err) { - console.log('[ERROR] Error running Contribute.') - console.log(err.stack) - throw (err) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> Method call produced an error.') + console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> commitMessage = ' + commitMessage) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> contributionsBranch = ' + contributionsBranch) + return false } } @@ -647,9 +655,19 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE head, base, }); + return true } catch (err) { - if (err.stack.indexOf('A pull request already exists') < 0) { - throw (err) + if (err.stack.indexOf('A pull request already exists') >= 0) { + return true + } else { + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token = ' + token) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) + return false } } } @@ -660,6 +678,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> username = ' + username) console.log('[ERROR] httpInterface -> App -> Contribute -> token = ' + token) + console.log('[ERROR] httpInterface -> App -> Contribute -> currentBranch = ' + currentBranch) + console.log('[ERROR] httpInterface -> App -> Contribute -> contributionsBranch = ' + contributionsBranch) let error = { result: 'Fail Because', From 75254b774b5d331c985f6a7db34a297434473392 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:39:11 +0100 Subject: [PATCH 07/17] This is my contribution to Superalgos --- Client/httpInterface.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index c1d69da31..a89a053fb 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -601,9 +601,11 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE async function contribute() { if (await doGit() === false) { respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + return } if (await doGithub() === false) { respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } From 26dcdeaaed1338282287c154dc865942e86d1328 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:42:19 +0100 Subject: [PATCH 08/17] This is my contribution to Superalgos --- Client/httpInterface.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index a89a053fb..115272566 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -666,7 +666,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token = ' + token) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(1, 5)) + '...' + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length-5, 5)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) return false From b59a8d0fa4280a10a1cb58d70d6c29716af8c53c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:44:48 +0100 Subject: [PATCH 09/17] This is my contribution to Superalgos --- Client/httpInterface.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 115272566..a517cf35a 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -539,7 +539,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE fs.mkdirSync(filePath) } catch (err) { if (err.message.indexOf('file already exists') < 0) { - throw(err) + throw (err) } } fs.writeFileSync(filePath + '/' + fileName, fileContent) @@ -666,8 +666,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(1, 5)) + '...' - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length-5, 5)) + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(1, 10)) + '...' + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) return false From 5ba59db34201d456b89a1738c07a03e847f73325 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 13:46:09 +0100 Subject: [PATCH 10/17] This is my contribution to Superalgos --- Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index a517cf35a..2a968bdd2 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -666,7 +666,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(1, 10)) + '...' + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) From 20c7c145676c319a7a9dccfc9c4dc45c1c1b0462 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 16:34:53 +0100 Subject: [PATCH 11/17] Bug Fixed:Not exiting edit mode when user types command --- .../Superalgos/UI/Spaces/Docs-Space/ContextMenu.js | 14 +++++++------- .../UI/Spaces/Docs-Space/DocumentPage.js | 2 +- .../UI/Spaces/Docs-Space/MainSearchPage.js | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js index 8614e01a2..99d4f8ce3 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js @@ -2,7 +2,7 @@ function newSuperalgosDocsContextMenu() { let thisObject = { selectedParagraph: undefined, getSelection: getSelection, - forceOutClick: forceOutClick, + removeContextMenuFromScreen: removeContextMenuFromScreen, initialize: initialize, finalize: finalize } @@ -53,7 +53,7 @@ function newSuperalgosDocsContextMenu() { } function editParagraph() { - forceOutClick() + removeContextMenuFromScreen() showHTMLTextArea() function showHTMLTextArea() { @@ -107,7 +107,7 @@ function newSuperalgosDocsContextMenu() { UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.appendChild(UI.projects.superalgos.spaces.docsSpace.textArea) UI.projects.superalgos.spaces.docsSpace.textArea.style.display = 'block' UI.projects.superalgos.spaces.docsSpace.textArea.focus() - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.enterEditMode() } } @@ -116,7 +116,7 @@ function newSuperalgosDocsContextMenu() { if (selectedParagraphIndex === undefined) { return } if (selectedParagraphIndex === 0) { return } UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.paragraphs.splice(selectedParagraphIndex, 1) - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true UI.projects.superalgos.spaces.docsSpace.documentPage.render() } @@ -260,20 +260,20 @@ function newSuperalgosDocsContextMenu() { } UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(clipboard) - forceOutClick() + removeContextMenuFromScreen() } function replaceStyle(docSchemaParagraph, style) { if (docSchemaParagraph.style !== style) { UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true docSchemaParagraph.style = style - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.documentPage.render() } } } - function forceOutClick() { + function removeContextMenuFromScreen() { const outClick = document.getElementById('docs-space-div') const menu = document.getElementById('menu') menu.classList.remove('show') diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index cd9423cf1..10b06f8c9 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -1933,7 +1933,7 @@ function newSuperalgosDocsDocumentPage() { outClick.addEventListener('click', () => { if (EDITOR_ON_FOCUS !== true) { - UI.projects.superalgos.spaces.docsSpace.contextMenu.forceOutClick() + UI.projects.superalgos.spaces.docsSpace.contextMenu.removeContextMenuFromScreen() } }) } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js index 5b652eb47..467185d54 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js @@ -1,9 +1,9 @@ function newSuperalgosDocsMainSearchPage() { let thisObject = { - addSearchHeader: addSearchHeader, + addSearchHeader: addSearchHeader, detectEnterOnSearchBox: detectEnterOnSearchBox, setFocusOnSearchBox: setFocusOnSearchBox, - render: render, + render: render, initialize: initialize, finalize: finalize } @@ -51,8 +51,9 @@ function newSuperalgosDocsMainSearchPage() { } element.addEventListener("keyup", function (event) { if (event.key === "Enter" || event.keyCode === 13) { + UI.projects.superalgos.spaces.docsSpace.exitEditMode() UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered = undefined - UI.projects.superalgos.spaces.docsSpace.contextMenu.forceOutClick() + UI.projects.superalgos.spaces.docsSpace.contextMenu.removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.commandInterface.command = element.value.trim() UI.projects.superalgos.spaces.docsSpace.commandInterface.detectCommands() } From 0fc8ffba67cc284da0e7d12f4396a3eaac6b7837 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 09:21:04 +0100 Subject: [PATCH 12/17] cleaning --- .../Trading-Bot/Low-Frequency-Trading/TradingProcess.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 5fa0d90b7..535a2e925 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -757,11 +757,6 @@ } } - function pad(str, max) { - str = str.toString(); - return str.length < max ? pad(" " + str, max) : str; - } - async function asyncGetDatasetFile(datasetModule, filePath, fileName) { let promise = new Promise((resolve, reject) => { From faf8e306c4d41792a4e5fbb44c2a584be45397ea Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 09:54:45 +0100 Subject: [PATCH 13/17] Bug Fix #330 --- .../Low-Frequency-Trading/TradingProcess.js | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 535a2e925..41cd05ae9 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -483,37 +483,50 @@ continue } + /* + If it is not a dependency then we pass.. + */ if (dataDependenciesModule.isItADepenency(timeFrameLabel, datasetModule.node.parentNode.config.singularVariableName) !== true) { if (!(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === timeFrameLabel && datasetModule.node.parentNode.config.pluralVariableName === 'candles')) { continue } } - let dateForPath = tradingProcessDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(tradingProcessDate.getUTCDate(), 2); - let filePath - if (dependency.referenceParent.config.codeName === "Multi-Period-Daily") { - filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath; - } else { - filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + dateForPath; - } - let fileName = "Data.json"; + /* + We will need to fetch the data of the current day and the previous day, in order for .previous properties in conditions and formulas to work well. + */ + let previousDate = new Date(tradingProcessDate.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) + let currentDate = new Date(tradingProcessDate.valueOf()) - /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ - let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) + let previousFile = getDataFileFromDate(previousDate) + if (previousFile === false) { return false } + let currentFile = getDataFileFromDate(currentDate) + if (currentFile === false) { return false } + let bothFiles = previousFile.concat(currentFile) - if (response.err.message === 'File does not exist.') { - return false - } - if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - throw (response.err) - } + let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + multiPeriodDataFiles.set(mapKey, bothFiles) + dataFiles.set(dependency.id, bothFiles) - let dataFile = JSON.parse(response.text); - dataFiles.set(dependency.id, dataFile); + function getDataFileFromDate(processDate) { + + let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2); + let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath + let fileName = "Data.json"; + + /* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */ + let response = await asyncGetDatasetFile(datasetModule, filePath, fileName) + + if (response.err.message === 'File does not exist.') { + return false + } + if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + throw (response.err) + } + + return JSON.parse(response.text) + } } - - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; - multiPeriodDataFiles.set(mapKey, dataFiles) } return true } From ea6f2f3f20571ad3d0c173bc0a8bc49e73739b70 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 10:26:59 +0100 Subject: [PATCH 14/17] Bug Fixed --- .../Low-Frequency-Trading/TradingProcess.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 41cd05ae9..01cb5c568 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -498,17 +498,16 @@ let previousDate = new Date(tradingProcessDate.valueOf() - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let currentDate = new Date(tradingProcessDate.valueOf()) - let previousFile = getDataFileFromDate(previousDate) + let previousFile = await getDataFileFromDate(previousDate) if (previousFile === false) { return false } - let currentFile = getDataFileFromDate(currentDate) + let currentFile = await getDataFileFromDate(currentDate) if (currentFile === false) { return false } let bothFiles = previousFile.concat(currentFile) - - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; - multiPeriodDataFiles.set(mapKey, bothFiles) dataFiles.set(dependency.id, bothFiles) - - function getDataFileFromDate(processDate) { + let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + multiPeriodDataFiles.set(mapKey, dataFiles) + + async function getDataFileFromDate(processDate) { let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2); let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel + "/" + dateForPath From 50b48be76ac53edd9c1d0dd945dc9e18d489bea2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 10:38:23 +0100 Subject: [PATCH 15/17] Final Bug Fix --- .../Trading-Bot/Low-Frequency-Trading/TradingProcess.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 01cb5c568..5cb4ed54a 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -504,9 +504,7 @@ if (currentFile === false) { return false } let bothFiles = previousFile.concat(currentFile) dataFiles.set(dependency.id, bothFiles) - let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; - multiPeriodDataFiles.set(mapKey, dataFiles) - + async function getDataFileFromDate(processDate) { let dateForPath = processDate.getUTCFullYear() + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCMonth() + 1, 2) + '/' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processDate.getUTCDate(), 2); @@ -526,6 +524,8 @@ return JSON.parse(response.text) } } + let mapKey = TS.projects.superalgos.globals.timeFrames.dailyFilePeriods()[n][1]; + multiPeriodDataFiles.set(mapKey, dataFiles) } return true } From 278a6d71e54a6f26cb296e2c879aec4fcb8ed515 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 11:42:15 +0100 Subject: [PATCH 16/17] Initial Candle calculation fixed --- .../TradingSimulation.js | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index 176b0beb6..af3e5c93c 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -55,13 +55,18 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { if ( TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_FIRST_LOOP === true && TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_RESUMING === false) { - /* Estimate Initial Candle based on the timeRage configured for the session. */ - let firstEnd = candles[0].end + + /* Estimate Initial Candle based on the timeRange configured for the session. */ + let firstIndex + let firstEnd + + sccanForInitialCandle() + let targetEnd = sessionParameters.timeRange.config.initialDatetime let diff = targetEnd - firstEnd let amount = diff / sessionParameters.timeFrame.config.value - initialCandle = Math.trunc(amount) + initialCandle = Math.trunc(amount) + firstIndex if (initialCandle < 0) { initialCandle = 0 } if (initialCandle > candles.length - 1) { /* @@ -73,8 +78,28 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { '[IMPORTANT] runSimulation -> Data is not up-to-date enough. Stopping the Session now. ') return } - } else { + function sccanForInitialCandle() { + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { + /* + When processing daily files, the initialCandle can not be the first candle of the arrray, + since we receive the candles from both the initialDatetime and the previousDay. We also don't know + now if the previousDay is complete, so the only effective solution is to scan all the candles until + we find the first one that is begining at the initialDay. + */ + for (let i = 0; i < candles.length; i++) { + let candle = candles[i] + if (candle.begin >= sessionParameters.timeRange.config.initialDatetime) { + firstEnd = candle.end + firstIndex = i + } + } + } else { + firstEnd = candles[0].end + firstIndex = 0 + } + } + } else { /* In this case we already have at the last candle index the next candle to be processed. We will just continue with this candle. @@ -545,7 +570,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { return true } } catch (err) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] runSimulation -> err = ' + err.stack) throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) } From bbd8578027c55e0facef51237281cb0bbf9dde8d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 Jan 2021 12:25:16 +0100 Subject: [PATCH 17/17] Bug Fixed --- .../Low-Frequency-Trading/TradingProcess.js | 3 +- .../TradingSimulation.js | 45 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js index 5cb4ed54a..ecd6796af 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingProcess.js @@ -87,7 +87,8 @@ This variable tell us which day we are standing at, specially while working with Daily Files. From this Date is that we are going to load the Daily Files. */ - TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingEngine.current.episode.processDate.value = TS.projects.superalgos.utilities.dateTimeFunctions.removeTime(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime).valueOf() + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingEngine.current.episode.processDate.value = + TS.projects.superalgos.utilities.dateTimeFunctions.removeTime(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime).valueOf() } /* diff --git a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js index af3e5c93c..d7846546d 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingSimulation.js @@ -45,6 +45,23 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { let propertyName = 'at' + sessionParameters.timeFrame.config.label.replace('-', '') let candles = chart[propertyName].candles + if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { + /* + We need to purge from the candles array all the candles from the previous day + that comes when processing daily files. + */ + let dailyCandles = [] + for (let i = 0; i < candles.length; i++) { + let candle = candles[i] + if (candle.begin >= TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingEngine.current.episode.processDate.value) { + dailyCandles.push(candle) + } + } + candles = dailyCandles + } else { + candles = chart[propertyName].candles + } + /* Variables needed for heartbeat functionality */ let heartBeatDate let previousHeartBeatDate @@ -57,16 +74,12 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_RESUMING === false) { /* Estimate Initial Candle based on the timeRange configured for the session. */ - let firstIndex - let firstEnd - - sccanForInitialCandle() - + let firstEnd = candles[0].end let targetEnd = sessionParameters.timeRange.config.initialDatetime let diff = targetEnd - firstEnd let amount = diff / sessionParameters.timeFrame.config.value - initialCandle = Math.trunc(amount) + firstIndex + initialCandle = Math.trunc(amount) if (initialCandle < 0) { initialCandle = 0 } if (initialCandle > candles.length - 1) { /* @@ -79,26 +92,6 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) { return } - function sccanForInitialCandle() { - if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) { - /* - When processing daily files, the initialCandle can not be the first candle of the arrray, - since we receive the candles from both the initialDatetime and the previousDay. We also don't know - now if the previousDay is complete, so the only effective solution is to scan all the candles until - we find the first one that is begining at the initialDay. - */ - for (let i = 0; i < candles.length; i++) { - let candle = candles[i] - if (candle.begin >= sessionParameters.timeRange.config.initialDatetime) { - firstEnd = candle.end - firstIndex = i - } - } - } else { - firstEnd = candles[0].end - firstIndex = 0 - } - } } else { /* In this case we already have at the last candle index the next candle to be