-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
133 lines (124 loc) · 4.16 KB
/
index.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from dash.dependencies import Input, Output, State
from app import app
from panels import statistiques, recommandations, analyse_sentiment
opportunities = pd.read_csv('data/extracted_tweets.csv', sep=";")
cases = pd.read_csv('data/extracted_tweets.csv', sep=";")
leads = pd.read_csv('data/extracted_tweets.csv', sep=';')
server = app.server
app.title = 'Dashboard e-réputation'
app.layout = html.Div(
[
html.Div(
className="row header",
children=[
html.Button(id="menu", children=dcc.Markdown("≡")),
html.Span(
className="app-title",
children=[
dcc.Markdown("**Dashboard**"),
html.Span(
id="subtitle",
children=dcc.Markdown("  e-réputation"),
style={"font-size": "1.8rem", "margin-top": "15px"},
),
],
)
],
),
html.Div(
id="tabs",
className="row tabs",
children=[
dcc.Link("Statistiques", href="/"),
dcc.Link("Analyse de sentiment", href="/"),
dcc.Link("Recommandations", href="/"),
],
),
html.Div(
id="mobile_tabs",
className="row tabs",
style={"display": "none"},
children=[
dcc.Link("Statistiques", href="/"),
dcc.Link("Analyse de sentiment", href="/"),
dcc.Link("Recommandations", href="/"),
],
),
dcc.Store( # opportunities df
id="opportunities_df",
data=opportunities.to_json(orient="split"),
),
dcc.Store( # leads df
id="leads_df",
data=leads.to_json(orient="split"),
),
dcc.Store(
id="cases_df",
data=cases.to_json(orient="split"),
), # cases df
dcc.Location(id="url", refresh=False),
html.Div(id="tab_content"),
html.Link(
href="https://use.fontawesome.com/releases/v5.2.0/css/all.css",
rel="stylesheet",
),
html.Link(
href="https://fonts.googleapis.com/css?family=Dosis", rel="stylesheet"
),
html.Link(
href="https://fonts.googleapis.com/css?family=Open+Sans", rel="stylesheet"
),
html.Link(
href="https://fonts.googleapis.com/css?family=Ubuntu", rel="stylesheet"
),
],
className="row",
style={"margin": "0%"},
)
# Update the index
@app.callback(
[
Output("tab_content", "children"),
Output("tabs", "children"),
Output("mobile_tabs", "children"),
],
[Input("url", "pathname")],
)
def display_page(pathname):
tabs = [
dcc.Link("Statistiques", href="/dash-ppd/statistiques"),
dcc.Link("Analyse de sentiment", href="/dash-ppd/analyse_sentiment"),
dcc.Link("Recommandations", href="/dash-ppd/recommandations"),
]
if pathname == "/dash-ppd/statistiques":
tabs[0] = dcc.Link(
dcc.Markdown("**■ Statistiques**"),
href="/dash-ppd/statistiques",
)
return statistiques.layout, tabs, tabs
elif pathname == "/dash-ppd/recommandations":
tabs[2] = dcc.Link(
dcc.Markdown("**■ Recommandations**"), href="/dash-ppd/recommandations"
)
return recommandations.layout, tabs, tabs
tabs[1] = dcc.Link(
dcc.Markdown("**■ Analyse de sentiment**"), href="/dash-ppd/analyse_sentiment"
)
return analyse_sentiment.layout, tabs, tabs
@app.callback(
Output("mobile_tabs", "style"),
[Input("menu", "n_clicks")],
[State("mobile_tabs", "style")],
)
def show_menu(n_clicks, tabs_style):
if n_clicks:
if tabs_style["display"] == "none":
tabs_style["display"] = "flex"
else:
tabs_style["display"] = "none"
return tabs_style
if __name__ == "__main__":
app.run_server(debug=False)