Skip to content

Commit

Permalink
fix issue add scroll bar at bottom of the diagnostic log container
Browse files Browse the repository at this point in the history
  • Loading branch information
CopyDemon committed May 20, 2024
1 parent 7547a6a commit 0a031d5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
4 changes: 2 additions & 2 deletions IDAES-UI/src/diagnosticLogs/DiagnosticsLog.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.diagnosticsRunner_content_container{
.diagnostics_log_container{
position:relative;
min-height: 500px;
max-height: 1080px;
padding: 20px;
overflow-y: scroll !important;
overflow: scroll !important;
scroll-behavior: smooth;
}
21 changes: 18 additions & 3 deletions IDAES-UI/src/diagnosticLogs/DiagnosticsLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,27 @@ export default function DiagnosticsLog(){

useEffect(()=>{
setDiagnosticsHistory((prev:number)=>displayLength)
},[displayLength])
},[displayLength]);

useEffect(()=>{
// Setup diagnostics log panel height is 100% as parent element height
const diagnosticsLogPanelLogContainer = document.getElementById('diagnostics_log_container');
if(diagnosticsLogPanelLogContainer){
const parentElement = diagnosticsLogPanelLogContainer.parentElement;
if(parentElement){
parentElement.style.position = "relative";
parentElement.style.height = "100%";
diagnosticsLogPanelLogContainer.style.height = "100%";
diagnosticsLogPanelLogContainer.style.minHeight = "100%";
diagnosticsLogPanelLogContainer.style.maxHeight = "100%";
}
}
},[])

return(
<div
className={css.diagnosticsRunner_content_container}
id="diagnosticsRunner_content_container"
className={css.diagnostics_log_container}
id="diagnostics_log_container"
style={{"overflowY" : "scroll"}}
>
{display}
Expand Down
6 changes: 3 additions & 3 deletions IDAES-UI/src/diagnostics/DiagnosticsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ export default function DiagnosticsDisplay(props:any){
}catch(error:any){
messageBarTemplateGenerator("diagnosticFNRunError", false, error.response.data.error)
console.log(error)
const diagnosticsRunnerContentContainer = document.getElementById("diagnosticsRunner_content_container");
if(diagnosticsRunnerContentContainer){
const diagnosticsLogContainer = document.getElementById("diagnostics_log_container");
if(diagnosticsLogContainer){
const errorTemplate = `
<pre class="${css.error_message}">${error.response.data.error}<pre>
<br>
`
diagnosticsRunnerContentContainer.innerHTML+= errorTemplate
diagnosticsLogContainer.innerHTML+= errorTemplate
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions IDAES-UI/src/utility/resizePanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @Description This function take current element's id as param then read parent element height and assign to current element
* @param DOMid DOM element ID
* @return VOID
*/
export function resizePanelHeightAsParent(DOMid:string){
const element = document.getElementById(DOMid);
if(element){
const parentNodeHeight = element.parentElement?.clientHeight;
if(parentNodeHeight){
element.style.height = parentNodeHeight + 'px';
console.log(parentNodeHeight)
}else{
console.log(`Try to resize element as parent height, but parent node high not found!`)
}
}else{
console.log(`Try to resize element as parent height, but parent node element not found!`)
}
}

0 comments on commit 0a031d5

Please sign in to comment.