Skip to content

Commit 657fd7e

Browse files
Adjust layout and styling in home.py and style.css for improved responsiveness and visual clarity
1 parent 9a9ea1d commit 657fd7e

File tree

2 files changed

+72
-25
lines changed

2 files changed

+72
-25
lines changed

src/assets/style.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ body{
172172
}
173173

174174
.cls-site-map {
175-
height: 640px;
175+
height: 540px;
176176
/* padding: 20px;
177177
border: 1px solid rgba(0, 0, 0, .125);
178178
border-radius: 1rem */
@@ -561,12 +561,16 @@ body{
561561
flex: 0.8;
562562
margin: 0 2px;
563563
min-height: 100px;
564-
padding: 30px;
564+
padding: 1%;
565565
text-align: center;
566566
color: rgb(47, 46, 46);
567567
background-color: #ffffff;
568568
}
569569

570+
.status-table-cls {
571+
padding: 2% 2% 0 2% !important;
572+
}
573+
570574
count-box {
571575
padding: 30px;
572576
text-align: center;

src/pages/home.py

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def total_number_of_alarms(sitesDf):
232232
),
233233
md=3, xs=3, xl=3, className='status-count-numbers'
234234
) 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'),
236236
], className='boxwithshadow g-0 mb-1')]
237237

238238

@@ -379,15 +379,15 @@ def layout(**other_unknown_query_strings):
379379
dbc.Col(dcc.Graph(figure=builMap(sitesDf), id='site-map',
380380
className='cls-site-map'),
381381
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%"}
383383
),
384384
dbc.Col(
385385
dcc.Loading(
386386
html.Div(id="alarms-stacked-bar"),
387387
style={'height': '1rem'}, color='#00245A'
388388
),
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
391391
# end of top left column
392392

393393
# top right column with status table, status statistics and the search fields
@@ -396,7 +396,7 @@ def layout(**other_unknown_query_strings):
396396
dbc.Row([
397397
dbc.Col(
398398
[
399-
html.Div(children=statusTable, id='site-status', className='p-2'),
399+
html.Div(children=statusTable, id='site-status', className='status-table-cls'),
400400
html.Div(
401401
[
402402
dbc.Button(
@@ -406,9 +406,16 @@ def layout(**other_unknown_query_strings):
406406
color="secondary",
407407
n_clicks=0,
408408
),
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",
412419
is_open=False,
413420
),
414421
], className="how-status-div",
@@ -427,18 +434,18 @@ def layout(**other_unknown_query_strings):
427434
"Search the Networking Alarms"
428435
], className="l-h-3"),
429436
], align="center", className="text-left rounded-border-1 pl-1"
430-
, md=6, xl=6),
437+
, md=12, xl=6),
431438
dbc.Col([
432439
dcc.DatePickerRange(
433440
id='date-picker-range',
434441
month_format='M-D-Y',
435-
min_date_allowed=date(2022, 8, 1),
442+
min_date_allowed=date.today() - pd.Timedelta(days=30),
436443
initial_visible_month=now[0],
437444
start_date=now[0],
438445
end_date=now[1]
439446
)
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"),
442449
dbc.Row([
443450
dbc.Col([
444451
dcc.Dropdown(multi=True, id='sites-dropdown', placeholder="Search for a site"),
@@ -458,13 +465,13 @@ def layout(**other_unknown_query_strings):
458465
])
459466
]),
460467
], 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"),
462469
], 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'),
464471

465472
# end of top right column
466473

467-
], className='h-100 gx-4'),
474+
], className='h-100 g-0'),
468475

469476
# bottom part with the list of alarms
470477
dbc.Row([
@@ -476,7 +483,7 @@ def layout(**other_unknown_query_strings):
476483
html.Div(id='results-table'),
477484
style={'height': '0.5rem'}, color='#00245A')
478485
], className="boxwithshadow page-cont p-2",),
479-
], className=""),
486+
], className="g-0"),
480487
], className='', style={"padding": "0.5% 1% 0 1%"})
481488

482489

@@ -559,6 +566,36 @@ def update_output(n_clicks, start_date, end_date, sites, all, events, allevents,
559566
return [sites_dropdown_items, events_dropdown_items, dcc.Graph(figure=bar_chart), dataTables]
560567
else:
561568
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
562599

563600

564601
def create_bar_chart(graphData):
@@ -596,15 +633,14 @@ def create_bar_chart(graphData):
596633
legend_orientation='h',
597634
legend_title_text='Alarm Type',
598635
legend=dict(
599-
traceorder="normal",
600-
font=dict(
601-
family="sans-serif",
602-
size=14,
603-
),
604636
x=0,
605-
y=1.9,
637+
y=1.35,
638+
orientation="h",
606639
xanchor='left',
607-
yanchor='top'
640+
yanchor='top',
641+
font=dict(
642+
size=10,
643+
),
608644
),
609645
height=600,
610646
plot_bgcolor='#fff',
@@ -615,6 +651,13 @@ def create_bar_chart(graphData):
615651
'x': 0.95,
616652
'xanchor': 'right',
617653
'yanchor': 'bottom'
654+
},
655+
xaxis=dict(
656+
# tickangle=-45,
657+
automargin=True
658+
),
659+
modebar={
660+
"orientation": 'v',
618661
}
619662
)
620663

0 commit comments

Comments
 (0)