diff --git a/core/gui/src/app/workspace/service/report-generation/report-generation.service.ts b/core/gui/src/app/workspace/service/report-generation/report-generation.service.ts index 8331ab288ed..64c1700277d 100644 --- a/core/gui/src/app/workspace/service/report-generation/report-generation.service.ts +++ b/core/gui/src/app/workspace/service/report-generation/report-generation.service.ts @@ -119,47 +119,64 @@ export class ReportGenerationService { const resultService = this.workflowResultService.getResultService(operatorId); const paginatedResultService = this.workflowResultService.getPaginatedResultService(operatorId); - // Generate the HTML content for operator details, which will be included in the report - const operatorDetailsHtml = `
-

Operator Details

-
- -
`; + const workflowContent = this.workflowActionService.getWorkflowContent(); + const operatorDetails = workflowContent.operators.find(op => op.operatorID === operatorId); + + const operatorDetailsHtml = ` +
+

Operator Details

+
+ +
+ `; - // Check if the paginated result service is available if (paginatedResultService) { paginatedResultService.selectPage(1, 10).subscribe({ next: pageData => { try { // Handle the paginated results const table = pageData.table; - let htmlContent = `

Operator ID: ${operatorId}

`; - if (!table.length) { - // If no results are found, display a message - htmlContent += "

No results found for operator

"; - } else { - // Generate an HTML table to display the results - const columns: string[] = Object.keys(table[0]); - const rows: any[][] = table.map(row => columns.map(col => row[col])); - - htmlContent += `
- - - ${columns.map(col => ``).join("")} - - - ${rows.map(row => `${row.map(cell => ``).join("")}`).join("")} - -
${col}
${String(cell)}
-
`; + allResults.push({ + operatorId, + html: ` +

Operator ID: ${operatorId}

+

No results found for operator

+ + +
Add your comments here...
+ `, + }); + resolve(); + return; } + // Generate an HTML table to display the results + const columns: string[] = Object.keys(table[0]); + const rows: any[][] = table.map(row => columns.map(col => row[col])); + + const htmlContent: string = ` +
+

Operator ID: ${operatorId}

+ + + ${columns.map(col => ``).join("")} + + + ${rows.map(row => `${row.map(cell => ``).join("")}`).join("")} + +
${col}
${String(cell)}
+ + +
Add your comments here...
+
+ `; // Add the generated HTML content to the allResults array allResults.push({ operatorId, html: htmlContent }); @@ -181,59 +198,63 @@ export class ReportGenerationService { }, }); } else if (resultService) { - try { - // Retrieve the current snapshot of results - const data = resultService.getCurrentResultSnapshot(); - let htmlContent = `

Operator ID: ${operatorId}

`; + // Retrieve the current snapshot of results + const data = resultService.getCurrentResultSnapshot(); - if (data) { - // Parse the HTML content from the snapshot data - const parser = new DOMParser(); - const lastData = data[data.length - 1]; - const doc = parser.parseFromString(Object(lastData)["html-content"], "text/html"); + // Check if data exists; if it does, parse and display the HTML content. + // If no data is available, return a message indicating "No data found for operator." + if (data) { + // Parse the HTML content from the snapshot data + const parser = new DOMParser(); + const lastData = data[data.length - 1]; + const doc = parser.parseFromString(Object(lastData)["html-content"], "text/html"); - // Ensure the document's height is set correctly - doc.documentElement.style.height = "50%"; - doc.body.style.height = "50%"; + // Ensure the document's height is set correctly + doc.documentElement.style.height = "50%"; + doc.body.style.height = "50%"; - const firstDiv = doc.body.querySelector("div"); - if (firstDiv) firstDiv.style.height = "100%"; + const firstDiv = doc.body.querySelector("div"); + if (firstDiv) firstDiv.style.height = "100%"; - const serializer = new XMLSerializer(); - const newHtmlString = serializer.serializeToString(doc); + const serializer = new XMLSerializer(); + const newHtmlString = serializer.serializeToString(doc); - htmlContent += newHtmlString; - } else { - // If no data is found, display a message - htmlContent += "

No data found for operator

"; - } + const visualizationHtml = ` +

Operator ID: ${operatorId}

+ ${newHtmlString} + + +
Add your comments here...
+ `; - // Add the generated HTML content to the allResults array - allResults.push({ operatorId, html: htmlContent }); + allResults.push({ operatorId, html: visualizationHtml }); resolve(); - } catch (error: unknown) { - // Handle any errors during snapshot result processing - const errorMessage = (error as Error).message || "Unknown error"; - this.notificationService.error( - `Error processing snapshot results for operator ${operatorId}: ${errorMessage}` - ); - reject(error); - } - } else { - try { - // If no result services are available, provide a default message + } else { + // If no data is found, display a message allResults.push({ operatorId, - html: `

Operator ID: ${operatorId}

-

No results found for operator

`, + html: ` +

Operator ID: ${operatorId}

+

No data found for operator

+ + +
Add your comments here...
+ `, }); resolve(); - } catch (error: unknown) { - // Handle any errors when pushing the default result - const errorMessage = (error as Error).message || "Unknown error"; - this.notificationService.error(`Error pushing default result for operator ${operatorId}: ${errorMessage}`); - reject(error); } + } else { + allResults.push({ + operatorId, + html: ` +

Operator ID: ${operatorId}

+

No results found for operator

+ + +
Add your comments here...
+ `, + }); + resolve(); } } catch (error: unknown) { // Handle any unexpected errors that occur in the main logic @@ -260,6 +281,9 @@ export class ReportGenerationService { Operator Results + + + @@ -297,13 +339,16 @@ export class ReportGenerationService { Workflow Snapshot ${allResults.join("")} +
+ +
`; const blob = new Blob([htmlContent], { type: "text/html" }); const url = URL.createObjectURL(blob); - const fileName = `${workflowName}-report.html`; // Use workflowName to generate the file name + const fileName = `${workflowName}-report.html`; const a = document.createElement("a"); a.href = url; a.download = fileName; diff --git a/core/gui/src/index.html b/core/gui/src/index.html index 71cc7985e94..ec6e08bbb53 100644 --- a/core/gui/src/index.html +++ b/core/gui/src/index.html @@ -43,6 +43,13 @@ + + + +