shinymanager
shinymanager copied to clipboard
Back to the app from admin mode without fab_button
Hi!
I'm using shinymanager in a app served company-wide. Using shinydashboardPlus, I created custom buttons for logout and enter admin mode in the user profile menu, setting the fab-button (position="none), as this way is more intuitive for my users. Both buttons works great.
in app_ui.R:
secured_ui <- shinymanager::secure_app(
app_ui,
enable_admin = T,
fab_position = 'none',
language = "es",
tags_top =
tags$div(
golem_add_external_resources(),
tags$h2("My app", style = "align:center"),
tags$br(),
tags$img(src = "www/appLogo.png", width = 150),
tags$br()
)
)
in app_server.R:
output$user <- shinydashboardPlus::renderUser(
shinydashboardPlus::dashboardUser(
name = creds_reactive()$user,
image = "www/user_icon.png",
title = NULL,
subtitle = paste0("Grupo: ", creds_reactive()$userGroup),
footer = NULL,
column( width = 12,
shinydashboardPlus::dashboardUserItem(actionButton(".shinymanager_logout", label = "Cerrar sesión"), width = 6),
if(creds_reactive()$admin) {
shinydashboardPlus::dashboardUserItem(actionButton(".shinymanager_admin", label = "Administración"), width = 6)
} else {NULL}
)
)
)
The issue arise when I want to come back from the admin mode to the main app given that the only way was using the fab_button and now this is not shown. I think it would be useful to have another button/link to go back to app in the admin ui for those cases where fab_button is hide.
Anyway, could I add a button for such a task from my code into the admin ui (maybe using shinyjs)? Or any other workaround?
Thanks for this awesome package,
Andrés.
Hi again, I've solved this issue with the following workaround in app_server.R (and keeping fab_position="none"):
observe({
if (!is.null(input$shinymanager_where) &&
input$shinymanager_where %in% "admin"
) {
insertUI(selector = ".container-fluid",
where = "beforeEnd",
ui = fab_button(position = "bottom-left",
actionButton(
inputId = ".shinymanager_app",
label = NULL,
icon = icon("share")
))
)
}
})
However, I think it would be nice to have a "native" solution to go back to te app from the admin console when fab_position="none".
Cheers! Andrés.