From f87809601afa756a679edc0939459dfd6d142f61 Mon Sep 17 00:00:00 2001 From: dylanbenzi Date: Thu, 16 Apr 2026 15:39:08 -0400 Subject: [PATCH] add downloadable datasets ui --- app/global.R | 9 ++--- app/ui.R | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/app/global.R b/app/global.R index 1a73ad6..4e397ec 100644 --- a/app/global.R +++ b/app/global.R @@ -27,6 +27,7 @@ library(shinyWidgets) library(paletteer) library(shinyjs) library(quarto) +library(bsicons) APP_DIR <- getwd() @@ -79,10 +80,10 @@ storm_coverage <- get_storm_data_coverage() %>% has_cost_data ) -dt_yr_range <- range(storm_coverage$storm_year, na.rm = TRUE) -dt_death_max <- max(storm_coverage$total_direct_deaths, na.rm = TRUE) -dt_mmh_max <- max(storm_coverage$mmh, na.rm = TRUE) -dt_mmp_max <- max(storm_coverage$mmp, na.rm = TRUE) +dt_yr_range <- range(storm_coverage$storm_year, na.rm = TRUE) +dt_death_max <- max(storm_coverage$total_direct_deaths, na.rm = TRUE) +dt_mmh_max <- max(storm_coverage$mmh, na.rm = TRUE) +dt_mmp_max <- max(storm_coverage$mmp, na.rm = TRUE) onStop(function() { poolClose(con) diff --git a/app/ui.R b/app/ui.R index 2419216..71c95a2 100644 --- a/app/ui.R +++ b/app/ui.R @@ -1,5 +1,89 @@ library(bslib) +download_card <- function( + title, + description, + data_coverage, + last_updated, + data_id +) { + return( + card( + fill = F, + layout_columns( + col_widths = c(10, 2), + strong(title), + actionButton( + class = "btn-primary btn-sm", + icon = icon("download"), + paste("download", data_id, sep = "-"), + "Download" + ) + ), + p(description), + div( + class = "d-flex", + div( + class = "d-flex me-4", + bs_icon("database-fill", class = "text-muted me-1"), + h6(data_coverage) + ), + div( + class = "d-flex me-4", + bs_icon("calendar-event-fill", class = "text-muted me-1"), + h6(last_updated) + ) + ) + ) + ) +} + +# cost norm, economic factors, fatalities, svis, rmw county weights, landfalls +download_cards <- list( + download_card( + "Cyclone Cost Normalization", + "Normalized economic damage estimates for US landfalling hurricanes 1900-2023 using updated MMH/MMP methodology.", + "1900-2023", + "8/03/2025", + "cost_norm" + ), + download_card( + "Economic Factors", + "Yearly economic factors for GDP deflator and Current-Cost Net Stock of Fixed Assets and Consumer Durable Goods (CCNFACDG) used in the MMH/MMP cost normalization methodology.", + "1900-2024", + "-/-/2025", + "usa_econ" + ), + download_card( + "Tracked Landfalls", + "Landfalls with identifiers, RMW county weights, and time/location data for all storms normalized using the MMH/MMP methodology.", + "1900-2024", + "3/15/2026", + "landfalls" + ), + download_card( + "Cyclone Fatalities", + "All known direct fatalities with peril categories from tropical cyclones", + "1963-2024", + "3/31/2026", + "fatalities" + ), + download_card( + "Social Vulnerability Index", + "County/tract level data representing the vulnerability of people in that region", + "X-X", + "...", + "svi" + ), + download_card( + "Additional Data", + "We can add more here later", + "X-X", + "...", + "additional" + ) +) + ui <- page_navbar( id = "main_navbar", fillable = TRUE, @@ -431,7 +515,17 @@ ui <- page_navbar( ) ) ), - nav_panel("Export") + nav_panel( + "Export", + layout_column_wrap( + width = 1 / 2, + card( + card_header("Available Datasets"), + !!!download_cards + ), + card() + ) + ) ), nav_menu( "About",