18910140161

Shiny::ShowModal不适用于ShinyManager

顺晟科技

2021-09-14 12:45:25

83

我在使用shiny::showModal的应用程序中插入了shinymanager。但是,身份验证会因为模式而停止工作。

运行以下代码:

library(shiny)
library(shinydashboard)
library(shinymanager)

# Credentials as data.frame
credentials <- data.frame(
  user = c("shiny", "shinymanager"), # mandatory
  password = c("azerty", "12345"), # mandatory
  stringsAsFactors = FALSE
)

# Change labels
set_labels(
  language = "en",
  "Please authenticate" = "Bitte authentifizieren",
  "Username:" = "Benutzername:",
  "Password:" = "Passwort:",
  "Login" = "Anmeldung"
)

# Classic shinydashboard
ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(),
  title = "Dashboard example"
)


# Wrap your UI with secure_app
ui <- secure_app(
  ui = ui,
  tags_top = 
    tags$div(
      tags$h4("Demo", style = "align:center"),
      tags$img(
        src = "https://www.r-project.org/logo/Rlogo.png", width = 100
      )
    ),
  # add information on bottom ?
  tags_bottom = tags$div(
    tags$p(
      "For any question, please  contact ",
      tags$a(
        href = "mailto:someone@example.com?Subject=Shiny%20aManager",
        target="_top", "administrator"
      )
    )
  )
)

# Server
server <- function(input, output, session) {

  observeEvent("", {
    showModal(modalDialog(
      includeHTML("intro_text.html"),
      easyClose = TRUE,
      footer = tagList(
        actionButton(inputId = "intro", label = "OK", icon = icon("info-circle"))
      )
    ))
  })
  
  observeEvent(input$intro,{
    removeModal()
  })
  
  # With creadentials data.frame (for the example)
  res_auth <- secure_server(
    check_credentials = check_credentials(credentials)
  )
  
}

shinyApp(ui, server)

登录屏幕:

这里有intro_text.html文件。

我尝试在observeEvent函数中使用observeEvent(如本答案中所示),但没有帮助。


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航