@@ -19,7 +19,6 @@ import {
19
19
Typography ,
20
20
} from '@material-ui/core' ;
21
21
22
-
23
22
import { makeStyles } from '@material-ui/core/styles' ;
24
23
import { BaseCSSProperties } from '@material-ui/core/styles/withStyles' ;
25
24
@@ -32,7 +31,6 @@ import Badge from '@material-ui/core/Badge';
32
31
import PersonIcon from '@material-ui/icons/Person' ;
33
32
import UpdateIcon from '@material-ui/icons/Update' ;
34
33
35
-
36
34
// // MODALS
37
35
import AddModal from '../modals/AddModal' ;
38
36
import ProfileContainer from '../containers/ProfileContainer' ;
@@ -49,40 +47,40 @@ import { CommsContext } from '../context/CommsContext';
49
47
50
48
// TYPESCRIPT
51
49
interface StyleProps {
52
- root : BaseCSSProperties ;
53
- }
54
- type ClickEvent = React . MouseEvent < HTMLElement > ;
55
-
50
+ root : BaseCSSProperties ;
51
+ }
52
+ type ClickEvent = React . MouseEvent < HTMLElement > ;
56
53
57
54
const Occupied = React . memo ( ( ) => {
58
- const { setServicesData } = useContext ( ApplicationContext ) ;
55
+ const { setServicesData, app , setApp } = useContext ( ApplicationContext ) ;
59
56
const { user, applications, getApplications, deleteApp, mode } = useContext ( DashboardContext ) ;
60
57
const { commsData } = useContext ( CommsContext ) ;
61
58
const [ serviceModalOpen , setServiceModalOpen ] = useState < boolean > ( false ) ;
62
59
const [ addModalOpen , setAddModalOpen ] = useState < boolean > ( false ) ;
63
60
const [ personModalOpen , setPersonModalOpen ] = useState < boolean > ( false ) ;
64
61
const [ index , setIndex ] = useState < number > ( 0 ) ;
65
- const [ app , setApp ] = useState < string > ( '' ) ;
62
+ // const [app, setApp] = useState<string>('');
66
63
const [ searchTerm , setSearchTerm ] = useState < string > ( '' ) ;
67
64
const [ clickedAt , setClickedAt ] = useState < string > ( '2000-01-01T00:00:00Z' ) ;
68
-
65
+
69
66
// Grab services and applications whenever the user changes
70
67
useEffect ( ( ) => {
71
68
setServicesData ( [ ] ) ;
72
69
getApplications ( ) ;
73
- } , [ user ] ) ;
70
+ } , [ user ] ) ;
74
71
75
72
// Dynamic refs
76
73
const delRef = useRef < any > ( [ ] ) ;
77
-
74
+
78
75
// Asks user to confirm deletion
79
76
const confirmDelete = ( event : ClickEvent , application : string , i : number ) => {
80
77
const message = `The application '${ app } ' will be permanently deleted. Continue?` ;
81
78
if ( confirm ( message ) ) deleteApp ( i ) ;
82
79
} ;
83
-
80
+
84
81
// Handle clicks on Application cards
85
82
const handleClick = ( event : ClickEvent , selectedApp : string , i : number ) => {
83
+ console . log ( selectedApp , i ) ;
86
84
if ( delRef . current [ i ] && ! delRef . current [ i ] . contains ( event . target ) ) {
87
85
setIndex ( i ) ;
88
86
setApp ( selectedApp ) ;
@@ -249,7 +247,11 @@ const Occupied = React.memo(() => {
249
247
You have { notification ? notification . length : 0 } new alerts
250
248
</ span >
251
249
< NotificationsIcon className = "navIcon" id = "notificationsIcon" />
252
- < Badge overlap = "rectangular" badgeContent = { notification ? notification . length : 0 } color = "secondary" />
250
+ < Badge
251
+ overlap = "rectangular"
252
+ badgeContent = { notification ? notification . length : 0 }
253
+ color = "secondary"
254
+ />
253
255
</ div >
254
256
< div className = "personIconArea" >
255
257
< Button className = "personTooltip" onClick = { ( ) => setPersonModalOpen ( true ) } >
@@ -267,61 +269,66 @@ const Occupied = React.memo(() => {
267
269
</ Button >
268
270
</ div >
269
271
{ applications &&
270
- applications . filter ( ( db : any ) => db [ 0 ] . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
271
- . map ( ( application : string [ ] , i : number | any | string | undefined ) => (
272
- < div className = "card" key = { `card-${ i } ` } id = { `card-${ application [ 1 ] } ` } >
273
- < Card
274
- key = { `card-${ i } ` }
275
- className = { classes . paper }
276
- variant = "outlined"
277
- onClick = { event => handleClick ( event , application [ 0 ] , i ) }
278
- >
279
- < div className = "databaseIconContainer" >
280
- < div className = "databaseIconHeader" >
281
- { application [ 1 ] === 'SQL' ? (
282
- < img className = "databaseIcon" alt = "SQL" />
283
- ) : (
284
- < img className = "databaseIcon" alt = "MongoDB" />
285
- ) }
272
+ applications
273
+ . filter ( ( db : any ) => db [ 0 ] . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
274
+ . map ( ( application : string [ ] , i : number | any | string | undefined ) => (
275
+ < div className = "card" key = { `card-${ i } ` } id = { `card-${ application [ 1 ] } ` } >
276
+ < Card
277
+ key = { `card-${ i } ` }
278
+ className = { classes . paper }
279
+ variant = "outlined"
280
+ onClick = { event => handleClick ( event , application [ 0 ] , i ) }
281
+ >
282
+ < div className = "databaseIconContainer" >
283
+ < div className = "databaseIconHeader" >
284
+ { application [ 1 ] === 'SQL' ? (
285
+ < img className = "databaseIcon" alt = "SQL" />
286
+ ) : (
287
+ < img className = "databaseIcon" alt = "MongoDB" />
288
+ ) }
289
+ </ div >
286
290
</ div >
287
- </ div >
288
291
289
- < CardHeader
290
- avatar = {
291
- < IconButton
292
- id = "iconButton"
293
- ref = { element => {
294
- delRef . current [ i ] = element ;
295
- } }
296
- className = { classes . iconbutton }
297
- aria-label = "Delete"
298
- onClick = { event => confirmDelete ( event , application [ 0 ] , i ) }
299
- >
300
- < HighlightOffIcon
301
- className = { classes . btnStyle }
302
- id = "deleteIcon"
292
+ < CardHeader
293
+ avatar = {
294
+ < IconButton
295
+ id = "iconButton"
303
296
ref = { element => {
304
297
delRef . current [ i ] = element ;
305
298
} }
306
- />
307
- </ IconButton >
308
- }
309
- />
310
- < CardContent >
311
- < p id = "databaseName" > Database Name:</ p >
312
- < Typography className = { classes . fontStyles } > { application [ 0 ] } </ Typography >
313
- </ CardContent >
314
- < hr className = "cardLine" />
299
+ className = { classes . iconbutton }
300
+ aria-label = "Delete"
301
+ onClick = { event => confirmDelete ( event , application [ 0 ] , i ) }
302
+ >
303
+ < HighlightOffIcon
304
+ className = { classes . btnStyle }
305
+ id = "deleteIcon"
306
+ ref = { element => {
307
+ delRef . current [ i ] = element ;
308
+ } }
309
+ />
310
+ </ IconButton >
311
+ }
312
+ />
313
+ < CardContent >
314
+ { /* <p id="databaseName">Name:</p> */ }
315
+ < Typography noWrap id = "databaseName" className = { classes . fontStyles } >
316
+ { application [ 0 ] }
317
+ </ Typography >
318
+ < p id = "serviceName" > Service:</ p >
319
+ < Typography className = { classes . fontStyles } > { application [ 3 ] } </ Typography >
320
+ </ CardContent >
321
+ < hr className = "cardLine" />
315
322
316
- < div className = "cardFooter" >
317
- < UpdateIcon className = "cardFooterIcon" />
318
- < em >
319
- < p id = "cardFooterText" > { application [ 3 ] } </ p >
320
- </ em >
321
- </ div >
322
- </ Card >
323
- </ div >
324
- ) ) }
323
+ < div className = "cardFooter" >
324
+ < UpdateIcon className = "cardFooterIcon" />
325
+ < em >
326
+ < p id = "cardFooterText" > { application [ 4 ] } </ p >
327
+ </ em >
328
+ </ div >
329
+ </ Card >
330
+ </ div >
331
+ ) ) }
325
332
326
333
< Modal open = { addModalOpen } onClose = { ( ) => setAddModalOpen ( false ) } >
327
334
< AddModal setOpen = { setAddModalOpen } />
0 commit comments