From 2ae4c5c87e397399de16797802a6b6896884f8a7 Mon Sep 17 00:00:00 2001 From: uday biswas Date: Tue, 3 Sep 2024 15:15:12 +0530 Subject: [PATCH 1/3] readme error resolved --- .../app/projects/project/project.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts index b968cb4..e6d199c 100644 --- a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts +++ b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts @@ -103,13 +103,13 @@ export class ProjectComponent implements OnInit { this.latestVersion = this.versions[0]; // Default to the latest version } // console.log("the loatest version : ", this.latestVersion); + this.projectService.getNotebookFile(result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0], this.latestVersion).subscribe( + notebookJson => { + this.notebookContent = this.sanitizer.bypassSecurityTrustHtml(this.renderNotebook(notebookJson)); + // console.log("the notebook content is : ", this.notebookContent); + }); }); // console.log("readme file is : ", result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0]); - this.projectService.getNotebookFile(result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0], this.latestVersion).subscribe( - notebookJson => { - this.notebookContent = this.sanitizer.bypassSecurityTrustHtml(this.renderNotebook(notebookJson)); - // console.log("the notebook content is : ", this.notebookContent); - }); } ) @@ -182,20 +182,20 @@ export class ProjectComponent implements OnInit { for (const cell of notebookJson.cells) { htmlContent += '
'; if (cell.cell_type === 'markdown') { - htmlContent += marked(cell.source.join('')); + htmlContent += marked(cell.source); } else if (cell.cell_type === 'code') { - htmlContent += '
' + hljs.highlight(cell.source.join(''), {language: 'python'}).value + '
'; + htmlContent += '
' + hljs.highlight(cell.source, {language: 'python'}).value + '
'; if (cell.outputs) { for (const output of cell.outputs) { if (output.data && output.data['text/html']) { - htmlContent += output.data['text/html'].join(''); + htmlContent += output.data['text/html']; } else if (output.data && output.data['image/png']) { htmlContent += ``; } else if (output.data && output.data['text/plain']) { - htmlContent += '
' + output.data['text/plain'].join('') + '
'; + htmlContent += '
' + output.data['text/plain'] + '
'; } else if (output.text) { - htmlContent += '
' + output.text.join('') + '
'; + htmlContent += '
' + output.text + '
'; } } } From 7f1ff484a9168d6a2875fedf7079d4e50e05b112 Mon Sep 17 00:00:00 2001 From: uday biswas Date: Wed, 4 Sep 2024 15:50:16 +0530 Subject: [PATCH 2/3] versioning update error resolved --- .../projects/project/project.component.scss | 1 + .../app/projects/project/project.component.ts | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.scss b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.scss index df315b5..03ee2de 100644 --- a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.scss +++ b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.scss @@ -53,6 +53,7 @@ .notebook-readme-full{ margin-bottom: 4px; + overflow-x: scroll; } .notebook-cell pre code div { diff --git a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts index e6d199c..729af28 100644 --- a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts +++ b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts @@ -95,18 +95,20 @@ export class ProjectComponent implements OnInit { if (this.currentUser != null && this.project.projectUsers.find(x => x.userID == this.currentUser.id) != undefined) { this.projectUser = this.project.projectUsers.find(x => x.userID == this.currentUser.id) } + // console.log("Result : ", result); this.readmeNotebook = result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0]; + // console.log("readme : " ,this.readmeNotebook); this.projectService.getNotebookVersions(result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0]).subscribe(versions => { this.versions = versions; - //console.log("Versions: ", this.versions); + // console.log("Versions: ", this.versions); if (this.versions.length > 0) { this.latestVersion = this.versions[0]; // Default to the latest version } // console.log("the loatest version : ", this.latestVersion); this.projectService.getNotebookFile(result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0], this.latestVersion).subscribe( notebookJson => { + // console.log("the notebook content is : ", notebookJson); this.notebookContent = this.sanitizer.bypassSecurityTrustHtml(this.renderNotebook(notebookJson)); - // console.log("the notebook content is : ", this.notebookContent); }); }); // console.log("readme file is : ", result.notebooks.filter((notebook) => notebook.name.toLowerCase() === "readme")[0]); @@ -177,25 +179,31 @@ export class ProjectComponent implements OnInit { } renderNotebook(notebookJson: any): string { - // Simple rendering of the notebook. Customize as needed. + // console.log("notebook rendering content :" , notebookJson); let htmlContent = `
`; for (const cell of notebookJson.cells) { htmlContent += '
'; if (cell.cell_type === 'markdown') { - htmlContent += marked(cell.source); + const markdownContent = Array.isArray(cell.source) ? cell.source.join('') : cell.source; + htmlContent += marked(markdownContent); } else if (cell.cell_type === 'code') { - htmlContent += '
' + hljs.highlight(cell.source, {language: 'python'}).value + '
'; + // console.log("error: ", hljs.highlight(cell.source, {language: 'python'})); + const codeContent = Array.isArray(cell.source) ? cell.source.join('') : cell.source; + htmlContent += '
' + hljs.highlight(codeContent, { language: 'python' }).value + '
'; if (cell.outputs) { for (const output of cell.outputs) { if (output.data && output.data['text/html']) { - htmlContent += output.data['text/html']; + const htmlOutput = Array.isArray(output.data['text/html']) ? output.data['text/html'].join('') : output.data['text/html']; + htmlContent += htmlOutput; } else if (output.data && output.data['image/png']) { htmlContent += ``; } else if (output.data && output.data['text/plain']) { - htmlContent += '
' + output.data['text/plain'] + '
'; + const plainTextOutput = Array.isArray(output.data['text/plain']) ? output.data['text/plain'].join('') : output.data['text/plain']; + htmlContent += '
' + plainTextOutput + '
'; } else if (output.text) { - htmlContent += '
' + output.text + '
'; + const outputText = Array.isArray(output.text) ? output.text.join('') : output.text; + htmlContent += '
' + outputText + '
'; } } } From e5a2a2f8c3be38aa320488bd8f3dae11f730bc91 Mon Sep 17 00:00:00 2001 From: uday biswas Date: Fri, 13 Sep 2024 09:39:07 +0530 Subject: [PATCH 3/3] readme refresh done --- .../src/app/projects/project/project.component.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts index 729af28..2b6a865 100644 --- a/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts +++ b/src/Analysim.Web/ClientApp/src/app/projects/project/project.component.ts @@ -176,6 +176,19 @@ export class ProjectComponent implements OnInit { closeDisplayNotebookModal() { this.displayNotebookModalRef.hide(); this.router.navigate([this.router.url.split('/').slice(0,5).join('/')]) + this.projectService.getNotebookVersions(this.readmeNotebook).subscribe(versions => { + this.versions = versions; + // console.log("Versions: ", this.versions); + if (this.versions.length > 0) { + this.latestVersion = this.versions[0]; // Default to the latest version + } + // console.log("the loatest version : ", this.latestVersion); + this.projectService.getNotebookFile(this.readmeNotebook, this.latestVersion).subscribe( + notebookJson => { + // console.log("the notebook content is : ", notebookJson); + this.notebookContent = this.sanitizer.bypassSecurityTrustHtml(this.renderNotebook(notebookJson)); + }); + }); } renderNotebook(notebookJson: any): string {