Skip to content

Commit

Permalink
the upload field is now added as plain text for the serverless version
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad1991 committed Dec 19, 2024
1 parent 3cb9754 commit d7c9c05
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
40 changes: 19 additions & 21 deletions bs/R/MainApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@ js_scripts <- function() {
}
}

upload_ui_field <- function() {
if (Sys.getenv("RUN_MODE") != "SERVER") {
res <- conditionalPanel(
condition = "input.conditionedPanels == 'Data'",
fileInput("file", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
)
)
)
return(res)
}
}

app <- function() {
js <- js_scripts()
uploadUIField <- upload_ui_field()
ui <- fluidPage(
useShinyjs(),
js,
Expand Down Expand Up @@ -120,11 +137,12 @@ app <- function() {
uiOutput("open_split_by_group"),
uiOutput("data_splitted"),
verbatimTextOutput("applied_filter"),
uiOutput("conditional_data_ui"),
br(),
div(
conditionalPanel(
condition = "input.conditionedPanels == 'Data'",
# uiOutput("conditional_data_ui"),
uploadUIField,
tags$hr()
),
conditionalPanel(
Expand Down Expand Up @@ -351,26 +369,6 @@ app <- function() {
))
})

# TODO: not needed anymore?
output$conditional_data_ui <- renderUI({
if (Sys.getenv("RUN_MODE") != "SERVER") {
res <- div(
class = "var-box-output",
conditionalPanel(
condition = "input.conditionedPanels == 'Data'",
fileInput("file", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
)
)
)
)
return(res)
}
})

download_file <- reactive({
file <- download(session, "/home/shiny/results") # NOTE: from COMELN
df <- NULL
Expand Down
10 changes: 9 additions & 1 deletion deploy_serverless_app.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Copy R files from bs
# ========================================
files <- list.files("./bs/R", pattern = ".R", full.names = TRUE)
file.copy(files, "./app/")
file.copy(files, "./app/", overwrite = TRUE)

file <- "./app/MainApp.R"
content <- readLines(file)
content <- gsub("uploadUIField",
"fileInput(\"file\", \"Choose CSV File\",\n accept = c(\n \"text/csv\",\n \"text/comma-separated-values,text/plain\",\n \".csv\"\n )\n ),\n",
content)
writeLines(content, file)


# Copy www files from bs
# ========================================
Expand Down

0 comments on commit d7c9c05

Please sign in to comment.