@@ -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' ;
@@ -50,10 +48,9 @@ import { AwsContext } from '../context/AwsContext';
50
48
51
49
// TYPESCRIPT
52
50
interface StyleProps {
53
- root : BaseCSSProperties ;
54
- }
55
- type ClickEvent = React . MouseEvent < HTMLElement > ;
56
-
51
+ root : BaseCSSProperties ;
52
+ }
53
+ type ClickEvent = React . MouseEvent < HTMLElement > ;
57
54
58
55
const Occupied = React . memo ( ( ) => {
59
56
const { awsData, fetchAwsData } = useContext ( AwsContext ) ;
@@ -67,24 +64,25 @@ const Occupied = React.memo(() => {
67
64
// const [app, setApp] = useState<string>('');
68
65
const [ searchTerm , setSearchTerm ] = useState < string > ( '' ) ;
69
66
const [ clickedAt , setClickedAt ] = useState < string > ( '2000-01-01T00:00:00Z' ) ;
70
-
67
+
71
68
// Grab services and applications whenever the user changes
72
69
useEffect ( ( ) => {
73
70
setServicesData ( [ ] ) ;
74
71
getApplications ( ) ;
75
- } , [ user ] ) ;
72
+ } , [ user ] ) ;
76
73
77
74
// Dynamic refs
78
75
const delRef = useRef < any > ( [ ] ) ;
79
-
76
+
80
77
// Asks user to confirm deletion
81
78
const confirmDelete = ( event : ClickEvent , application : string , i : number ) => {
82
79
const message = `The application '${ app } ' will be permanently deleted. Continue?` ;
83
80
if ( confirm ( message ) ) deleteApp ( i ) ;
84
81
} ;
85
-
82
+
86
83
// Handle clicks on Application cards
87
84
const handleClick = ( event : ClickEvent , selectedApp : string , i : number ) => {
85
+ console . log ( selectedApp , i ) ;
88
86
if ( delRef . current [ i ] && ! delRef . current [ i ] . contains ( event . target ) ) {
89
87
console . log ( 'the application that you clicked is: ' , selectedApp )
90
88
setIndex ( i ) ;
@@ -253,7 +251,11 @@ const Occupied = React.memo(() => {
253
251
You have { notification ? notification . length : 0 } new alerts
254
252
</ span >
255
253
< NotificationsIcon className = "navIcon" id = "notificationsIcon" />
256
- < Badge overlap = "rectangular" badgeContent = { notification ? notification . length : 0 } color = "secondary" />
254
+ < Badge
255
+ overlap = "rectangular"
256
+ badgeContent = { notification ? notification . length : 0 }
257
+ color = "secondary"
258
+ />
257
259
</ div >
258
260
< div className = "personIconArea" >
259
261
< Button className = "personTooltip" onClick = { ( ) => setPersonModalOpen ( true ) } >
@@ -271,66 +273,66 @@ const Occupied = React.memo(() => {
271
273
</ Button >
272
274
</ div >
273
275
{ applications &&
274
- applications . filter ( ( db : any ) => db [ 0 ] . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
275
- . map ( ( application : string [ ] , i : number | any | string | undefined ) => (
276
- < div className = "card" key = { `card-${ i } ` } id = { `card-${ application [ 1 ] } ` } >
277
- < Card
278
- key = { `card-${ i } ` }
279
- className = { classes . paper }
280
- variant = "outlined"
281
- onClick = { event => {
282
- console . log ( 'what are all the applications mapped: ' , applications )
283
- handleClick ( event , application [ 0 ] , i )
284
- } }
285
- >
286
- < div className = "databaseIconContainer" >
287
- < div className = "databaseIconHeader" >
288
- { application [ 1 ] === 'SQL' ? (
289
- < img className = "databaseIcon" alt = "SQL" />
290
- ) : (
291
- < img className = "databaseIcon" alt = "MongoDB" />
292
- ) }
276
+ applications
277
+ . filter ( ( db : any ) => db [ 0 ] . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
278
+ . map ( ( application : string [ ] , i : number | any | string | undefined ) => (
279
+ < div className = "card" key = { `card-${ i } ` } id = { `card-${ application [ 1 ] } ` } >
280
+ < Card
281
+ key = { `card-${ i } ` }
282
+ className = { classes . paper }
283
+ variant = "outlined"
284
+ onClick = { event => handleClick ( event , application [ 0 ] , i ) }
285
+ >
286
+ < div className = "databaseIconContainer" >
287
+ < div className = "databaseIconHeader" >
288
+ { application [ 1 ] === 'SQL' ? (
289
+ < img className = "databaseIcon" alt = "SQL" />
290
+ ) : (
291
+ < img className = "databaseIcon" alt = "MongoDB" />
292
+ ) }
293
+ </ div >
293
294
</ div >
294
- </ div >
295
295
296
- < CardHeader
297
- avatar = {
298
- < IconButton
299
- id = "iconButton"
300
- ref = { element => {
301
- delRef . current [ i ] = element ;
302
- } }
303
- className = { classes . iconbutton }
304
- aria-label = "Delete"
305
- onClick = { event => confirmDelete ( event , application [ 0 ] , i ) }
306
- >
307
- < HighlightOffIcon
308
- className = { classes . btnStyle }
309
- id = "deleteIcon"
296
+ < CardHeader
297
+ avatar = {
298
+ < IconButton
299
+ id = "iconButton"
310
300
ref = { element => {
311
301
delRef . current [ i ] = element ;
312
302
} }
313
- />
314
- </ IconButton >
315
- }
316
- />
317
- < CardContent >
318
- < p id = "databaseName" > Name:</ p >
319
- < Typography className = { classes . fontStyles } > { application [ 0 ] } </ Typography >
320
- < p id = "databaseName" > Service:</ p >
321
- < Typography className = { classes . fontStyles } > { application [ 3 ] } </ Typography >
322
- </ CardContent >
323
- < hr className = "cardLine" />
303
+ className = { classes . iconbutton }
304
+ aria-label = "Delete"
305
+ onClick = { event => confirmDelete ( event , application [ 0 ] , i ) }
306
+ >
307
+ < HighlightOffIcon
308
+ className = { classes . btnStyle }
309
+ id = "deleteIcon"
310
+ ref = { element => {
311
+ delRef . current [ i ] = element ;
312
+ } }
313
+ />
314
+ </ IconButton >
315
+ }
316
+ />
317
+ < CardContent >
318
+ { /* <p id="databaseName">Name:</p> */ }
319
+ < Typography noWrap id = "databaseName" className = { classes . fontStyles } >
320
+ { application [ 0 ] }
321
+ </ Typography >
322
+ < p id = "serviceName" > Service:</ p >
323
+ < Typography className = { classes . fontStyles } > { application [ 3 ] } </ Typography >
324
+ </ CardContent >
325
+ < hr className = "cardLine" />
324
326
325
- < div className = "cardFooter" >
326
- < UpdateIcon className = "cardFooterIcon" />
327
- < em >
328
- < p id = "cardFooterText" > { application [ 4 ] } </ p >
329
- </ em >
330
- </ div >
331
- </ Card >
332
- </ div >
333
- ) ) }
327
+ < div className = "cardFooter" >
328
+ < UpdateIcon className = "cardFooterIcon" />
329
+ < em >
330
+ < p id = "cardFooterText" > { application [ 4 ] } </ p >
331
+ </ em >
332
+ </ div >
333
+ </ Card >
334
+ </ div >
335
+ ) ) }
334
336
335
337
< Modal open = { addModalOpen } onClose = { ( ) => setAddModalOpen ( false ) } >
336
338
< AddModal setOpen = { setAddModalOpen } />
0 commit comments