datastorm-open / shinymanager

Simple and secure authentification mechanism for single shiny applications.
https://datastorm-open.github.io/shinymanager/
386 stars 79 forks source link

Move the location of the FAB logout/admin button #75

Closed ferguskeatinge closed 3 years ago

ferguskeatinge commented 3 years ago

Any way to move the location of the floating action logout/admin button?

Thanks.

pvictor commented 3 years ago

Currently, this is only doable in CSS by adding in your UI something like :

tags$style(
    "[tooltip]:before {left: 110% !important; right: auto !important}",
    ".container-fab {right: auto !important; left: 0 !important;}"
)

Logout button will appear on left.

Full example:

credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("123", "456"),
  stringsAsFactors = FALSE
)

library(shiny)
library(shinymanager)

ui <- fluidPage(
  tags$head(
    # Tooltip bouton shinymanager
    tags$style(
      "[tooltip]:before {left: 110% !important; right: auto !important}",
      ".container-fab {right: auto !important; left: 0 !important;}"
    )
  ),
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output")
)

# Wrap your UI with secure_app
ui <- secure_app(ui)

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

  res_auth <- secure_server(
    check_credentials = check_credentials(credentials)
  )

  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })

  # your classic server logic

}

shinyApp(ui, server)
howardbaek commented 3 years ago

@pvictor How do I position the FAB button on the top right corner?

pvictor commented 3 years ago

Not currently possible, we have to re-write the fab button functionnality. I'll let you know

nathanjones4323 commented 3 years ago

@howardbaek Thanks for asking this question ! I would like to do the same thing.

@pvictor Thanks for the response, this would be a wonderful addition !

pvictor commented 3 years ago

If you re-install from GitHub, there's a new argument fab_position in secure_app to specify FAB button position. Example:


credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("123", "456"),
  stringsAsFactors = FALSE
)

library(shiny)
library(shinymanager)

ui <- fluidPage(
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output")
)

# Wrap your UI with secure_app
ui <- secure_app(ui, fab_position = "top-right") # <- set position of FAB button here

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

  res_auth <- secure_server(
    check_credentials = check_credentials(credentials)
  )

  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })

  # your classic server logic

}

shinyApp(ui, server)

Victor