JohnCoene / firebase

Google FIrebase for shiny
https://firebase.john-coene.com
GNU Affero General Public License v3.0
170 stars 26 forks source link

How to embed it in other page frame?(e.g. bs4dash) #1

Closed bianchenhao closed 1 year ago

bianchenhao commented 4 years ago

I try the code below,but it dosen't work.

library(bs4Dash)
library(shiny)
library(firebase)

ui <- bs4DashPage(
  useFirebase(),
  useFirebaseUI(),
  title = "test",
  navbar = bs4DashNavbar(),
  sidebar = bs4DashSidebar(
    skin = "light",
    title = "test"),
  controlbar = bs4DashControlbar(),
  footer = bs4DashFooter(),
  body = bs4DashBody()
)

server <- function(input, output, session) {
  f <- FirebaseUI$
    new("session")$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )$
    launch() # launch
}

shinyApp(ui, server)

I try another way, it dosen't work either.

ui <- fluidPage(
  useFirebase(),
  useFirebaseUI(),
  reqSignin(bs4DashPage(
    title = "test",
    navbar = bs4DashNavbar(),
    sidebar = bs4DashSidebar(
      skin = "light",
      title = "test"),
    controlbar = bs4DashControlbar(),
    footer = bs4DashFooter(),
    body = bs4DashBody()
  )))
bianchenhao commented 4 years ago

The code below works, but page turns ugly.

library(bs4Dash)
library(shiny)
library(firebase)

ui <- fluidPage(
  useFirebase(),
  useFirebaseUI(),
  uiOutput("ui1")
  )

server <- function(input, output, session) {
  f <- FirebaseUI$
    new("session")$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )$
    launch() # launch

  output$ui1 <- renderUI({
    f$req_sign_in() # require sign in
    bs4DashPage(
      title = "test",
      navbar = bs4DashNavbar(),
      sidebar = bs4DashSidebar(
        skin = "light",
        title = "test"),
      controlbar = bs4DashControlbar(),
      footer = bs4DashFooter(),
      body = bs4DashBody()
    )
  })

}

shinyApp(ui, server)

image

gesorabill commented 3 years ago

Hey, Did you ever find a solution to this? I noticed adding a usebs4Dash() in your second solution brings a better look of the app. See below `library(bs4Dash) library(shiny) library(firebase)

ui <- fluidPage( useBs4Dash(), useFirebase(), useFirebaseUI(), uiOutput("ui1") )

server <- function(input, output, session) { f <- FirebaseUI$ new("session")$ # instantiate set_providers( # define providers email = TRUE, google = TRUE )$ launch() # launch

output$ui1 <- renderUI({ f$req_sign_in() # require sign in bs4DashPage( title = "test", navbar = bs4DashNavbar(), sidebar = bs4DashSidebar( skin = "light", title = "test"), controlbar = bs4DashControlbar(), footer = bs4DashFooter(), body = bs4DashBody() ) })

}

shinyApp(ui, server)`

diwashrestha commented 3 years ago

Do you Find any solution for this problem?

kennedymwavu commented 1 year ago

This is not an issue with {firebase}. You can place the firebase UI container in bs4DashBody:

ui <- bs4Dash::bs4DashPage(
  title = "test",
  header = bs4Dash::bs4DashNavbar(),
  sidebar = bs4Dash::bs4DashSidebar(
    skin = "light",
    title = "test"),
  controlbar = bs4Dash::bs4DashControlbar(),
  footer = bs4Dash::bs4DashFooter(),
  body = bs4Dash::bs4DashBody(
    firebase::useFirebase(),
    firebase::useFirebaseUI(),
    firebase::firebaseUIContainer()
  )
)

server <- function(input, output, session) {
  f <- firebase::FirebaseUI$
    new("session")$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )$
    launch() # launch
}

shiny::shinyApp(ui, server)

image