Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set list of files format allowed #51

Closed
erifa1 opened this issue Jul 22, 2022 · 3 comments
Closed

Set list of files format allowed #51

erifa1 opened this issue Jul 22, 2022 · 3 comments

Comments

@erifa1
Copy link

erifa1 commented Jul 22, 2022

Hi

Is it possible to have an argument file_extensions in the import_modal() function to control list of possible file formats allowed?

Thanks!
Etienne

@pvictor
Copy link
Member

pvictor commented Sep 1, 2022

Thanks for the suggestion.
import_modal() has now a file_extensions argument, re-install from CRAN to have last version.

Victor

@pvictor pvictor closed this as completed Sep 1, 2022
@erifa1
Copy link
Author

erifa1 commented Oct 6, 2022

Hello

Just a feedback, file_extensions keep default value when from argument is set only on "file" value.

Thanks again

See:

library(shiny)
library(datamods)

ui <- fluidPage(
  # Try with different Bootstrap version
  # theme = bslib::bs_theme(version = 4),
  fluidRow(
    column(
      width = 4,
      checkboxGroupInput(
        inputId = "from",
        label = "From",
        choices = c("env", "file", "copypaste", "googlesheets", "url"),
        selected = c("file", "copypaste")
      ),
      actionButton("launch_modal", "Launch modal window")
    ),
    column(
      width = 8,
      tags$b("Imported data:"),
      verbatimTextOutput(outputId = "name"),
      verbatimTextOutput(outputId = "data")
    )
  )
)

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

  observeEvent(input$launch_modal, {
    req(input$from)
    import_modal(
      id = "myid",
      from = input$from,
      file_extensions = c(".tsv", ".rdata", ".xls"),
      title = "Import data to be used in application"
    )
  })

  imported <- import_server("myid", return_class = "tbl_df")

  output$name <- renderPrint({
    req(imported$name())
    imported$name()
  })

  output$data <- renderPrint({
    req(imported$data())
    imported$data()
  })
}

if (interactive())
  shinyApp(ui, server)

@pvictor
Copy link
Member

pvictor commented Oct 6, 2022

Thanks that's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants