From bd342c3f5cdff4fcf0845d97bad788d3214c486e Mon Sep 17 00:00:00 2001 From: janlisec Date: Thu, 28 Mar 2024 09:12:46 +0100 Subject: [PATCH] Remaining `shinyalert` calls substituted agains `shinyWidgets`. --- DESCRIPTION | 6 ++---- NAMESPACE | 1 - R/app_utils.R | 1 - R/fnc_list2rv.R | 9 +++------ R/fnc_read_zenodo.R | 5 ++--- R/m_Rdata_import.R | 39 ++++++++++++++++++++------------------- R/page_LTS.R | 10 +++++----- 7 files changed, 32 insertions(+), 39 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 23f46d2..c273c78 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: eCerto Title: Statistical Tests for the Production of Reference Materials -Version: 0.2.14 -Date: 2024-03-21 +Version: 0.2.15 +Date: 2024-03-28 Authors@R: c( person("Jan", "Lisec", , "jan.lisec@bam.de", role = c("cre", "aut"), comment = c(ORCID = "0000-0003-1220-2286")), @@ -26,7 +26,6 @@ LazyData: true LazyDataCompression: bzip2 Depends: R (>= 3.5.0) -Remotes: github::daattali/shinyalert Imports: config, DT, @@ -41,7 +40,6 @@ Imports: R6, rmarkdown, shiny, - shinyalert (>= 3.0.0.9000), shinyjs, shinyWidgets, tidyxl diff --git a/NAMESPACE b/NAMESPACE index 5dd864c..5237701 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,7 +29,6 @@ importFrom(purrr,pluck) importFrom(shiny,shinyApp) importFrom(shinyWidgets,dropdownButton) importFrom(shinyWidgets,show_alert) -importFrom(shinyalert,shinyalert) importFrom(shinyjs,useShinyjs) importFrom(stats,rnorm) importFrom(stats,sd) diff --git a/R/app_utils.R b/R/app_utils.R index 491e982..1ef5eb5 100644 --- a/R/app_utils.R +++ b/R/app_utils.R @@ -51,7 +51,6 @@ getValue <- function(df, key = NULL) { #' @param filepath the path to a single or multiple excel file(s) #' @return the names of sheets #' @importFrom openxlsx getSheetNames -#' @importFrom shinyalert shinyalert #' @importFrom tools file_ext #' @noRd #' @keywords internal diff --git a/R/fnc_list2rv.R b/R/fnc_list2rv.R index e4c3af9..17a1f18 100644 --- a/R/fnc_list2rv.R +++ b/R/fnc_list2rv.R @@ -57,11 +57,7 @@ list2rv <- function(x = NULL) { paste(err, collapse=", ") ) if (!is.null(shiny::getDefaultReactiveDomain())) { - shinyalert::shinyalert( - title = "m_RDataImport_Server", - text = err_msg, - type = "warning" - ) + shinyWidgets::show_alert(title="m_RDataImport_Server", text = err_msg, type = "warning") } else { warning(err_msg) } @@ -123,7 +119,8 @@ list2rv <- function(x = NULL) { } setValue(rv, c("General","time_stamp"), Sys.time()) if (!is.null(shiny::getDefaultReactiveDomain())) { - shinyalert::shinyalert( + shinyWidgets::show_alert( + title=NULL, text = paste("This is an import from a previous data format.", "Please note that some additional parameters are available", "in the current version of eCerto which could not be restored", diff --git a/R/fnc_read_zenodo.R b/R/fnc_read_zenodo.R index e4ad0f5..1a3071d 100644 --- a/R/fnc_read_zenodo.R +++ b/R/fnc_read_zenodo.R @@ -47,19 +47,18 @@ read_zenodo <- function(id) { if (interactive()) { message("Sorry, something went wrong upon download. :/") } else { - shinyalert::shinyalert(type = "error", text = "Sorry, something went wrong upon download. :/", closeOnClickOutside = TRUE) + shinyWidgets::show_alert(title=NULL, type = "error", text = "Sorry, something went wrong upon download. :/", closeOnClickOutside = TRUE) } } else { return(check_RData(x = dest)) } - } else { if (interactive()) { message("Sorry, could not find this Zenodo ID. :/") } else { - shinyalert::shinyalert(type = "error", text = "Sorry, could not find this Zenodo ID. :/", closeOnClickOutside = TRUE) + shinyWidgets::show_alert(title=NULL, type = "error", text = "Sorry, could not find this Zenodo ID. :/", closeOnClickOutside = TRUE) } } diff --git a/R/m_Rdata_import.R b/R/m_Rdata_import.R index f1ea1c3..1ae7492 100644 --- a/R/m_Rdata_import.R +++ b/R/m_Rdata_import.R @@ -82,29 +82,29 @@ m_RDataImport_Server = function(id, rv) { if (all(!rv$e_present())) { load_test_data() } else { - shinyalert::shinyalert( - title = "Test Data", confirmButtonText = "Load", showCancelButton = TRUE, size = "xs", html = TRUE, - text = shiny::tagList(div_check_present()), - callbackR = function(value) { - if (value) { load_test_data() } - } + shinyWidgets::ask_confirmation( + inputId = "confirm_load_test_data", + title = "Test Data", btn_labels = c("Cancel", "Load"), size = "xs", html = TRUE, + text = shiny::tagList(div_check_present()) ) } }) + shiny::observeEvent(input$confirm_load_test_data, { + if (input$confirm_load_test_data) { load_test_data() } + }) # Load Zenodo Data --------------------------------------------------------- shiny::observeEvent(input$load_zenodo_data, { - shinyalert::shinyalert( - title = "Zenodo Import", confirmButtonText = "Load", showCancelButton = TRUE, size = "xs", html = TRUE, + + shinyWidgets::ask_confirmation( + inputId = "confirm_load_zenodo_data", + title = "Zenodo Import", btn_labels = c("Cancel", "Load"), size = "xs", html = TRUE, text = shiny::tagList(div_check_present(), shiny::textInput(inputId = session$ns("z_id"), label = "Enter Zonodo Record ID", value = "8380870")), - callbackR = function(value) { - if (value) { - x <- read_zenodo(input$z_id) - load_test_data(x = x) - } - } ) }) + shiny::observeEvent(input$confirm_load_zenodo_data, { + if (input$confirm_load_zenodo_data) { load_test_data(x = read_zenodo(input$z_id)) } + }) # Load Backup Data --------------------------------------------------------- rdata <- shiny::eventReactive(input$in_file_ecerto_backup, { @@ -115,15 +115,16 @@ m_RDataImport_Server = function(id, rv) { if (all(!rv$e_present())) { load_test_data(x = rdata()) } else { - shinyalert::shinyalert( - title = "RData Import", confirmButtonText = "Load", showCancelButton = TRUE, size = "xs", html = TRUE, + shinyWidgets::ask_confirmation( + inputId = "confirm_load_rdata", + title = "RData Import", btn_labels = c("Cancel", "Load"), size = "xs", html = TRUE, text = shiny::tagList(div_check_present()), - callbackR = function(value) { - if (value) { load_test_data(x = rdata()) } - } ) } }) + shiny::observeEvent(input$confirm_load_rdata, { + if (input$confirm_load_zenodo_data) { load_test_data(x = rdata()) } + }) }) diff --git a/R/page_LTS.R b/R/page_LTS.R index e68d40c..f780370 100644 --- a/R/page_LTS.R +++ b/R/page_LTS.R @@ -114,7 +114,7 @@ m_longtermstabilityServer = function(id) { if (!is.null(input$LTS_input_file)) { file.type <- tools::file_ext(input$LTS_input_file$datapath) if (!tolower(file.type) %in% c("rdata","xls","xlsx")) { - shinyalert::shinyalert(title = "Wrong Filetype?", text = "Please select an RData file or an Excel file.", type = "warning") + shinyWidgets::show_alert(title = "Wrong Filetype?", text = "Please select an RData file or an Excel file.", type = "warning") return(NULL) } if (tolower(file.type)=="rdata") { @@ -134,12 +134,12 @@ m_longtermstabilityServer = function(id) { check_val_cols <- val_cols %in% colnames(LTS_dat[[i]][["val"]]) if (!all(check_def_cols)) { warn_txt <- paste0("Can't find the following columns in input file", i, " 'definition' part: ", paste(def_cols[!check_def_cols], collapse=", ")) - shinyalert::shinyalert(title = "Warning", text = warn_txt, type = "warning") + shinyWidgets::show_alert(title = "Warning", text = warn_txt, type = "warning") LTS_dat[[i]][["def"]] <- cbind(LTS_dat[[i]][["def"]], as.data.frame(matrix(NA, ncol=sum(!check_def_cols), nrow=1, dimnames=list(NULL,def_cols[!check_def_cols])))) } if (!all(check_val_cols)) { warn_txt <- paste0("Can't find the following columns in input file", i, " 'definition' part: ", paste(val_cols[!check_val_cols], collapse=", ")) - shinyalert::shinyalert(title = "Warning", text = warn_txt, type = "warning") + shinyWidgets::show_alert(title = "Warning", text = warn_txt, type = "warning") } if (!"Comment" %in% colnames(LTS_dat[[i]][["val"]])) LTS_dat[[i]][["val"]] <- cbind(LTS_dat[[i]][["val"]], "Comment"=as.character(rep(NA, nrow(LTS_dat[[i]][["val"]])))) if (!inherits(LTS_dat[[i]][["val"]][,"Date"], "Date")) { @@ -321,7 +321,7 @@ m_longtermstabilityServer = function(id) { a <- shiny::nearPoints(d(), input$plot1_click, xvar = "mon", yvar = "vals", addDist = TRUE, threshold = 10) # 2/3 index in table if (nrow(a)>=2) { - shinyalert::shinyalert(title = "Warning", text = "More than one data point in proximity to click event. Please cross check with table entry if correct data point is selected.", type = "warning") + shinyWidgets::show_alert(title = "Warning", text = "More than one data point in proximity to click event. Please cross check with table entry if correct data point is selected.", type = "warning") a <- a[which.min(a[,"dist_"])[1],] } idx <- which(d()$mon==a$mon & d()$vals==a$vals) @@ -347,7 +347,7 @@ m_longtermstabilityServer = function(id) { tmp <- datalist$lts_data[[i()]][["val"]] nval <- LTS_tmp_val() if (nval$Date < max(tmp$Date)) { - shinyalert::shinyalert(title = "Warning", text = "You added a data point for an earlier date. Resorting the table accordingly.", type = "warning") + shinyWidgets::show_alert(title = "Warning", text = "You added a data point for an earlier date. Resorting the table accordingly.", type = "warning") ord <- order(c(tmp$Date, nval$Date)) } else { ord <- 1:(nrow(tmp)+1)