From 6f423ec6c0e8524b5b8ec69e5c05926eecdb6805 Mon Sep 17 00:00:00 2001
From: Anjana Elapavalore <anjana.elapavalore@ext.uni.lu>
Date: Tue, 23 Jul 2019 10:13:18 +0200
Subject: [PATCH] Add save button

* R/mix.R: Modified server to test for button clicks.
---
 R/mix.R | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/R/mix.R b/R/mix.R
index 6ccbe5b..601ce65 100644
--- a/R/mix.R
+++ b/R/mix.R
@@ -570,8 +570,13 @@ presc.shiny <-function(wd,mode,pal="Dark2",cex=0.75,rt_digits=2,m_digits=4){
                                                              shiny::plotOutput("plot1", width = "100%", height = "900px", click = NULL,
                                                                         dblclick = NULL, hover = NULL, hoverDelay = NULL,
                                                                         hoverDelayType = NULL, brush = NULL, clickId = NULL,
-                                                                        hoverId = NULL)
-                                                         ),
+                                                                        hoverId = NULL),
+                                                             shinydashboard::box(
+                                                                                 shiny::actionButton("saveplot", "Save", icon = icon("save"))
+                                                             
+                                                                             )
+                                                             ),
+                                         
                                          shinydashboard::box(
                                                              title = "Compounds", solidHeader = TRUE, collapsible = TRUE, "", shiny::br(),
                                                              shiny::sliderInput("idslider", "Compound number:", idsliderrange[1], idsliderrange[2], value=1,step=1)
@@ -679,7 +684,7 @@ presc.shiny <-function(wd,mode,pal="Dark2",cex=0.75,rt_digits=2,m_digits=4){
              
         ## RChemMass::renderSMILES.rcdk(smiles[[i]],coords=c(x1,y1,x2,y2))
         gc()
-
+       
     }
     clean_rtrange <- function(rtrange) {
             x1 <- rtrange[1]
@@ -703,10 +708,22 @@ presc.shiny <-function(wd,mode,pal="Dark2",cex=0.75,rt_digits=2,m_digits=4){
             })
         }
         )
+        ## output$downloadPlot <- shiny::downloadHandler(
+        ##     filename = function() {'test.pdf'},
+        ##     content = function(file){
+        ##         pdf(file=file, width=12, height=8, out.type="pdf")
+        ##         i=input$idslider
+        ##         rtrange <- c(input$min_val,input$max_val)
+        ##         plotall(i,rtrange=clean_rtrange(rtrange))
+        ##         dev.off()
+        ##     },
+        ##     contentType=NULL)
          output$compoundID <- renderText(
         {
             i=input$idslider
-            })
+        })
+
+        shiny::observeEvent(input$saveplot,{message("Value is: ",input$saveplot)})
     }
     
     shiny::shinyApp(ui = ui, server = server)
-- 
GitLab