From 96394afadb0cbe35af85ff9c782e2addded1eda7 Mon Sep 17 00:00:00 2001
From: Midoux Cedric <cedric.midoux@irstea.fr>
Date: Tue, 4 Dec 2018 11:00:44 +0100
Subject: [PATCH] Revert "download the last plot"

This reverts commit 77c6fbbe004a52193040ad7eae5ce4ca763f3dee.
---
 server.R | 61 ++++++++++++++++----------------------------------------
 ui.R     |  3 +--
 2 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/server.R b/server.R
index fe2d573..c3c9072 100644
--- a/server.R
+++ b/server.R
@@ -1,4 +1,4 @@
-options(shiny.maxRequestSize = 30 * 1024 ^ 2)
+options(shiny.maxRequestSize = 30*1024^2)
 
 library(shinydashboard)
 library(dplyr)
@@ -152,66 +152,39 @@ shinyServer
     )
   }
   
-  output$downloadDataUI <- renderUI({
+  output$downloadUI <- renderUI({
     validate(need(data16S(), ""))
     tags$div(
       style = "text-align:center",
       title = "Download file as RData",
-      hr(),
       downloadButton("downloadData", "Download RData file", style = "color: black; background-color: gray90")
     )
   })
   
-  # current_plot <- reactive({last_plot()})
-  
-  output$downloadPlotUI <- renderUI({
-    # validate(need(current_plot(), "azerty"))
-    tags$div(
-      style = "text-align:center",
-      title = "Download the last plot",
-      downloadButton("downloadPlot", "Download the last plot", style = "color: black; background-color: gray90")
-    )
-  })
-  
-  output$downloadPlot <- {
-    downloadHandler(
-      filename = function() {
-        paste("Easy16S-plot",
-              ifelse(is.null(input$plotDevice), "png", input$plotDevice),
-              sep = ".")
-      },
-      content = function(file) {
-        ggsave(
-          file,
-          last_plot(),
-          device = ifelse(is.null(input$plotDevice), "png", input$plotDevice),
-          units = "cm",
-          width = ifelse(is.null(input$plotWidth), NA, input$plotWidth),
-          height = ifelse(is.null(input$plotHeight), NA, input$plotHeight),
-          dpi = ifelse(is.null(input$plotDPI), 300, input$plotDPI),
-          limitsize = FALSE
-        )
-      }
-    )
-  }
-  
   observeEvent(input$plotSize, {
     showModal(
       modalDialog(
         title = "Setting plot size",
         numericInput(
           "plotWidth",
-          label = "Plot width (cm) : ",
-          value = 20,
+          label = "Plot width : ",
+          value = 6,
           min = 1,
-          max = 100
+          max = 50
         ),
         numericInput(
           "plotHeight",
-          label = "Plot height  (cm) : ",
-          value = 20,
+          label = "Plot height : ",
+          value = 6,
           min = 1,
-          max = 100
+          max = 50
+        ),
+        radioButtons(
+          "plotUnits",
+          label = "Units : ",
+          choices = list("in", "cm", "mm"),
+          selected = "cm",
+          inline = TRUE
         ),
         numericInput(
           "plotDPI",
@@ -225,7 +198,7 @@ shinyServer
           "plotDevice",
           label = "Plot device : ",
           choices = list("eps", "ps", "tex", "pdf", "jpeg", "tiff", "png", "bmp", "svg"),
-          selected = "png"
+          selected = "pdf"
         ),
         size = "s",
         easyClose = TRUE,
@@ -295,7 +268,7 @@ shinyServer
   })
   
   output$tableGlom <- DT::renderDataTable(server = FALSE, {
-    Glom <- tax_glom(data16S(), input$glomRank, NArm = FALSE)
+    Glom <- tax_glom(data16S(), input$glomRank, NArm=FALSE)
     taxTableGlom <- Glom %>%
       tax_table() %>%
       as.data.frame(stringsAsFactors = FALSE) %>%
diff --git a/ui.R b/ui.R
index 1c31c51..ad6ce4f 100644
--- a/ui.R
+++ b/ui.R
@@ -76,9 +76,8 @@ shinyUI(dashboardPage(
     #     placeholder = "data.fasta"
     #   )
     # ),
-    uiOutput("downloadDataUI"),
     hr(),
-    uiOutput("downloadPlotUI"),
+    uiOutput("downloadUI"),
     tags$div(
       align = "center",
       actionButton("plotSize", label = "Plot size")
-- 
GitLab