Skip to content

Commit

Permalink
Open an alert window when clicking on buttons (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Nov 12, 2019
1 parent 7e2f5b3 commit c70b8c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ importFrom(methods,setClassUnion)
importFrom(methods,setGeneric)
importFrom(methods,setMethod)
importFrom(rlang,.data)
importFrom(shinyWidgets,dropdownButton)
importFrom(shinyWidgets,pickerInput)
importFrom(shinyWidgets,sendSweetAlert)
importFrom(shinyWidgets,updatePickerInput)
2 changes: 1 addition & 1 deletion R/gamma-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"_PACKAGE"

#' @import shiny
#' @importFrom shinyWidgets dropdownButton pickerInput updatePickerInput
#' @importFrom shinyWidgets pickerInput sendSweetAlert updatePickerInput
#' @importFrom methods as new setClass setClassUnion setGeneric setMethod
#' @importFrom graphics plot
#' @importFrom ggplot2 aes facet_wrap geom_errorbar geom_errorbarh
Expand Down
23 changes: 18 additions & 5 deletions R/shiny_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,30 @@ shiny_server <- function(input, output, session) {
spc_calib <- try(calibrate_energy(spc, peaks))
# Update spectrum
if (class(spc_calib) == "try-error") {
showModal(modalDialog(
title = "Energy calibration",
spc_calib,
easyClose = TRUE
))
shinyWidgets::sendSweetAlert(
session = session,
title = "Error",
text = spc_calib,
type = "error"
)
} else {
myData$spectra[[input$calib_select]] <- spc_calib
shinyWidgets::sendSweetAlert(
session = session,
title = "Success",
text = "The enegy scale has been adjusted.",
type = "success"
)
}
})
observeEvent(input$calib_reset, {
myData$spectra[[input$calib_select]] <- myData$raw[[input$calib_select]]
shinyWidgets::sendSweetAlert(
session = session,
title = "Info",
text = "The energy scale has been restored to its original values.",
type = "info"
)
})
# Render ---------------------------------------------------------------------
output$calib_plot_peaks <- renderPlot(
Expand Down

0 comments on commit c70b8c4

Please sign in to comment.