-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'download-template-84' into fix-option-C-#135
- Loading branch information
Showing
4 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ mod_query_data_ui <- function(id) { | |
ns("example_data_go"), | ||
"Load", | ||
shiny::icon("truck-ramp-box"), | ||
disabled = TRUE, | ||
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4" | ||
) | ||
)), | ||
|
@@ -188,10 +189,9 @@ mod_query_data_ui <- function(id) { | |
shiny::fluidRow( | ||
column( | ||
4, | ||
shiny::checkboxGroupInput(ns("providers"), | ||
shiny::radioButtons(ns("providers"), | ||
"Data Source", | ||
c("NWIS (USGS)" = "NWIS", "WQX (EPA)" = "STORET"), | ||
selected = c("NWIS", "STORET")) | ||
c("NWIS (USGS)" = "NWIS", "WQX (EPA)" = "STORET", "Both (NWIS and WQX)" = "all"), selected = "all") | ||
) | ||
), | ||
shiny::fluidRow(column( | ||
|
@@ -204,11 +204,9 @@ mod_query_data_ui <- function(id) { | |
shiny::fluidRow( | ||
htmltools::h3("Option C: Upload dataset"), | ||
htmltools::HTML(( | ||
"Upload a dataset from your computer. This upload feature only accepts data in .xls and .xlsx formats. | ||
The file can be a <B>fresh</B> TADA dataset or a <B>working</B> TADA dataset that you are returning to the | ||
app to iterate on. Data must also be formatted in the EPA Water Quality eXchange (WQX) schema to leverage | ||
this tool. You may reach out to the WQX helpdesk at [email protected] for assistance preparing and submitting your data | ||
to the WQP through EPA's WQX." | ||
"Upload a compatible dataset from your computer. This upload feature only accepts data in .xls and .xlsx formats. Data must be formatted in the EPA Water Quality eXchange (WQX) schema (and include all columns required for this TADA R Shiny application) to run | ||
this tool. The file can be a <B>fresh</B> dataset you created using the TADA template below or a <B>working</B> dataset that you downloaded from this application using the Download Working Dataset feature, and are now returning to the | ||
app to iterate on." | ||
)), | ||
# widget to upload WQP profile or WQX formatted spreadsheet | ||
column( | ||
|
@@ -222,6 +220,20 @@ mod_query_data_ui <- function(id) { | |
) | ||
) | ||
), | ||
shiny::fluidRow( | ||
htmltools::HTML( | ||
"Download a blank TADA data template in .xlsx format. This template is available to assist users that do not have data available in the WQP (and therefore cannot use Option B) prepare their data for upload to this R Shiny application using import Option C. | ||
You may reach out to the TADA team through the helpdesk at [email protected] for assistance preparing your data. If your data is not in the WQP yet and you are interested in submitting it, you may reach out to the WQX helpdesk at [email protected] for assistance preparing and submitting your data | ||
to the WQP through EPA's WQX.<br><br>" | ||
), | ||
column( | ||
9, | ||
shiny::downloadButton( | ||
ns("download_template"), | ||
"Download Template", | ||
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4;") | ||
) | ||
), | ||
htmltools::hr(), | ||
shiny::fluidRow( | ||
htmltools::h3("Optional: Upload Progress File"), | ||
|
@@ -255,6 +267,32 @@ mod_query_data_ui <- function(id) { | |
mod_query_data_server <- function(id, tadat) { | ||
shiny::moduleServer(id, function(input, output, session) { | ||
ns <- session$ns | ||
|
||
## creates download template button used for importing data to TADAShiny - used in option C | ||
template_data <- reactive(EPATADA::TADA_GetTemplate()) | ||
# return an ms excel file with the template columns | ||
output$download_template <- shiny::downloadHandler( | ||
filename = function() { | ||
paste0("tada_template", ".xlsx") | ||
}, | ||
content = function(file) { | ||
# format csv. contentType = "text/csv" | ||
# write.csv(template_data(), file) | ||
# browser() | ||
# format excel (xlsx) | ||
d = template_data() | ||
writexl::write_xlsx(d, path = file) | ||
}, | ||
contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | ||
) | ||
|
||
## greys out Load button for example data until file has been selected | ||
# https://stackoverflow.com/questions/24175997/force-no-default-selection-in-selectinput | ||
shiny::observeEvent(input$example_data, { | ||
if (!is.na(input$example_data) && nchar(input$example_data) > 1) { | ||
shinyjs::enable("example_data_go") | ||
} | ||
}) | ||
|
||
# read in the excel spreadsheet dataset if this input reactive object is populated via fileInput and define as tadat$raw | ||
shiny::observeEvent(input$file, { | ||
|
@@ -413,15 +451,15 @@ mod_query_data_server <- function(id, tadat) { | |
} else { | ||
tadat$countrycode <- input$countryocean | ||
} | ||
if (is.null(input$providers)) { | ||
if (is.null(input$providers) | input$providers == "all") { | ||
tadat$providers <- "null" | ||
} else { | ||
tadat$providers <- input$providers | ||
} | ||
if (input$huc == "") { | ||
tadat$huc <- "null" | ||
} else { | ||
tadat$huc <- input$huc | ||
tadat$huc <- gsub("\\s", "", input$huc) | ||
} | ||
if (is.null(input$siteid)) { | ||
tadat$siteid <- "null" | ||
|
@@ -451,7 +489,7 @@ mod_query_data_server <- function(id, tadat) { | |
if (is.null(input$project)) { | ||
tadat$project <- "null" | ||
} else { | ||
tadat$project <- paste(input$project, collapse = ",") | ||
tadat$project <- input$project | ||
} | ||
if (is.null(input$org)) { | ||
tadat$organization <- "null" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters