Вот всплывающее окно входа в систему, основанное на ? ModalDialog .
library("shiny")
shinyApp(
ui <- basicPage(
actionButton("login", "Login"),
verbatimTextOutput("secrets")
),
server <- function(input, output, session) {
vals <- reactiveValues(authenticated=FALSE)
passwordModal <- function(message=NULL) {
modalDialog(
textInput("username", "Username", input$username),
passwordInput("password", "Password", input$password),
if (!is.null(message)) div(tags$b(message, style="color: red;")),
footer = tagList(
modalButton("Cancel"),
actionButton("authenticate", "OK")
)
)
}
observeEvent(input$login, {
showModal(passwordModal())
})
observeEvent(input$authenticate, {
vals$authenticated <- FALSE
if (!is.null(input$username) && nzchar(input$username) &&
!is.null(input$password) && nzchar(input$password)) {
removeModal()
if (input$password == "letmein") {
vals$authenticated <- TRUE
} else {
showModal(passwordModal(message="Incorrect password!"))
}
} else {
showModal(passwordModal(message="Please fill in your username and password"))
}
})
output$secrets <- renderText({
if (vals$authenticated) {
paste("Don't tell anyone, ", input$username, ", but...", sep="")
} else {
"I can't tell you that!"
}
})
}
)