Skip to content

Commit 9394254

Browse files
authored
Merge pull request #58 from CopyDemon/issue-56-update-notification-component-behavior
Updates the style and behavior of the green notification box in the UI. Ignoring stochastic looking failure
2 parents 06b513b + 95b5f85 commit 9394254

10 files changed

+942
-60
lines changed

IDAES-UI/src/components/MessageBar/MessageBar.module.css

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
11
.message_bar_container{
22
position: fixed;
3-
width: 100vw;
4-
height:0px;
3+
width: 250px;
4+
height:25px;
5+
min-width: fit-content;
56
bottom: 0;
7+
right: 0;
68
z-index: 10000;
79
}
810

911
.messageBarTextContainer{
1012
position: absolute;
11-
left: 50%;
12-
top: 100%;
13-
transform: translateX(-50%);
13+
width: 100%;
14+
height: 100%;
1415
display: flex;
1516
flex-direction: row;
1617
justify-content: center;
1718
align-items: center;
18-
width: 300px;
19-
height: 100px;
20-
padding: 10px;
21-
border-radius: 6px;
22-
animation: messageBarShowUp .8s ease-in-out forwards;
19+
animation: messageBarShowUp .5s ease-in-out forwards;
20+
background-color: #333333;
21+
border-radius: 1px solid blue;
22+
border-top-left-radius: 5px;
2323
}
2424

