From 6afb3b1153780997bdce61787da0500a47bf3733 Mon Sep 17 00:00:00 2001 From: CopyDemon Date: Sun, 28 Apr 2024 11:30:01 -0700 Subject: [PATCH] fix when DiagnosticsToolBox has error frontend has no responed issue --- .../diagnostics_display.module.css | 4 + .../diagnostics_display.tsx | 12 ++- .../flowsheet_diagnostic_runner_component.tsx | 6 +- ...sage_bar_template_generator_utility_fn.tsx | 8 +- idaes_ui/fv/model_server.py | 83 +++++++++++-------- 5 files changed, 76 insertions(+), 37 deletions(-) diff --git a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.module.css b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.module.css index af0307ae..5c036f78 100644 --- a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.module.css +++ b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.module.css @@ -122,4 +122,8 @@ background-color: white; box-shadow: 0px 0px 10px rgb(219, 219, 219); border-radius: 3px; +} + +.error_message{ + color: red; } \ No newline at end of file diff --git a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.tsx b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.tsx index 530eb984..f90caf5c 100644 --- a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.tsx +++ b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_component/diagnostics_display/diagnostics_display.tsx @@ -4,6 +4,7 @@ import axios from "axios"; import { config } from "@fortawesome/fontawesome-svg-core"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCopy } from '@fortawesome/free-solid-svg-icons'; +import { messageBarTemplateGenerator } from "@/components/message_bar_component/message_bar_template_generator_utility_fn"; import css from "./diagnostics_display.module.css"; export default function DiagnosticsDisplay(props:any){ @@ -167,8 +168,17 @@ export default function DiagnosticsDisplay(props:any){ return copyState }) - }catch(error){ + }catch(error:any){ + messageBarTemplateGenerator("diagnosticFNRunError", false, error.response.data.error) console.log(error) + const diagnosticsRunnerContentContainer = document.getElementById("diagnosticsRunner_content_container"); + if(diagnosticsRunnerContentContainer){ + const errorTemplate = ` +
${error.response.data.error}
+                    
+ ` + diagnosticsRunnerContentContainer.innerHTML+= errorTemplate + } } } diff --git a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_runner_component/flowsheet_diagnostic_runner_component.tsx b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_runner_component/flowsheet_diagnostic_runner_component.tsx index 41c710de..d3c9a149 100644 --- a/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_runner_component/flowsheet_diagnostic_runner_component.tsx +++ b/IDAES-UI/src/components/flowsheet_main_component/flowsheet_diagnostics_runner_component/flowsheet_diagnostic_runner_component.tsx @@ -36,7 +36,11 @@ export default function FlowsheetDiagnosticsRunner(){ },[displayLength]) return( -
+
{display}
) diff --git a/IDAES-UI/src/components/message_bar_component/message_bar_template_generator_utility_fn.tsx b/IDAES-UI/src/components/message_bar_component/message_bar_template_generator_utility_fn.tsx index ef0586f7..31d73dbb 100644 --- a/IDAES-UI/src/components/message_bar_component/message_bar_template_generator_utility_fn.tsx +++ b/IDAES-UI/src/components/message_bar_component/message_bar_template_generator_utility_fn.tsx @@ -1,6 +1,6 @@ import css from "./message_bar.module.css"; -export function messageBarTemplateGenerator(whichCalled:string, succeed:boolean){ +export function messageBarTemplateGenerator(whichCalled:string, succeed:boolean, error?:any){ let templateBgClass:string = "bg-successful"; succeed ? templateBgClass = "bg-successful" : templateBgClass = "bg-error"; @@ -34,6 +34,12 @@ export function messageBarTemplateGenerator(whichCalled:string, succeed:boolean) message = "Diagnostics refresh failed! Please restart the server!"; } + // diagnostics fn run + if(whichCalled == "diagnosticFNRunError" && !succeed){ + let currentError:string | undefined = undefined; + error ? message = error : message = `Run diagnostics failed, please check your python terminal.` + } + // initial template const messageBarTemplate = `