mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
add storm report downloading
This commit is contained in:
+65
-3
@@ -1,11 +1,12 @@
|
|||||||
---
|
---
|
||||||
title: "Hurricane Normalization App"
|
title: "Hurricane Normalization App"
|
||||||
runtime: shiny
|
runtime: shiny
|
||||||
output:
|
output:
|
||||||
flexdashboard::flex_dashboard:
|
flexdashboard::flex_dashboard:
|
||||||
orientation: columns
|
orientation: columns
|
||||||
vertical_layout: fill
|
vertical_layout: fill
|
||||||
theme:
|
resize_reload: false
|
||||||
|
theme:
|
||||||
version: 4
|
version: 4
|
||||||
bootswatch: litera
|
bootswatch: litera
|
||||||
---
|
---
|
||||||
@@ -40,6 +41,7 @@ library(billboarder)
|
|||||||
library(shinyWidgets)
|
library(shinyWidgets)
|
||||||
library(paletteer)
|
library(paletteer)
|
||||||
library(shinyjs)
|
library(shinyjs)
|
||||||
|
library(quarto)
|
||||||
|
|
||||||
APP_DIR <- getwd()
|
APP_DIR <- getwd()
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ storm_selection <- reactiveValues(
|
|||||||
storm_year = NULL,
|
storm_year = NULL,
|
||||||
storm_name = NULL,
|
storm_name = NULL,
|
||||||
storm_basin = NULL,
|
storm_basin = NULL,
|
||||||
|
hurdatid = NULL
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -177,7 +180,9 @@ observeEvent(input$selectStorm, {
|
|||||||
storm_selection$storm_basin <- "AL"
|
storm_selection$storm_basin <- "AL"
|
||||||
storm_selection$storm_year <- input$stormYear
|
storm_selection$storm_year <- input$stormYear
|
||||||
storm_selection$storm_name <- input$stormName
|
storm_selection$storm_name <- input$stormName
|
||||||
#storm_selection$is_selected <- TRUE
|
|
||||||
|
hurdatid <- get_hurdat_id(storm_selection)
|
||||||
|
storm_selection$hurdatid = hurdatid$hurdatid
|
||||||
|
|
||||||
showNotification("Storm selection updated!", type = "message")
|
showNotification("Storm selection updated!", type = "message")
|
||||||
})
|
})
|
||||||
@@ -1443,6 +1448,63 @@ div(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Download Report {data-navmenu="Compute"}
|
||||||
|
===
|
||||||
|
|
||||||
|
Column {data-width=400}
|
||||||
|
---
|
||||||
|
|
||||||
|
### Report Options {}
|
||||||
|
```{r}
|
||||||
|
downloadButton("report", "Generate Report")
|
||||||
|
|
||||||
|
output$report <- downloadHandler(
|
||||||
|
filename = function() {
|
||||||
|
paste0(
|
||||||
|
storm_selection$hurdatid,
|
||||||
|
"_",
|
||||||
|
storm_selection$storm_name,
|
||||||
|
"_",
|
||||||
|
storm_selection$storm_year,
|
||||||
|
".pdf"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
content = function(file) {
|
||||||
|
params <- list(
|
||||||
|
storm_basin = storm_selection$storm_basin,
|
||||||
|
storm_year = storm_selection$storm_year,
|
||||||
|
storm_name = storm_selection$storm_name,
|
||||||
|
hurdat_id = storm_selection$hurdatid
|
||||||
|
)
|
||||||
|
|
||||||
|
id <- showNotification(
|
||||||
|
"Rendering report...",
|
||||||
|
duration = NULL,
|
||||||
|
closeButton = FALSE
|
||||||
|
)
|
||||||
|
|
||||||
|
on.exit(removeNotification(id), add = TRUE)
|
||||||
|
|
||||||
|
temp_pdf <- file.path(APP_DIR, "storm_report.pdf")
|
||||||
|
|
||||||
|
quarto::quarto_render(
|
||||||
|
input = file.path(APP_DIR, "storm_report.qmd"),
|
||||||
|
execute_params = params,
|
||||||
|
output_format = "pdf"
|
||||||
|
)
|
||||||
|
|
||||||
|
file.copy(temp_pdf, file)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Column {data-width=600}
|
||||||
|
---
|
||||||
|
|
||||||
|
### {.no-padding}
|
||||||
|
```{r}
|
||||||
|
```
|
||||||
|
|
||||||
Data Export {data-navmenu="Compute"}
|
Data Export {data-navmenu="Compute"}
|
||||||
===
|
===
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user