25-
.messageBarTextContainer >p{
25+
.messageBarTextContainer > p{
26+
margin: 0;
27+
padding: 0;
28+
font-size: 12px;
2629
color: white;
27-
text-align: center;
30+
text-wrap: nowrap;
31+
border-top-left-radius: 20px;
32+
2833
}
2934

3035
@keyframes messageBarShowUp {
3136
1%{
32-
top: 100%;
37+
opacity: 0;
3338
}
3439

3540
100%{
36-
top:-120px;
41+
opacity: 1;
3742
}
3843
}
3944

4045
.bg_successful{
41-
background-color: rgb(0, 158, 32);
46+
background-color: #333333;
4247
}
4348

4449
.bg_error{
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
11
import css from "./MessageBar.module.css";
2+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3+
import { faCircleCheck } from "@fortawesome/free-solid-svg-icons";
4+
export function messageBarTemplateGenerator(whichCalled: string, succeed: boolean, error?: any) {
25

3-
export function messageBarTemplateGenerator(whichCalled:string, succeed:boolean, error?:any){
4-
5-
let templateBgClass:string = "bg-successful";
6+
let templateBgClass: string = "bg-successful";
67
succeed ? templateBgClass = "bg-successful" : templateBgClass = "bg-error";
78
// initial message and conditionally render message
8-
let message:string = "loading...";
9+
let message: string = "loading...";
910

1011
// refresh flowsheet
11-
if(whichCalled == "refreshFS" && succeed){
12+
if (whichCalled == "refreshFS" && succeed) {
1213
message = "Flowsheet refreshed.";
1314
}
1415

15-
if(whichCalled == "refreshFS" && !succeed){
16+
if (whichCalled == "refreshFS" && !succeed) {
1617
message = "Flowsheet refresh failed! Please reload the page!";
1718
}
1819

1920
// userSave flowsheet
20-
if(whichCalled == "userSave" && succeed){
21+
if (whichCalled == "userSave" && succeed) {
2122
message = "Flowsheet saved.";
2223
}
2324

24-
if(whichCalled == "userSave" && !succeed){
25+
if (whichCalled == "userSave" && !succeed) {
2526
message = "Flowsheet save failed! Please restart the server!";
2627
}
2728

2829
// diagnostics refresh
29-
if(whichCalled == "diagnosticRefresh" && succeed){
30+
if (whichCalled == "diagnosticRefresh" && succeed) {
3031
message = "Diagnostics refreshed.";
3132
}
3233

33-
if(whichCalled == "diagnosticRefresh" && !succeed){
34+
if (whichCalled == "diagnosticRefresh" && !succeed) {
3435
message = "Diagnostics refresh failed! Please restart the server!";
3536
}
3637

3738
// diagnostics fn run
38-
if(whichCalled == "diagnosticFNRunError" && !succeed){
39-
let currentError:string | undefined = undefined;
40-
error ? message = error : message = `Run diagnostics failed, please check your python terminal.`
39+
if (whichCalled == "diagnosticFNRunError" && !succeed) {
40+
let currentError: string | undefined = undefined;
41+
// error ? message = error : message = `
42+
message = `Diagnostics failed, check your terminal.`;
4143
}
4244

4345
// initial template
4446
const messageBarTemplate = `
4547
<div id='messageBarTextContainer'
46-
class="${css.messageBarTextContainer} ${succeed ? css.bg_successful : css.bg_error}"
48+
class="${css.messageBarTextContainer} ${!succeed ? css.bg_error : css.bg_successful}"
4749
>
50+
<i class="fa-solid fa-circle-check"></i>
4851
<p>${message}</p>
4952
</div>
5053
`;
@@ -54,14 +57,13 @@ export function messageBarTemplateGenerator(whichCalled:string, succeed:boolean,
5457
messageBarContainer.innerHTML = messageBarTemplate;
5558

5659
// timeout 1.5 sec remove template
57-
const timeOut = setTimeout(()=>{
60+
const timeOut = setTimeout(() => {
5861
const readMessageBarTemplate = document.getElementById('messageBarTextContainer');
59-
console.log(readMessageBarTemplate)
60-
if(readMessageBarTemplate){
62+
if (readMessageBarTemplate) {
6163
messageBarContainer.removeChild(readMessageBarTemplate)
62-
}else{
64+
} else {
6365
console.log(`Child node message bar is not found!`)
6466
}
6567
clearTimeout(timeOut)
66-
},3000)
68+
}, 3000)
6769
}

IDAES-UI/src/diagnostics/Diagnostics.tsx

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext, useEffect, useState} from "react";
1+
import { useContext, useEffect, useState } from "react";
22
import { AppContext } from "@/AppContext";
33
import axios from "axios";
44
import { messageBarTemplateGenerator } from "@/components/MessageBar/MessageBarTemplateGenerator";
@@ -9,60 +9,60 @@ import DiagnosticsDisplay from "./DiagnosticsDisplay";
99
import "./Diagnostics.css";
1010

1111
interface DiagnosticsDataInterface {
12-
config: {key:any, value:any},
13-
issues:{issues:any}
14-
statistics:any
12+
config: { key: any, value: any },
13+
issues: { issues: any }
14+
statistics: any
1515
}
1616

17-
export default function Diagnostics(){
18-
let {server_port, diagnosticsRefreshState} = useContext(AppContext);
17+
export default function Diagnostics() {
18+
let { server_port, diagnosticsRefreshState } = useContext(AppContext);
1919
// this use to hold all diagnostic data fetched from api end point pass down to sub components
2020
const [diagnosticData, setDiagnosticsData] = useState<DiagnosticsDataInterface | null>(null);
2121
// use to hold which issue currently is displayed on screen setWhichIssue to update diagnostics display
22-
const [whichIssue, setWhichIssue] = useState<string | null>("structural");
22+
const [whichIssue, setWhichIssue] = useState<string | null>("structural");
2323

24-
const toggleIssueHandler = (issue:any) =>{
24+
const toggleIssueHandler = (issue: any) => {
2525
// this function use in issues component's each issue tab
2626
// use for when each issue tab click and toggle current displayed issue
2727
setWhichIssue(issue)
2828
}
2929

30-
useEffect(()=>{
30+
useEffect(() => {
3131
// const getDiagnosticUrl = `http://127.0.0.1:${server_port}/api/get_diagnostics`;
3232
const windowURL = new URL(window.location.href);
3333
const id = windowURL.searchParams.get("id");
3434
const getDiagnosticUrl = `http://localhost:${server_port}/diagnostics?id=${id}`;
3535

36-
const fetchDiagnosticData = async (url:string) =>{
36+
const fetchDiagnosticData = async (url: string) => {
3737
// fetch diagnostic data from end point and update to state
38-
try{
38+
try {
3939
const res = await axios.get(url);
4040
const data = res.data
4141
messageBarTemplateGenerator("diagnosticRefresh", true);
4242
setDiagnosticsData(data);
43-
}catch(error){
43+
} catch (error) {
4444
console.error("Fetch diagnostic data error", error)
4545
messageBarTemplateGenerator("diagnosticRefresh", false);
4646
}
4747
}
4848
fetchDiagnosticData(getDiagnosticUrl);
4949
},
50-
/**
51-
* useEffect triggers:
52-
* 1. onload
53-
* 2. on diagnosticsRefreshState changed (click handler in mosaic to toggle this bool state)
54-
*/
55-
[diagnosticsRefreshState]);
50+
/**
51+
* useEffect triggers:
52+
* 1. onload
53+
* 2. on diagnosticsRefreshState changed (click handler in mosaic to toggle this bool state)
54+
*/
55+
[diagnosticsRefreshState]);
5656

5757
return (
5858
<>
59-
<DiagnosticHeader
60-
diagnosticData={diagnosticData}
61-
toggleIssue={toggleIssueHandler}
59+
<DiagnosticHeader
60+
diagnosticData={diagnosticData}
61+
toggleIssue={toggleIssueHandler}
6262
whichIssue={whichIssue}
6363
/>
64-
<DiagnosticsDisplay
65-
diagnosticData={diagnosticData}
64+
<DiagnosticsDisplay
65+
diagnosticData={diagnosticData}
6666
whichIssue={whichIssue}
6767
/>
6868
</>

idaes_ui/fv/static/assets/allPaths-4a93b574.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idaes_ui/fv/static/assets/allPathsLoader-8041c61d.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idaes_ui/fv/static/assets/index-64ee1e34.css

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)