Skip to content

Jpng.merge seassons to single page #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions fbfmaproom/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ body {
#main_row {
display: flex;
flex-grow: 1;
min-height: 0; /* otherwise it gets sized to fit the table content and overflows the viewport. */
min-height: 0;
/* otherwise it gets sized to fit the table content and overflows the viewport. */
}

#lcol {
Expand Down Expand Up @@ -102,7 +103,8 @@ table.supertable {
display: block;
}

table.supertable td, table.supertable th {
table.supertable td,
table.supertable th {
border-right-style: solid;
border-right-width: 1px;
border-right-color: rgb(200, 200, 200);
Expand Down Expand Up @@ -174,3 +176,35 @@ table.supertable tbody {
.cell-excluded {
background-color: rgb(150, 150, 150);
}

#season_links .btn-primary {
line-height: 22px;
width: 100%;
text-align: left;
padding: 10px;
border-radius: 4px;
font: 14px / 16px Arial, Helvetica, sans-serif;
--bs-btn-color: #333;
--bs-btn-bg: white;
--bs-btn-border-color: #ccc;
--bs-btn-hover-border-color: #ccc;
--bs-btn-hover-bg: white;
--bs-btn-hover-color: #333;
--bs-btn-active-color: #333;
--bs-btn-active-border-color: #ccc;
--bs-btn-active-bg: white;
--bs-btn-disabled-color: #333;
--bs-btn-disabled-bg: white;
}

#season_links .dropdown-toggle::after {
float: right;
margin: 5px;
border-width: 5px 5px 2.5px;
color: #999;
}

#season_links .dropdown-item {
--bs-dropdown-link-active-bg: #cfe2ff;
--bs-dropdown-link-active-color: black;
}
9 changes: 5 additions & 4 deletions fbfmaproom/fbflayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ def control_layout():
clearable=False,
),
),

# TODO: A hidden dropdown is used to store the season variable.
# This can be removed once season is refactored to be contained in a single page
html.Div(dcc.Dropdown(id="season"), style={"display": "none"}),
control(
"Season",
"The rainy season being forecasted",
dcc.Dropdown(
id="season",
clearable=False,
dbc.DropdownMenu(
id="season_links",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, you switched from dcc.Dropdown to dbc.DropdownMenu because in the version of dash we're using, you can't put a link in dcc.Dropdown item text; but in dash 2.5+ you can. Let's go with your solution for now, so we can deliver the new functionality to Madagascar ASAP, but after this is merged I will try to update dash so we can go back to using dcc.Dropdown. If that doesn't work out, maybe we should switch all the menus to dbc.DropdownMenu to avoid the risk of styling getting out of sync.

Copy link
Collaborator

@aaron-kaplan aaron-kaplan Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this comment before looking at the screenshot or trying it out. Now I see that the styling difference isn't just a potential future problem, it's a problem now. This dropdown is blue while all the others are white, and it doesn't display the currently selected item when not clicked. Is that fixable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've updated the CSS styling to more closely match the other dropdowns. Once we are able to upgrade to dash 2.5+ then we can change it to a dcc.Dropdown and get all the styling changes for free.

image

),
),

Expand Down
14 changes: 12 additions & 2 deletions fbfmaproom/fbfmaproom-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ countries:
pct: quantile
colormap: pne_25
is_poe: no

subpages:
DJF: "madagascar"
NDJ: "madagascar-ndj"
OND: "madagascar-ond"
seasons:
season1:
label: DJF
Expand Down Expand Up @@ -519,6 +522,10 @@ countries:
pct: quantile
colormap: pne_25
is_poe: no
subpages:
DJF: "madagascar"
NDJ: "madagascar-ndj"
OND: "madagascar-ond"
seasons:
season1:
label: NDJ
Expand Down Expand Up @@ -689,7 +696,10 @@ countries:
pct: quantile
colormap: pne_25
is_poe: no

subpages:
DJF: "madagascar"
NDJ: "madagascar-ndj"
OND: "madagascar-ond"
seasons:
season1:
label: OND
Expand Down
15 changes: 14 additions & 1 deletion fbfmaproom/fbfmaproom.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ def country(pathname: str) -> str:
Output("map", "zoom"),
Output("season", "options"),
Output("season", "value"),
Output("season_links", "children"),
Output("season_links", "label"),
Output("mode", "options"),
Output("mode", "value"),
Output("predictand", "options"),
Expand All @@ -794,7 +796,7 @@ def country(pathname: str) -> str:
Input("location", "pathname"),
State("location", "search"),
)
def initial_setup(pathname, qstring):
def initial_setup(pathname: str, qstring: str):
country_key = country(pathname)
c = CONFIG["countries"][country_key]

Expand All @@ -805,6 +807,15 @@ def initial_setup(pathname, qstring):
)
for k in sorted(c["seasons"].keys())
]

subpages = c.get("subpages", {"DEFAULT": country_key})
season_link_options = [
dbc.DropdownMenuItem(subpage, href=f"{PFX}/{subpage_link}", active=(subpage_link == country_key))
for subpage, subpage_link in subpages.items()
]
active_seasons = [subpage for subpage, subpage_link in subpages.items() if subpage_link==country_key]
active_season = active_seasons[0] if len(active_seasons) > 0 else ""

cx, cy = c["center"]

mode_options = [
Expand Down Expand Up @@ -894,6 +905,8 @@ def initial_setup(pathname, qstring):
c["zoom"],
season_options,
season_value,
season_link_options,
active_season,
mode_options,
mode_value,
predictand_options,
Expand Down
2 changes: 1 addition & 1 deletion pingrid/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ def client_side_error(e):

REQUIRED = object()

def parse_arg(name, conversion=str, default=REQUIRED, qstring=None):
def parse_arg(name: str, conversion=str, default=REQUIRED, qstring: Optional[str] = None):
'''Stricter version of flask.request.args.get. Raises an exception in
cases where args.get ignores the problem and silently falls back on a
default behavior:
Expand Down
Loading