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 8 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ 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
39 changes: 21 additions & 18 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 @@ -52,32 +53,34 @@ app_server <- function(input, output, session) {

# update the master 'Remove' column anytime data is added to the 'remove' table
shiny::observeEvent(tadat$removals, {
print("Updating removals column")
print(dim(tadat$removals))
print(sum(tadat$raw$TADA.Remove))
if (dim(tadat$removals)[2] > 0) {
print("Updating removals column")
tadat$raw$TADA.Remove <- apply(tadat$removals, 1, any)
}
print(sum(tadat$raw$TADA.Remove))
})

# 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
#})
}
59 changes: 39 additions & 20 deletions R/mod_TADA_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ mod_TADA_summary_server <- function(id, tadat) {
# calculate the stats needed to fill the summary box
shiny::observe({
shiny::req(tadat$raw)
print("Updating summary stats")
print(nrow(tadat$raw))
summary_things$rem_rec <-
length(tadat$raw$ResultIdentifier[tadat$raw$TADA.Remove ==
TRUE])
Expand All @@ -95,6 +97,7 @@ mod_TADA_summary_server <- function(id, tadat) {
length(unique(tadat$raw$MonitoringLocationIdentifier[!tadat$raw$MonitoringLocationIdentifier %in%
clean_sites]))
summary_things$removals <- sort_removals(tadat$removals)
print(nrow(tadat$raw))
})
summary_things$removals <- data.frame(matrix(
ncol = 2,
Expand All @@ -118,6 +121,8 @@ mod_TADA_summary_server <- function(id, tadat) {
if (is.null(tadat$raw)) {
"Total Results in Dataset: 0"
} else {
print("Updating result count")
print(nrow(tadat$raw))
paste0("Total Results in Dataset: ", scales::comma(length(tadat$raw$ResultIdentifier)))
}
})
Expand Down Expand Up @@ -171,14 +176,23 @@ 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({
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_ts <- 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 @@ -187,6 +201,7 @@ mod_TADA_summary_server <- function(id, tadat) {
datafile_name = paste0(tadat$default_outfile, ".xlsx")
progress_file_name = paste0(tadat$default_outfile, "_prog.RData")
desc <- writeNarrativeDataFrame(tadat)
out_data = TADA::TADA_OrderCols(tadat$raw[tadat$raw])
dfs <-
list(Data = TADA::TADA_OrderCols(tadat$raw), Parameterization = desc)
writeFile(tadat, progress_file_name)
Expand All @@ -197,22 +212,26 @@ 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)
dfs <-
list(Data = TADA::TADA_OrderCols(tadat$raw), 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
3 changes: 3 additions & 0 deletions R/mod_censored_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ mod_censored_data_server <- function(id, tadat) {
) # reset to detection quantitation limit value
tadat$raw$TADA.ResultMeasureValueDataTypes.Flag[tadat$raw$TADA.ResultMeasureValueDataTypes.Flag == "Result Value/Unit Estimated from Detection Limit"] <-
"Result Value/Unit Copied from Detection Limit" # reset data types flag to what it was before simpleCensoredMethods function run
# print(1234)
print(nrow(tadat$raw))
tadat$raw <- tadat$raw %>% dplyr::select(-TADA.CensoredMethod)
print(nrow(tadat$raw))
tadat$censor_applied = FALSE
})

Expand Down
Loading
Loading