-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
137 lines (124 loc) · 4.46 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
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
134
135
136
137
import pathlib
import pandas as pd
import dash
from dash import Dash, callback, html, dcc, dash_table, Input, Output, State, MATCH, ALL
import dash_bootstrap_components as dbc
from templates.templates import widget_card_header
import sqlalchemy as sqla
import config
# config variables
port = config.PORT
host = config.HOST
publis_last_obs_date = config.PUBLIS_LAST_OBS_DATE
url_subpath = config.URL_SUBPATH
# external JavaScript f& CSS iles
external_scripts = [
{
'src': 'https://code.jquery.com/jquery-3.6.0.min.js',
'integrity': 'sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=',
'crossorigin': 'anonymous'
},
'https://cdnjs.cloudflare.com/ajax/libs/devextreme/22.1.3/js/dx.all.js',
]
# external CSS stylesheets
external_stylesheets = [
dbc.themes.LUX,
'https://cdnjs.cloudflare.com/ajax/libs/devextreme/22.1.3/css/dx.material.blue.light.compact.css',
]
app = dash.Dash(
__name__, use_pages=True, suppress_callback_exceptions=True,
meta_tags=[
{"name": "viewport", "content": "width=device-width"}],
external_scripts=external_scripts,
external_stylesheets=external_stylesheets,
url_base_pathname=url_subpath,
)
app.config.suppress_callback_exceptions = True
app.title = "Baromètre signatures UCA"
server = app.server
# get relative db folder
PATH = pathlib.Path(__file__).parent
DB_PATH = PATH.joinpath("db", "publications.db").resolve()
dbEngine=sqla.create_engine(f'sqlite:///{DB_PATH}')
df_bsi_publis_uniques = pd.read_sql(f'select dc_identifiers from bsi_publis_uniques_{publis_last_obs_date}',dbEngine)
df_bsi_all_by_mention_adresse = pd.read_sql(f'select dc_identifiers from bsi_all_by_mention_adresse_{publis_last_obs_date}',dbEngine)
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# Use row and col to control vertical alignment of logo / brand
dbc.Row(
[
dbc.Col(html.Img(src=app.get_asset_url('logo_UCA_bibliotheque_ligne_couleurs.png'), height="40px")),
dbc.Col(dbc.NavbarBrand("Barometre des signatures des publications scientifiques UCA", className="ms-2")),
],
align="center",
className="g-0",
),
href=url_subpath,
style={"textDecoration": "none"},
),
dbc.Collapse(
dbc.Nav(
[#dbc.NavItem(dbc.NavLink("Home", href="/")),
dbc.NavItem(dbc.NavLink("Tableau de bord UCA", href=f"{url_subpath}dashboard")),
dbc.NavItem(dbc.NavLink("Tableau de bord par structure", href=f"{url_subpath}dashboard-par-structure")),
dbc.NavItem(dbc.NavLink("Données", href=f"{url_subpath}data")),
],
className="ms-auto",
navbar=True,
),
id="navbar-collapse2",
navbar=True,
),
],
style={"max-width":"1800px"}
),
color="#7191b3",
dark=True,
className="mb-5",
)
row_widgets_header = html.Div(
[
dbc.Row(
[
dbc.Col(widget_card_header("Scopus", "Source des données"),width={"offset": 1, "size":2}),
dbc.Col(widget_card_header("2016 - 2022", "Période observée"),width=2),
dbc.Col(widget_card_header(f'{df_bsi_publis_uniques.shape[0]:,}'.replace(',', ' '),"Nombre de publications"),width=2),
dbc.Col(widget_card_header(f'{df_bsi_all_by_mention_adresse.shape[0]:,}'.replace(',', ' '),"Nombre de mentions d'adresse"), width=2),
dbc.Col(widget_card_header("29 août 2022","Date de dernière mise à jour"), width=2),
],
align="center"
),
]
)
footer = html.Div(
[
html.Footer(
[
html.Div(
[
html.Span("2022 - SCD Université Côte d'Azur. | Contact : "),
dcc.Link(html.A('geraldine.geoffroy@univ-cotedazur.fr'), href="mailto:geraldine.geoffroy@univ-cotedazur.fr")
])
]
)
],
id="footer",
className="text-center",
style={"margin-bottom": "25px"}
)
app.layout = dbc.Container(
fluid=True,
children=
[
navbar,
row_widgets_header,
html.Hr(),
dash.page_container,
footer
],
)
# Main
if __name__ == "__main__":
app.run_server(port=port, host=host)