Skip to content
Snippets Groups Projects
Unverified Commit 9fc012d6 authored by Todor Kondic's avatar Todor Kondic
Browse files

shiny-ui-base, app: Add download button.

parent 4028c9f9
No related branches found
No related tags found
No related merge requests found
...@@ -1414,6 +1414,7 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1414,6 +1414,7 @@ mk_shinyscreen_server <- function(projects,init) {
create_plots(rvs$m) create_plots(rvs$m)
}) })
observeEvent(input$make_report_b, { observeEvent(input$make_report_b, {
shinymsg("Started creating report. Please wait.") shinymsg("Started creating report. Please wait.")
req(NROW(rvs$m$out$tab$flt_summ)>0) req(NROW(rvs$m$out$tab$flt_summ)>0)
...@@ -1857,6 +1858,30 @@ mk_shinyscreen_server <- function(projects,init) { ...@@ -1857,6 +1858,30 @@ mk_shinyscreen_server <- function(projects,init) {
}) })
output$dwn_proj_b <- shiny::downloadHandler(
filename=function() {
format(Sys.time(), "project_%Y%m%d_%H_%M_%S.tar.gz")
},
content=function(file) {
pdir <- rvs$m$conf$project
shiny::req(!is.null(pdir) &&
!is.na(pdir) &&
(nchar(pdir) > 0))
ddir <- tempfile("projectdata",tmpdir=".")
if (dir.exists(ddir)) unlink(ddir,recursive=T)
dir.create(ddir)
srcfig <- file.path(pdir,'figures')
file.copy(from=srcfig,to=ddir,recursive=T,copy.date=T)
csvfns <- list.files(path=pdir,pattern=r"(.*\.csv$)",full.names=T)
ymlfns <- list.files(path=pdir,pattern=r"(.*\.y.ml$)",full.names=T)
pdffns <- list.files(path=pdir,pattern=r"(.*\.pdf$)",full.names=T)
fns <- c(csvfns,ymlfns,pdffns)
for (fn in fns) {file.copy(from=fn,to=ddir,copy.date=T)}
tar(file,files=ddir,compression="gzip")
unlink(ddir,recursive=T)
})
......
...@@ -120,10 +120,9 @@ actionButton(inputId = "create_proj_b", ...@@ -120,10 +120,9 @@ actionButton(inputId = "create_proj_b",
<summary>Load an existing project</summary> <summary>Load an existing project</summary>
All the existing projects are shown in the `Avaliable projects` All the existing projects are shown in the `Avaliable projects`
list. Load the project by pressing `Select project` button. list. Load the project by pressing `Select project` button.
</details> </details>
```{r, echo=F} ```{r, echo=F}
selectInput('proj_list', selectInput('proj_list',
label = "Select project", label = "Select project",
...@@ -133,12 +132,35 @@ actionButton(inputId = "load_proj_b", ...@@ -133,12 +132,35 @@ actionButton(inputId = "load_proj_b",
``` ```
##### Save project ##### Save project
```{r, echo=F} ```{r, echo=F}
actionButton(inputId = "save_proj_b", actionButton(inputId = "save_proj_b",
label= "Save project") label= "Save project")
``` ```
##### Download project
<details>
<summary>Download results</summary>
Button `Download project` only makes sense to be used if Shinyscreen is
served over network. If this is the case, clicking this button will
download plots and csvs generated in the project directory.
</details>
```{r, echo=F}
downloadButtonRmd <- function (outputId, label = "Download", class = NULL, ...) {
tags$a(id = outputId, class = paste("btn btn-default shiny-download-link",
class), href = "", target = "_blank", download = NA,
icon("download"), label, ...)
}
downloadButtonRmd("dwn_proj_b",
"Download project directory")
```
##### Select input directory ##### Select input directory
<details> <details>
<summary>More on input directories</summary> <summary>More on input directories</summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment