0

I have an app that I where I want to ask a question up front in say a pop up dialogue box, have the question answered, have the box disappear, and then have my app run.

I have searched for over a week and have tried many things to no avail. I have tried just readline(). I have looked at ShinyBS but none of the examples are functioning. I have looked into tcltk2. While I didn't get any errors, nothing happened to include no dialogue box.

Here is a simple example of what I would like to do.

Suppose I just want a pop up box to ask, What is your name?

After the name is inputed, the box closes, and the app begins. Perhaps the app now says, Hello Name.

Please help me update the code below.

library(shiny)
library(tcltk2)
library(shinybs)

#Create pop up box asking name. Then substitute this value into XXX below.
ui <- shinyUI(fluidPage(

   # Application title
   titlePanel("Hello XXX, how are you?")


   )
)

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


   })


# Run the application 
shinyApp(ui = ui, server = server)
Scott Hunter
  • 254
  • 2
  • 14
  • What do you mean none of the are functioning? – shayaa Jul 25 '16 at 15:49
  • I'm sure you can re-write this http://stackoverflow.com/questions/28987622/starting-shiny-app-after-password-input/28997605#28997605 – Pork Chop Jul 25 '16 at 15:51
  • Pork Chop, this did help. It still took me the better part of the day, but I got it. Now off to the next problem. Thanks!! Shayaa, every link to each example in ShinyBS is dead (404 error). The links aren't functioning and I can't see any examples. – Scott Hunter Jul 26 '16 at 13:16

1 Answers1

0

For completeness, here is the code I wrote. This was gleaned from the link Pork Chop referenced. It works, although some parts I still don't understand.

library(shiny)

Logged = FALSE;

ui1 <- function(){
  tagList(
    div(id = "login",
        wellPanel(textInput("name", "Name"),
                  br(),actionButton("submit", "Submit"))),
    tags$style(type="text/css", "#login {font-size:10px;   text-align: left;position:absolute;top: 40%;left: 50%;margin-top: -100px;margin-left: -150px;}")
  )}

ui2 <- function(){fluidPage(

  # Application title
  titlePanel({
    fluidRow(column(12,
            textOutput("greeting")))


            })

)}


ui = (htmlOutput("page"))
server = (function(input, output,session) {

  USER <- reactiveValues(Logged = Logged)

  observe({ 
    if (USER$Logged == FALSE) {
      if (!is.null(input$submit)) {
        if (input$submit > 0) {
          Username <- isolate(input$name)
          if (length(Username) > 0 ) {

            USER$Logged <- TRUE

          }
        } 
      }
    }    
  })
  observe({
    if (USER$Logged == FALSE) {

      output$page <- renderUI({
        div(class="outer",do.call(bootstrapPage,c("",ui1())))
      })
    }
    if (USER$Logged == TRUE) 
    {
      output$page <- renderUI({
        div(class="outer",do.call(fluidPage,ui2()))
      })
      print(ui)
    }
  })

  output$greeting <- renderText({
    print(paste("Hello, how are you", " ", input$name,"?", sep = ""))
    })

})

runApp(list(ui = ui, server = server))
Scott Hunter
  • 254
  • 2
  • 14