BACKGROUND
I'm building a shiny dashboard in Data Science Studio where a user has to choose a file they want to process from the selectizeInput
and then press Submit actionButton
. Once the button is pressed, it starts a backend process to determine what category the file falls into and what workflow it should follow (different workflows contain different cleaning steps and final outputs). Once the workflow completes, I want to display the final output in DT::renderDataTable
.
DESIRED OUTPUT
I would like my shiny app to
- show no data before the input is chosen
- time, let's say, 30 seconds from the moment someone clicks the Submit button to actually picking up the dataset
MINIMAL WORKING EXAMPLE
How could I implement it in this simple app?
UI
library(shiny)
library(shinydashboard)
library(DT)
library(dataiku)
path <- dkuManagedFolderPath("receiver") #folder with the files to choose from
dashboardPage(
dashboardHeader(title = "Catchy Title"),
dashboardSidebar(
selectizeInput("file", "Select File",
list.files(path)),
actionButton("submit", "Submit")
),
dashboardBody(
fluidRow(
box(h2("Show Data"),
div(style = 'overflow-x: scroll', DT::dataTableOutput('mytable')),
width = 12)
)
)
)
SERVER
library(dataiku)
library(shiny)
library(shinydashboard)
library(DT)
library(dplyr)
shinyServer(function(input, output) {
file_name <- reactive({
req(input$file)
})
####
# run the process that takes the file name to pass it to
# the global environment, which triggers the conditional workflow
# and may result in different data outputs
####
## AFTER the process runs (approx. 30 seconds after pressing the submit button)
# I want the shiny app to follow this logic:
if(is.null(nrow(try(dkuReadDataset("intermediate_dataset"))[1]))){
df <- dkuReadDataset("final_data1")
} else{
df <- dkuReadDataset("final_data2")
}
output$mytable = DT::renderDataTable({
df
})
})
Thanks for the hints!