diff --git a/R/shiny-ui-config.R b/R/shiny-ui-config.R index b4ed132920e83cb084ab92a4c1b61157d37bb1ba..87932030cbc7dbadde54606bb60230c3a8a5811d 100644 --- a/R/shiny-ui-config.R +++ b/R/shiny-ui-config.R @@ -118,5 +118,62 @@ mk_ui_config <- function() { side=confSideItem)) } +react_conf_v <- function(input,output,session,rv,rf) { + rv$conf <- react_v(data=CONF$data, + project=CONF$project, + compounds=react_v(known=CONF$compounds$known, + unknown=CONF$compounds$unknown, + sets=CONF$compounds$sets)) + + rv +} + +react_conf_f <- function(input,output,session,rv,rf) { + rf$get_proj_vol <- react_e(rv$conf$project,{ + ## For shinyfiles dialogs. + path <- normalizePath(rv$conf$project, winslash = '/') + vls <- vols()() #Ugly! :) + vol <- path2vol(path) + sel<-match(vol,vls) + validate(need(sel,"Yikes! Unable to detect current project's volume.")) + res<-names(vls)[[sel]] + res + }) + + rf$get_proj_path <- react_e(rv$conf$project,{ + ## For shinyfiles dialogs. + wd <- rv$conf$project + vol <- rf$get_proj_vol() + v <- vols()() + pref<-v[[vol]] + res<-wd + message('Relative project path is: ',res) + res + }) + + rf +} -server_conf <- function(input,output,session) {} +server_conf <- function(input,output,session,rv,rf) { + ## ***** shinyFiles observers ***** + droot <- rf$get_proj_vol + dpath <- rf$get_proj_path + vs <- vols() + shinyFiles::shinyFileChoose(input, 'impKnownListB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + shinyFiles::shinyFileChoose(input, 'impUnkListB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + shinyFiles::shinyFileChoose(input, 'impSetIdB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + + shinyFiles::shinyFileSave(input, 'saveConfB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + shinyFiles::shinyFileChoose(input, 'restoreConfB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + shinyFiles::shinyFileChoose(input, 'mzMLB',defaultRoot=droot(), + defaultPath=dpath(),roots=vs) + shinyFiles::shinyDirChoose(input, 'switchProjB',roots=vs) + + + +} diff --git a/R/shiny-ui-top.R b/R/shiny-ui-top.R index c92b56b45bbc388e44ec8cc6a8a4e103a8769974..241a68d89bb9d25bcede2812ceabcfefcb730a83 100644 --- a/R/shiny-ui-top.R +++ b/R/shiny-ui-top.R @@ -46,7 +46,17 @@ mk_ui <- function (fn_style) { mk_shinyscreen <- function(fn_style=system.file('www/custom.css',package = 'shinyscreen')) { server <- function(input,output,session) { ## Top-level server function. - server_conf(input,output,session) + rv <- shiny::reactiveValues(dummy=1) # Container for all + # reactive values. + + rf <- list() # Container for all + # reactive functions. + + rv <- react_conf_v(input,output,session,rv=rv,rf=rf) # Config related r. values. + rf <- react_conf_f(input,output,session,rv=rv,rf=rf) # Config related r. functions. + + ## Observers and renderers. + server_conf(input,output,session,rv=rv,rf=rf) session$onSessionEnded(function () { stopApp() })