Skip to content
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

Review fix #134

Merged
merged 24 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b6f00b9
fixed the zip file issue, na filters in desc tab
triphook Dec 18, 2023
b6b0844
Revert "fixed the zip file issue, na filters in desc tab"
triphook Jan 3, 2024
ed85f5e
fixed the zipfile download issue
triphook Jan 9, 2024
70801d6
reconfigured flagging page to populate table whenever flagging column…
triphook Jan 10, 2024
d492dfb
added second button for downloading final dataset
triphook Jan 23, 2024
1702152
Merge branch 'develop' into review_fix
cristinamullin Jan 23, 2024
9bafba1
update docs and add package refs
cristinamullin Jan 24, 2024
e743da1
removed some print statements
triphook Jan 30, 2024
5dd5832
Merge branch 'review_fix' of https://github.com/usepa/tadashiny into …
triphook Jan 30, 2024
c651241
Update prints
cristinamullin Feb 2, 2024
a5e2c87
add definitions
cristinamullin Feb 2, 2024
9e5f0df
merged
triphook Feb 6, 2024
ba3b71a
fixed htm vs zip bug
triphook Feb 6, 2024
2e64caa
add qual code def
cristinamullin Feb 6, 2024
51a723a
fixed flag table bug
triphook Feb 8, 2024
a437468
update max and min flag column values
cristinamullin Feb 8, 2024
9e47ac9
update to match package
cristinamullin Feb 8, 2024
2ed5af6
removed print statements
triphook Feb 12, 2024
6e35c34
update description
cristinamullin Feb 20, 2024
fe70af8
Progress file details
cristinamullin Feb 20, 2024
3891e83
documentation
cristinamullin Feb 20, 2024
1ed01ce
update description
cristinamullin Feb 23, 2024
fc79471
fix speciation name
cristinamullin Feb 23, 2024
3c076ef
filter field selection working
triphook Feb 23, 2024
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
55 changes: 28 additions & 27 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
Package: TADAShiny
Type: Package
Title: WQP Data Discovery and Cleaning: First R Shiny App in the TADA (Tools for Automated Data Analysis) Series
Title: Water Quality Portal Data Discovery and Cleaning: First R Shiny App in the TADA (Tools for Automated Data Analysis) Series
Version: 0.0.0.9000
Organization: U.S. Environmental Protection Agency
Authors@R:
c(person(given = "Cristina",
family = "Mullin",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-0615-6087")),
person(given = "Trip",
family = "Hook",
role = "aut"),
person(given = "Elise",
family = "Hinman",
role = c("aut"),
email = "[email protected]"),
person(given = "Hui",
family = "Zhou",
role = c("aut"),
email = "[email protected]"),
person(given = "Shelly",
family = "Thawley",
role = "aut"))
Description: Assists data partners in retrieving, wrangling, quality checking, and preparing data from the Water Quality Portal for subsequent analyses.
Authors@R: c(
person(given = "U.S. Environmental Protection Agency", role = "aut"),
person(given = "Cristina",
family = "Mullin",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-0615-6087")),
person(given = "Trip",
family = "Hook",
role = "aut"),
person(given = "Elise",
family = "Hinman",
role = "aut"),
person(given = "Hillary",
family = "Marler",
role = "aut"),
person(given = "Shelly",
family = "Thawley",
role = "aut"),
person(given = "Hui",
family = "Zhou",
role = "aut")
)
Description: Assists data partners in retrieving, wrangling, quality checking, and harmonizing data from the Water Quality Portal for subsequent analyses.
License: CC0
Copyright: This software is in the public domain because it contains materials
that originally came from the U.S. Environmental Protection Agency.
Imports:
config,
golem,
magrittr,
golem,
htmltools,
readxl,
writexl,
Expand All @@ -54,6 +55,7 @@ Imports:
Remotes:
github::USEPA/TADA
Suggests:
config,
testthat,
remotes,
covr,
Expand All @@ -73,6 +75,5 @@ Config/testthat/load-all: list(export_all = FALSE, helpers = FALSE)
LazyData: true
URL: https://github.com/USEPA/TADAShiny
BugReports: https://github.com/USEPA/TADAShiny/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr, rmarkdown
36 changes: 17 additions & 19 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Below increases the max data upload size from the Shiny default of 5MB per file
# to 30MB for file
options(shiny.maxRequestSize = 30 * 1024^2)

options(warn = 2)
app_server <- function(input, output, session) {
# Your application server logic
tadat <- shiny::reactiveValues() # create a list object that holds reactive values passed between modules
Expand All @@ -35,6 +35,7 @@ app_server <- function(input, output, session) {
# switch that indicates when a file is being loaded
tadat$load_progress_file = NA
tadat$save_progress_file = NA
tadat$flags_present = FALSE
job_id = paste0("ts", format(Sys.time(), "%y%m%d%H%M%S"))
tadat$default_outfile = paste0("tada_output_", job_id)
tadat$job_id = job_id
Expand All @@ -44,7 +45,7 @@ app_server <- function(input, output, session) {
shiny::observeEvent(tadat$new, {
shiny::showModal(shiny::modalDialog(
title = "Data Loaded",
"Your data were successfully loaded into the app and are displayed on the Overview tab. The following data wrangling steps were performed automatically when data was loaded: 1) created TADA versions of a subset of columns for editing (originals are retained), 2) removed exact duplicates, 3) handled/flagged special characters and text in result values and units, 4) identified detection limit data and copied limit value to result value if blank, 5) harmonized result and depth units to TADA defaults, and 6) replaced retired characteristic names with current names. See summary information about your dataset in the gray box at the bottom of the app."
"Your data were successfully loaded into the app and are displayed on the Overview tab. The following data wrangling steps were performed automatically when data was loaded: 1) created TADA versions of a subset of columns for editing (originals are retained), 2) handled/flagged special characters and text in result values and units, 3) harmonized result and depth units to TADA defaults, and 4) replaced retired characteristic names with current names. See summary information about your dataset in the gray box at the bottom of the app."
))
shiny::updateTabsetPanel(session = session, inputId = "tabbar", selected = "Overview")
tadat$new <- NULL
Expand All @@ -57,27 +58,24 @@ app_server <- function(input, output, session) {
}
})

# Update the default switches if a progress file is uploaded.
shiny::observeEvent(tadat$selected_flags, {
switch_defaults = tadat$selected_flags
})


# this observes when the user switches tabs and adds the current tab they're on as a column to their dataset.
shiny::observe({
shiny::req(tadat$raw)
# JCH - is this necessary?
#shiny::req(tadat$raw)
tadat$raw$TADAShiny.tab <- input$tabbar
tadat$tab <- input$tabbar
})

# JCH - disabling this for now. I think progress files provide this functionality
# this observes when the user switches tabs and adds the current tab they're on as a column to their dataset.

# switch to tab user left off on when tadat$reup changes, which only happens when someone uploads a workbook with the column "Removed" in it
shiny::observeEvent(tadat$reup, {
shiny::showModal(shiny::modalDialog(
title = "Data Loaded",
"Your working dataset has been uploaded and the app switched to the tab where you left off."
))
# the switch tab command
shiny::updateTabsetPanel(session = session, inputId = "tabbar", selected = unique(tadat$raw$tab))
tadat$reup <- NULL
})
#shiny::observeEvent(tadat$reup, {
# shiny::showModal(shiny::modalDialog(
# title = "Data Loaded",
# "Your working dataset has been uploaded and the app switched to the tab where you left off."
# ))
# # the switch tab command
# shiny::updateTabsetPanel(session = session, inputId = "tabbar", selected = unique(tadat$raw$tab))
# tadat$reup <- NULL
#})
}
61 changes: 38 additions & 23 deletions R/mod_TADA_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ mod_TADA_summary_ui <- function(id) {
"site_clean"
)))),
shiny::fluidRow(column(6, shiny::uiOutput(ns(
"dwn_all"
"dwn_working"
)))),
shiny::fluidRow(column(6, shiny::uiOutput(ns(
"dwn_ts"
"dwn_final"
))))#,
# shiny::fluidRow(column(
# 6,
Expand Down Expand Up @@ -169,16 +169,25 @@ mod_TADA_summary_server <- function(id, tadat) {
})

