Skip to content

Commit

Permalink
Remaining shinyalert calls substituted agains shinyWidgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
janlisec committed Mar 28, 2024
1 parent 2470acf commit bd342c3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 39 deletions.
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand All @@ -26,7 +26,6 @@ LazyData: true
LazyDataCompression: bzip2
Depends:
R (>= 3.5.0)
Remotes: github::daattali/shinyalert
Imports:
config,
DT,
Expand All @@ -41,7 +40,6 @@ Imports:
R6,
rmarkdown,
shiny,
shinyalert (>= 3.0.0.9000),
shinyjs,
shinyWidgets,
tidyxl
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion R/app_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions R/fnc_list2rv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions R/fnc_read_zenodo.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Expand Down
39 changes: 20 additions & 19 deletions R/m_Rdata_import.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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()) }
})

})

Expand Down
10 changes: 5 additions & 5 deletions R/page_LTS.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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")) {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit bd342c3

Please sign in to comment.