-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
98 lines (90 loc) · 2.8 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from dash import Dash, html, dcc, callback, Input, Output, State
import dash
import pandas as pd
import dash_mantine_components as dmc
from data_etl import df_raw
from utils import (
create_metric_chooser,
create_top_n_filter,
create_city_filter,
create_category_filter,
create_vendor_filter,
create_bottly_volume_filter,
create_simple_grid,
)
app = Dash(__name__, use_pages=True)
sidebar = dmc.Navbar(
fixed=True,
style={"marginLeft": 25},
width={"base": 300},
height=300,
children=[
dmc.ScrollArea(
offsetScrollbars=True,
type="scroll",
children=[
dmc.Group(
direction="column",
children=[
dmc.Button("Filters", id="modal-demo-button"),
dmc.Modal(
size="lg",
title="Dataset Filters",
id="modal",
children=create_simple_grid(
component_list=[
create_metric_chooser(),
create_top_n_filter(),
create_city_filter(),
create_category_filter(),
create_vendor_filter(),
create_bottly_volume_filter(),
]
),
),
],
),
# dmc.Divider(style={"marginBottom": 20, "marginTop": 20}),
dmc.Group(
direction="column",
children=[
dcc.Link(
dmc.Text(page["name"], size="sm", color="gray"),
href=page["path"],
id=page["name"],
style={"textDecoration": "none"},
)
for page in dash.page_registry.values()
],
),
],
)
],
)
app.layout = dmc.Container(
[
dmc.Header(
height=40,
children=[html.H1("Dash Autumn Challange", style={"textAlign": "center"})],
style={"backgroundColor": "#FFFFFF"},
),
sidebar,
dmc.Container(
dash.page_container,
size="lg",
pt=20,
style={"marginLeft": 350},
),
],
fluid=True,
)
@callback(
Output("modal", "opened"),
Input("modal-demo-button", "n_clicks"),
State("modal", "opened"),
prevent_initial_call=True,
)
def modal_demo(nc1, opened):
return not opened
if __name__ == "__main__":
app.run_server(debug=True)