# download dataset button - only appears if there data exists in the app already
output$dwn_all <- shiny::renderUI({
output$dwn_working <- shiny::renderUI({
shiny::req(tadat$raw)
shiny::downloadButton(ns("download_all"),
shiny::downloadButton(ns("download_working"),
"Download Working Dataset (.zip)",
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4")
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4",
contentType = "application/zip")
})

output$download_all <- shiny::downloadHandler(
output$dwn_final <- shiny::renderUI({
shiny::req(tadat$raw)
shiny::downloadButton(ns("download_final"),
"Download Final Dataset (.zip)",
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4",
contentType = "application/zip")
})

output$download_working <- shiny::downloadHandler(
filename = function() {
paste0(tadat$default_outfile, ".zip")
paste0(tadat$default_outfile, "_working.zip")
},
content = function(fname) {
fs <- c()
Expand All @@ -197,22 +206,28 @@ mod_TADA_summary_server <- function(id, tadat) {
contentType = "application/zip"
)

# # Download TADA progress file
# output$dwn_ts = shiny::renderUI({
# shiny::req(tadat$raw)
# shiny::downloadButton(ns("download_ts_file"),
# "Download Progress File (.Rdata)",
# style = "color: #fff; background-color: #337ab7; border-color: #2e6da4")
# })

# output$download_ts_file = shiny::downloadHandler(
# filename = function() {
# paste0(tadat$job_id, '.Rdata')
# },
# content = function(file) {
# writeFile(tadat, file)
# }
# )
output$download_final <- shiny::downloadHandler(
filename = function() {
paste0(tadat$default_outfile, "_final.zip")
},
content = function(fname) {
fs <- c()
tmpdir <- tempdir()
setwd(tempdir())
datafile_name = paste0(tadat$default_outfile, ".xlsx")
progress_file_name = paste0(tadat$default_outfile, "_prog.RData")
desc <- writeNarrativeDataFrame(tadat)

# Remove all rows flagged for removal
dfs <-
list(Data = TADA::TADA_OrderCols(tadat$raw[!tadat$raw$TADA.Remove,]), Parameterization = desc)
writeFile(tadat, progress_file_name)
writexl::write_xlsx(dfs, path = datafile_name)
utils::zip(zipfile = fname,
files = c(datafile_name, progress_file_name))
},
contentType = "application/zip"
)

shiny::observeEvent(input$disclaimer, {
shiny::showModal(
Expand Down
Loading
Loading