Commit 34260c1d authored by Midoux Cedric's avatar Midoux Cedric

downloadData

parent c1ce19e5
...@@ -163,17 +163,31 @@ observeEvent(input$okData, { ...@@ -163,17 +163,31 @@ observeEvent(input$okData, {
} }
}) })
output$downloadData <- { dataDownload <- function() {
downloadHandler( modalDialog(
filename = function() { title = "Download data",
paste("Easy16S-data", Sys.Date(), "RData", sep = ".") size = "s",
}, textInput("dataName", "File name : ", value = paste("Easy16S-data", Sys.Date(), sep = "-")),
content = function(file) { radioButtons("dataFormat", "File format : ", choices = c("RData", "biom"), selected = "RData", inline = TRUE),
footer = tagList(modalButton("Cancel"),
downloadButton("okDownload", "Download")
)
)
}
output$okDownload <- downloadHandler(
filename = function() {
paste(input$dataName, input$dataFormat, sep = ".")
},
content = function(file) {
if (input$dataFormat == "RData") {
data <- physeq() data <- physeq()
save(data, file = file) save(data, file = file)
} else if (input$dataFormat == "biom") {
write_phyloseq(physeq = physeq(), biom_file = file, biom_format = "frogs") #"standard"
} }
) }
} )
plotDownload <- function() { plotDownload <- function() {
modalDialog( modalDialog(
...@@ -183,7 +197,7 @@ plotDownload <- function() { ...@@ -183,7 +197,7 @@ plotDownload <- function() {
numericInput("plotWidth", "Width : ", value = 7), numericInput("plotWidth", "Width : ", value = 7),
numericInput("plotHeight", "Height : ", value = 7), numericInput("plotHeight", "Height : ", value = 7),
numericInput("plotDPI", "DPI : ", value = 300), numericInput("plotDPI", "DPI : ", value = 300),
radioButtons("plotFormat", "File format : ", choices = c("png", "pdf", "jpeg", "svg", "wmf"), selected = 1, inline = TRUE), radioButtons("plotFormat", "File format : ", choices = c("png", "pdf", "jpeg", "svg", "wmf"), selected = "png", inline = TRUE),
footer = tagList(modalButton("Cancel"), footer = tagList(modalButton("Cancel"),
downloadButton("okPlot", "Download") downloadButton("okPlot", "Download")
) )
......
...@@ -34,6 +34,10 @@ shinyServer ...@@ -34,6 +34,10 @@ shinyServer
showModal(dataInput()) showModal(dataInput())
}) })
observeEvent(input$downloadButton, {
showModal(dataDownload())
})
observeEvent(input$plotButton, { observeEvent(input$plotButton, {
showModal(plotDownload()) showModal(plotDownload())
}) })
......
...@@ -20,9 +20,9 @@ dashboardHeader(title = "Easy16S"), ...@@ -20,9 +20,9 @@ dashboardHeader(title = "Easy16S"),
"Select your data", "Select your data",
icon = icon("upload"), icon = icon("upload"),
style = "width: 80% ; color: black ; background-color: gray90"), style = "width: 80% ; color: black ; background-color: gray90"),
downloadButton("downloadData", actionButton("downloadButton",
"Download data as RData", "Download data",
icon = icon("download"), icon = icon("download"),
style = "width: 80% ; color: black ; background-color: gray90"), style = "width: 80% ; color: black ; background-color: gray90"),
actionButton("plotButton", actionButton("plotButton",
"Download last plot", "Download last plot",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment