简体   繁体   中英

Save and load all the settings a user sets in a Shiny app

I have a simple shiny app below in which the user can make some choices using those widgets. Is it possible to save and load all the settings as the user will set in the Shiny App, so that he can open the app the next time and load these same settings from a location on his computer, which then causes the app to change its settings immediately to how it used to be before?

#ui.r
navbarPage(
  "Application",
  tabPanel("General",
           sidebarLayout(

             sidebarPanel(
               uiOutput("tex1"),
               br(),
               uiOutput("num"),
               br(),

               uiOutput("num2")
              ),



             mainPanel(
               wellPanel(
                 h4("Format"),
                 fluidRow( # Width = sum of component columns
                   tags$style(type="text/css",
                              ".shiny-output-error { visibility: hidden; }",
                              ".shiny-output-error:before { visibility: hidden; }"
                   ),
                   column(3,
                          h5("Booklet ID"),
                          div(style="display: inline-block;vertical-align:top; width: 150px;",uiOutput("num3"))


                   )
                 )
                 )



             )
           )))





#server.r
library(shiny)


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

  output$tex1<-renderUI({
    textInput("text", h4("Run Name") 
    )
  })
  output$num<-renderUI({
    numericInput("nm", 
                 h4("Items"), 
                 value = 50,min = 1)
  })
  output$num2<-renderUI({
    numericInput("nm2", 
                 h4("Dimensions"), 
                 value = 1,min = 0,max = max(input$nm))
  })
  output$num3<-renderUI({
    textInput("nm3", 
              h6("Column"), 
              value = 1)
  })







}

Yes, it is possible with bookmarking: https://shiny.rstudio.com/articles/bookmarking-state.html .

shinyApp() has a parameter enableBookmarking . If you set it to url , you can create a link and visit the page at the state it had at the bookmark creation.

在此处输入图片说明

Note: You can also save the state of the app to disk, if you set the enableBookmarking parameter to server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM