@@ -232,7 +232,7 @@ def total_number_of_alarms(sitesDf):
232
232
),
233
233
md = 3 , xs = 3 , xl = 3 , className = 'status-count-numbers'
234
234
) for s , icon in status .items ()]
235
- ], className = 'w-100 status-box p-1 gx-4' , align = "center" , justify = 'center' ),
235
+ ], className = 'w-100 status-box gx-4' , align = "center" , justify = 'center' ),
236
236
], className = 'boxwithshadow g-0 mb-1' )]
237
237
238
238
@@ -379,15 +379,15 @@ def layout(**other_unknown_query_strings):
379
379
dbc .Col (dcc .Graph (figure = builMap (sitesDf ), id = 'site-map' ,
380
380
className = 'cls-site-map' ),
381
381
className = 'boxwithshadow page-cont mb-1 g-0 p-2 column-margin' ,
382
- xl = 12 , style = {"background-color" : "#b9c4d4;" , "padding-top" : "3%" }, align = "center"
382
+ xl = 12 , lg = 12 , style = {"background-color" : "#b9c4d4;" , "padding-top" : "3%" }
383
383
),
384
384
dbc .Col (
385
385
dcc .Loading (
386
386
html .Div (id = "alarms-stacked-bar" ),
387
387
style = {'height' : '1rem' }, color = '#00245A'
388
388
),
389
- className = "boxwithshadow page-cont mb-1 p-2" ,),
390
- ], lg = 6 , md = 12 , className = 'd-flex flex-column' ), # d-flex and flex-column make the columns the same size
389
+ className = "boxwithshadow page-cont mb-1 p-2 align-content-around " ,),
390
+ ], lg = 6 , md = 12 , className = 'd-flex flex-column' , align = 'around' ), # d-flex and flex-column make the columns the same size
391
391
# end of top left column
392
392
393
393
# top right column with status table, status statistics and the search fields
@@ -396,7 +396,7 @@ def layout(**other_unknown_query_strings):
396
396
dbc .Row ([
397
397
dbc .Col (
398
398
[
399
- html .Div (children = statusTable , id = 'site-status' , className = 'p-2 ' ),
399
+ html .Div (children = statusTable , id = 'site-status' , className = 'status-table-cls ' ),
400
400
html .Div (
401
401
[
402
402
dbc .Button (
@@ -406,9 +406,16 @@ def layout(**other_unknown_query_strings):
406
406
color = "secondary" ,
407
407
n_clicks = 0 ,
408
408
),
409
- dbc .Collapse (
410
- id = "how-status-collapse" ,
411
- className = "how-status-collapse" ,
409
+ dbc .Modal (
410
+ [
411
+ dbc .ModalHeader (dbc .ModalTitle ("How was the status determined?" )),
412
+ dbc .ModalBody (id = "how-status-modal-body" ),
413
+ dbc .ModalFooter (
414
+ dbc .Button ("Close" , id = "close-how-status-modal" , className = "ml-auto" , n_clicks = 0 )
415
+ ),
416
+ ],
417
+ id = "how-status-modal" ,
418
+ size = "lg" ,
412
419
is_open = False ,
413
420
),
414
421
], className = "how-status-div" ,
@@ -427,18 +434,18 @@ def layout(**other_unknown_query_strings):
427
434
"Search the Networking Alarms"
428
435
], className = "l-h-3" ),
429
436
], align = "center" , className = "text-left rounded-border-1 pl-1"
430
- , md = 6 , xl = 6 ),
437
+ , md = 12 , xl = 6 ),
431
438
dbc .Col ([
432
439
dcc .DatePickerRange (
433
440
id = 'date-picker-range' ,
434
441
month_format = 'M-D-Y' ,
435
- min_date_allowed = date ( 2022 , 8 , 1 ),
442
+ min_date_allowed = date . today () - pd . Timedelta ( days = 30 ),
436
443
initial_visible_month = now [0 ],
437
444
start_date = now [0 ],
438
445
end_date = now [1 ]
439
446
)
440
- ], style = { "display" : "flex" , "justify-content" : "flex-end" , "align-items" : "center" } )
441
- ], justify = "between " , align = "center" ),
447
+ ], md = 12 , xl = 6 , className = "mb-1 text-right" )
448
+ ], justify = "around " , align = "center" , className = "flex-wrap " ),
442
449
dbc .Row ([
443
450
dbc .Col ([
444
451
dcc .Dropdown (multi = True , id = 'sites-dropdown' , placeholder = "Search for a site" ),
@@ -458,13 +465,13 @@ def layout(**other_unknown_query_strings):
458
465
])
459
466
]),
460
467
], lg = 12 , md = 12 , className = "pl-1 pr-1 p-1" ),
461
- ], className = "p-1 site" , justify = "center" , align = "center" ),
468
+ ], className = "p-1 site g-0 " , justify = "center" , align = "center" ),
462
469
], className = 'boxwithshadow page-cont mb-1 row' , align = "center" )],
463
- lg = 6 , sm = 12 , className = 'd-flex flex-column h-100' ),
470
+ lg = 6 , sm = 12 , className = 'd-flex flex-column h-100 pl-1 ' ),
464
471
465
472
# end of top right column
466
473
467
- ], className = 'h-100 gx-4 ' ),
474
+ ], className = 'h-100 g-0 ' ),
468
475
469
476
# bottom part with the list of alarms
470
477
dbc .Row ([
@@ -476,7 +483,7 @@ def layout(**other_unknown_query_strings):
476
483
html .Div (id = 'results-table' ),
477
484
style = {'height' : '0.5rem' }, color = '#00245A' )
478
485
], className = "boxwithshadow page-cont p-2" ,),
479
- ], className = "" ),
486
+ ], className = "g-0 " ),
480
487
], className = '' , style = {"padding" : "0.5% 1% 0 1%" })
481
488
482
489
@@ -559,6 +566,36 @@ def update_output(n_clicks, start_date, end_date, sites, all, events, allevents,
559
566
return [sites_dropdown_items , events_dropdown_items , dcc .Graph (figure = bar_chart ), dataTables ]
560
567
else :
561
568
raise dash .exceptions .PreventUpdate
569
+
570
+
571
+ @dash .callback (
572
+ [
573
+ Output ("how-status-modal" , "is_open" ),
574
+ Output ("how-status-modal-body" , "children" ),
575
+ ],
576
+ [
577
+ Input ("how-status-collapse-button" , "n_clicks" ),
578
+ Input ("close-how-status-modal" , "n_clicks" ),
579
+ ],
580
+ [State ("how-status-modal" , "is_open" )],
581
+ )
582
+ def toggle_modal (n1 , n2 , is_open ):
583
+ if n1 or n2 :
584
+ if not is_open :
585
+ catTable , statusExplainedTable = explainStatuses ()
586
+ data = dbc .Row ([
587
+ dbc .Col (children = [
588
+ html .H3 ('Category & Alarm types' , className = 'status-title' ),
589
+ html .Div (statusExplainedTable , className = 'how-status-table' )
590
+ ], lg = 12 , md = 12 , sm = 12 , className = 'page-cont pr-1 how-status-cont' ),
591
+ dbc .Col (children = [
592
+ html .H3 ('Status color rules' , className = 'status-title' ),
593
+ html .Div (catTable , className = 'how-status-table' )
594
+ ], lg = 12 , md = 12 , sm = 12 , className = 'page-cont how-status-cont' )
595
+ ], className = 'pt-1' )
596
+ return not is_open , data
597
+ return not is_open , dash .no_update
598
+ return is_open , dash .no_update
562
599
563
600
564
601
def create_bar_chart (graphData ):
@@ -596,15 +633,14 @@ def create_bar_chart(graphData):
596
633
legend_orientation = 'h' ,
597
634
legend_title_text = 'Alarm Type' ,
598
635
legend = dict (
599
- traceorder = "normal" ,
600
- font = dict (
601
- family = "sans-serif" ,
602
- size = 14 ,
603
- ),
604
636
x = 0 ,
605
- y = 1.9 ,
637
+ y = 1.35 ,
638
+ orientation = "h" ,
606
639
xanchor = 'left' ,
607
- yanchor = 'top'
640
+ yanchor = 'top' ,
641
+ font = dict (
642
+ size = 10 ,
643
+ ),
608
644
),
609
645
height = 600 ,
610
646
plot_bgcolor = '#fff' ,
@@ -615,6 +651,13 @@ def create_bar_chart(graphData):
615
651
'x' : 0.95 ,
616
652
'xanchor' : 'right' ,
617
653
'yanchor' : 'bottom'
654
+ },
655
+ xaxis = dict (
656
+ # tickangle=-45,
657
+ automargin = True
658
+ ),
659
+ modebar = {
660
+ "orientation" : 'v' ,
618
661
}
619
662
)
620
663
0 commit comments