Ifeanyi's picture
Update app.R
2de1ded verified
library(shiny)
library(shinyjs)
library(shinyWidgets)
library(shinythemes)
library(GWalkR)
ui <- fluidPage(
includeCSS("styles.css"),
useShinyjs(),
setBackgroundColor(color = c("white","#007acc"),gradient = c("linear","radial")),
title = "Data Explorer",
theme = shinytheme("cerulean"),
tags$h3(id = "title", tags$strong("Graphic-Walker Data Explorer"),style = "text-align:center;color:#007acc;"),
tags$a(href = "https://github.com/Ifeanyi55", tags$strong("Maintainer"),target = "_blank",style = "text-decoration:none;color:#007acc;margin-left:1250px;margin-bottom:1000px"),
br(),br(),
sidebarLayout(sidebarPanel = "",
mainPanel(align = "center",
width = 12,
fileInput("target_upload",h5(strong("Click to Upload CSV File"),style = "color:#007acc;"),
accept = c("text/csv"),
buttonLabel = strong("Select File",style = "color:#007acc;"),
placeholder = "No file selected"),
actionButton("reset",strong("Reset"),icon = icon("refresh"),style = "color:#007acc;"),
a(href = "https://github.com/Kanaries/GWalkR",h6(strong("Learn More"),style = "color:#007acc;margin-left:-1220px;margin-top:-170px;font-size:15px;"),target = "_blank",style = "text-decoration: none;"),
gwalkrOutput(outputId = "explorer",width = "101%")
)
)
)
server <- function(input,output,session){
# increase file upload size to 100MB
options(shiny.maxRequestSize = 100 * 1024^2)
file_upload <- reactive({
inFile <- input$target_upload
if(is.null(inFile)){return(NULL)}
data <- read.csv(inFile$datapath,header = TRUE,sep = ",")
return(data)
})
output$explorer <- renderGwalkr({
tryCatch(
{
gwalkr(file_upload())
},
error = function(e){
message("Could not display interface")
}
)
})
# refresh app
observeEvent(input$reset,{
runjs("location.reload();")
})
}
shinyApp(ui,server)