Skip to content

Commit cd6e86f

Browse files
committed
Refresh org list on load
1 parent cb9ee83 commit cd6e86f

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

dashboard/layout/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def serve_layout():
7777
df_org.name, df_org.id
7878
)
7979
],
80-
# multi=False,
80+
clearable=False,
8181
value=orga_id,
8282
# value=df_org.id.unique().tolist()[0],
8383
# value="Select your organization",

dashboard/layout/callbacks.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_experiment_sums,
1010
get_lastrun,
1111
get_orga_sums,
12+
get_organization_list,
1213
get_project,
1314
get_project_list,
1415
get_project_sums,
@@ -595,3 +596,21 @@ def update_map(start_date, end_date, project, kpi):
595596
showland=True, landcolor="#6f898e", showocean=True, oceancolor="#759FA8"
596597
)
597598
return container, fig
599+
600+
601+
# Refresh organizations list
602+
@app.callback(
603+
[
604+
Output(component_id="org-dropdown", component_property="options"),
605+
Output(component_id="org-dropdown", component_property="value"),
606+
],
607+
[Input("url-location", "pathname")],
608+
)
609+
def refresh_org_list(url):
610+
df_org = get_organization_list()
611+
org_id = df_org.id.unique().tolist()[1]
612+
options = [
613+
{"label": orgName, "value": orgId}
614+
for orgName, orgId in zip(df_org.name, df_org.id)
615+
]
616+
return options, org_id

dashboard/layout/components.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def get_header():
1313
[html.Img(src="/assets/logo.png")], href="https://codecarbon.io"
1414
),
1515
html.P("Track and reduce CO2 emissions from your computing"),
16+
dcc.Location(id="url-location", refresh=False),
1617
dcc.DatePickerRange(
1718
id="periode",
1819
day_size=39,

0 commit comments

Comments
 (0)