-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0c6cf9
commit e7caee8
Showing
15 changed files
with
363 additions
and
110 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const Countdown = withStyles(countdownStyle)(props => { | ||
const { classes, label, millisecondsRemaining, postUpdate } = props; | ||
const [ timeRemaining, setTimeRemaining ] = useState(false); | ||
|
||
useEffect(() => { | ||
if (millisecondsRemaining) { | ||
const timeReference = Date.now()+millisecondsRemaining; | ||
setTimeRemaining(timeReference-Date.now()); | ||
var requestSent = false; | ||
const interval = setInterval(()=>{ | ||
const remaining = timeReference-Date.now(); | ||
if (remaining >= 0) { | ||
setTimeRemaining(remaining); | ||
} | ||
if ((remaining <= 100) && !requestSent) { | ||
requestSent=true; | ||
postUpdate(); | ||
} | ||
},50); | ||
return ()=>clearInterval(interval); | ||
} | ||
},[millisecondsRemaining]); | ||
|
||
return ( | ||
<Box className={classes.root}> | ||
<Typography variant="little" color="textSecondary">{label}</Typography>: | ||
<Typography className={classes.timeremaining} width="100px" variant="little" color="textAttribute">{timeRemaining}</Typography> | ||
</Box>) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const countdownStyle = theme => ({ | ||
root: { | ||
display: "flex", | ||
flexDirection: "row", | ||
columnGap: "3px", | ||
alignItems: "center", | ||
}, | ||
timeremaining: { | ||
width: "50px" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 17 additions & 9 deletions
26
...nents/home/designer/effect.jsx/effect.jsx → ...omponents/home/designer/effect/effect.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const NotificationPanel = withStyles(notificationsStyle)(props => { | ||
const { classes, notifications } = props; | ||
const [numErrors, setNumErrors] = React.useState(undefined); | ||
const [errorTargets, setErrorTargets] = React.useState({}); | ||
const [open, setOpen] = React.useState(false); | ||
const inputRef = React.createRef(); | ||
|
||
useEffect(()=>{ | ||
setNumErrors(notifications.reduce((ret,notif) => ret+notif.notifications.length, 0)); | ||
setErrorTargets(notifications.reduce((ret,notif) => | ||
{return {...ret,[notif.target]:ret[notif.target] || false}}, {})); | ||
},[notifications]); | ||
|
||
return ( | ||
<Box className={classes.root}> | ||
<IconButton | ||
id="notifications" | ||
ref={inputRef} | ||
onClick={() => setOpen(wasOpen=>!wasOpen)}> | ||
<Badge | ||
aria-label="Alerts" | ||
badgeContent={numErrors} | ||
color="secondary"> | ||
<Icon>notifications</Icon> | ||
</Badge> | ||
</IconButton> | ||
<Popover | ||
open={open} | ||
target="notifications" | ||
onClose={()=>{setOpen(false)}} | ||
anchorOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'right', | ||
}}> | ||
<Card className={classes.popup} elevation={9}> | ||
<CardHeader | ||
avatar={ | ||
<Avatar aria-label="error"> | ||
! | ||
</Avatar> | ||
} | ||
action={ | ||
<IconButton onClick={()=>setOpen(false)} aria-label="settings"> | ||
<Icon>close</Icon> | ||
</IconButton> | ||
} | ||
title={`${numErrors} Errors`} | ||
/> | ||
<CardContent> | ||
{Object.entries(errorTargets).map(target => | ||
<CardContent key={target[0]} className={classes.errors}> | ||
{Object.entries(notifications) | ||
.filter(notif => notif[1].target === target[0]) | ||
.map(error => | ||
<Box key={error[0]}> | ||
<Box className={classes.errorHeader} key="header"> | ||
<Typography>{target[0]}</Typography> | ||
<Typography color="textSecondary">{error[1].type}</Typography> | ||
<Typography>{error[1].level}</Typography> | ||
</Box> | ||
<Box className={classes.errors} key="errors"> | ||
{Object.entries(error[1].notifications.reduce((ret,error) => {return {...ret,[error.notification]:(ret[error.notification]||0)+1}},{})) | ||
.map(entry => <Typography key={entry[1]} variant="tiny">{`${entry[1]}X ${entry[0]}`}</Typography>) | ||
} | ||
</Box> | ||
</Box> | ||
)} | ||
</CardContent> | ||
)} | ||
</CardContent> | ||
</Card> | ||
</Popover> | ||
</Box>); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const notificationsStyle = theme => ({ | ||
root: { | ||
}, | ||
popup: { | ||
}, | ||
errorTarget: { | ||
}, | ||
errors: { | ||
display: "flex", | ||
flexDirection: "column" | ||
}, | ||
errorHeader: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
borderBottom: "solid aquamarine 2px", | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ReactDOM.createRoot(document.getElementById("root")) | ||
.render(<MainApp/>); | ||
.render(<StrictMode><MainApp/></StrictMode>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const { useState, useEffect, useMemo, useRef } = window.React; | ||
const { useState, useEffect, useMemo, useRef, StrictMode } = window.React; | ||
|
||
const { createTheme, ThemeProvider, Checkbox, AppBar, Toolbar, IconButton, Icon, MenuIcon, Typography } = window.MaterialUI; | ||
const { Badge, withStyles, CssBaseline, Drawer, Divider, List, ListItem, ListItemIcon, ListItemText } = window.MaterialUI; | ||
const { Box, Dialog, Slide, Button, TextField, FormControlLabel, useTheme, LinearProgress } = window.MaterialUI; | ||
const { Box, Dialog, Slide, Button, TextField, FormControlLabel, useTheme, LinearProgress, Popover } = window.MaterialUI; | ||
const { Card, CardHeader, CardContent, Collapse, CardActions, CardActionArea, Avatar } = window.MaterialUI; | ||
|
||
const { AreaChart, BarChart, Area, Bar, ResponsiveContainer, LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip, Legend } = window.Recharts; | ||
|