From e593b2ecceb6506af7ede421599270db4d50f9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu> Date: Fri, 8 May 2020 07:18:22 +0200 Subject: [PATCH] cmpd, sets: Add server functions * R/shiny-ui-cmpd.R(server_cmpd): New server function. * R/shiny-ui-sets.R(server_sets): New server function. * R/shiny-ui-top.R(mk_shinyscreen) <plugin-servers>: Add server_cmpd and server_sets. --- R/shiny-ui-cmpd.R | 24 ++++++++++++++++++++++++ R/shiny-ui-sets.R | 12 ++++++++++++ R/shiny-ui-top.R | 7 ++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/R/shiny-ui-cmpd.R b/R/shiny-ui-cmpd.R index 68a77e3..a12a8f1 100644 --- a/R/shiny-ui-cmpd.R +++ b/R/shiny-ui-cmpd.R @@ -42,3 +42,27 @@ mk_ui_cmpd <- function() { return(list(tab=cmpListTab, side=compListSideItem)) } + +server_cmpd <- function(input,output,session,rv,rf,roots) { + output$knownCtrl <- rhandsontable::renderRHandsontable({ + df<-rv$m$input$tab$known + out<-if (!is.null(df)) { + df + } else { + data.frame(ID=numeric(),Name=character(),SMILES=character(),RT=numeric()) + } + rhandsontable::rhandsontable(out,stretchH="all") + }) + + output$unkCtrl <- rhandsontable::renderRHandsontable({ + df<-rv$m$input$tab$unknown + out<-if (!is.null(df)) { + df + } else { + data.frame(ID=numeric(),mz=numeric()) + } + rhandsontable::rhandsontable(out,stretchH="all") + }) + + rv +} diff --git a/R/shiny-ui-sets.R b/R/shiny-ui-sets.R index fbf82ff..72c6740 100644 --- a/R/shiny-ui-sets.R +++ b/R/shiny-ui-sets.R @@ -34,4 +34,16 @@ mk_ui_sets <- function() { icon=shiny::icon("table")) return(list(tab=setIdTab, side=setIdSideItem)) + +} + + +server_sets <- function(input,output,session,rv,rf,roots) { + output$setIdCtrl<- rhandsontable::renderRHandsontable({ + df<-rv$m$input$tab$setid + rhandsontable::rhandsontable(df,stretchH="all") + }) + + rv + } diff --git a/R/shiny-ui-top.R b/R/shiny-ui-top.R index 43d2b0f..07b1546 100644 --- a/R/shiny-ui-top.R +++ b/R/shiny-ui-top.R @@ -72,8 +72,13 @@ mk_shinyscreen <- function(wd=getwd(),fn_style=system.file('www/custom.css',pack rf <- react_conf_f(input,output,session,rv=rv,rf=rf) # Config related r. functions. - ## ## Observers and renderers. + ## Plugin servers. rv <- server_conf(input,output,session,rv=rv,rf=rf,roots=roots) + rv <- server_cmpd(input,output,session,rv=rv,rf=rf,roots=roots) + rv <- server_sets(input,output,session,rv=rv,rf=rf,roots=roots) + + + obsrv_e(rv,{ message(paste("rv changed at ",Sys.time())) }) -- GitLab