File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ import Admin from './pages/Admin';
8
8
import DataView from './pages/DataView360/DataView360' ;
9
9
import About from './pages/About' ;
10
10
import Login from './components/Login/Login' ;
11
+ import CDialog from './components/CDialog' ;
11
12
import Check from './pages/Check/Check' ;
13
+
14
+
12
15
import useToken from './components/Login/useToken' ;
13
16
var jwt = require ( 'jsonwebtoken' ) ;
14
17
@@ -76,6 +79,8 @@ function AuthenticatedApp() {
76
79
77
80
const jwtExpired = expTime <= 0
78
81
82
+ const popRefreshAlert = expTime < 30 ;
83
+
79
84
const hdr = userRole === 'admin' ? < AdminHeader /> : < Header /> // If we're going to display a header, which one?
80
85
81
86
return (
@@ -84,6 +89,9 @@ function AuthenticatedApp() {
84
89
85
90
{ ! jwtExpired && hdr ? hdr : '' /* Above-chosen header, or if logged out, no header */ }
86
91
92
+ { popRefreshAlert && < CDialog /> }
93
+
94
+
87
95
{ /* If not logged in, show login screen */
88
96
( ! access_token | jwtExpired ) ? < Login setToken = { setToken } /> : < Switch >
89
97
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import Button from '@material-ui/core/Button' ;
3
+ import Dialog from '@material-ui/core/Dialog' ;
4
+ import DialogActions from '@material-ui/core/DialogActions' ;
5
+ import DialogContent from '@material-ui/core/DialogContent' ;
6
+ import DialogContentText from '@material-ui/core/DialogContentText' ;
7
+ import DialogTitle from '@material-ui/core/DialogTitle' ;
8
+
9
+ export default function CDialog ( ) {
10
+ const [ open , setOpen ] = React . useState ( true ) ;
11
+
12
+ const handleClickOpen = ( ) => {
13
+ setOpen ( true ) ;
14
+ } ;
15
+
16
+ const handleClose = ( shouldRefresh ) => {
17
+ setOpen ( false ) ;
18
+ console . log ( "Refresh? " + String ( shouldRefresh ) ) ;
19
+ } ;
20
+
21
+
22
+
23
+ return (
24
+ < div >
25
+ { /* <Button variant="outlined" color="primary" onClick={handleClickOpen}>
26
+ Open alert dialog
27
+ </Button> */ }
28
+ < Dialog
29
+ open = { open }
30
+ onClose = { handleClose }
31
+ aria-labelledby = "alert-dialog-title"
32
+ aria-describedby = "alert-dialog-description"
33
+ >
34
+ < DialogTitle id = "alert-dialog-title" > { "You are about to be logged out!" } </ DialogTitle >
35
+ < DialogContent >
36
+ < DialogContentText id = "alert-dialog-description" >
37
+ Stay logged in to keep working?
38
+ </ DialogContentText >
39
+ </ DialogContent >
40
+ < DialogActions >
41
+ < Button onClick = { ( ) => handleClose ( false ) } color = "primary" >
42
+ No
43
+ </ Button >
44
+ < Button onClick = { ( ) => handleClose ( true ) } color = "primary" autoFocus >
45
+ Yes
46
+ </ Button >
47
+ </ DialogActions >
48
+ </ Dialog >
49
+ </ div >
50
+ ) ;
51
+ }
You can’t perform that action at this time.
0 commit comments