Forked from
Environmental Cheminformatics / shinyscreen
678 commits behind, 47 commits ahead of the upstream repository.
-
Todor Kondic authored
* R/shiny-ui-base.R(validate,validate1): Function validate changed back to shiny original. Introduced validate1 when there is no need for `need'.
Todor Kondic authored* R/shiny-ui-base.R(validate,validate1): Function validate changed back to shiny original. Introduced validate1 when there is no need for `need'.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
shiny-ui-base.R 3.92 KiB
## Copyright (C) 2020 by University of Luxembourg
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
## http://www.apache.org/licenses/LICENSE-2.0
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##' @importFrom(shiny, validate)
react_v <- shiny::reactiveValues
react_f <- shiny::reactive
react_e <- shiny::eventReactive
obsrv <- shiny::observe
obsrv_e <- shiny::observeEvent
vols <- shinyFiles::getVolumes
vol_f <- vols()
validate1 <- function(expr,msg) shiny::validate(need(expr,msg))
path2vol <- function(path) {
## This function returns shinyFiles compatible volumes.
splits <- split_path(path)
file.path(tail(splits,1),'')
}
prim_box<-function(...) {shinydashboard::box(...,
status="primary",
solidHeader=T)}
good_box<-function(...) {shinydashboard::box(...,
status="success",
solidHeader=T)}
err_box<-function(...) {shinydashboard::box(...,
status="danger",
solidHeader=T)}
inact_box<-function(...) {shinydashboard::box(...,
status="danger",
solidHeader=T)}
html<-function(...) {shiny::tags$div(shiny::HTML(...))}
## num_input<-function(...,width=NUM_INP_WIDTH) {shiny::tags$div(id="inline",shiny::textInput(...,width=width))}
num_input <- function(inputId,label,...,width=NUM_INP_WIDTH) {
shiny::tags$div(style="display:inline-block",
shiny::tags$label(label, `for` = inputId),
shiny::tags$input(id = inputId, type = "text",style=paste("width:",width,sep = ""),...))
}
num_input_unit <- function(inputId,l1,l2,width=NUM_INP_WIDTH,...) {
shiny::tags$div(style="display:inline-block",
shiny::tags$label(l1, `for` = inputId),
shiny::tags$input(id = inputId, type = "text",style=paste("width:",width,sep = ""),...),
shiny::tags$label(paste(" ",l2,sep=""), `for` = inputId))
}
txt_file_input <- function(inputId,input,fileB,label,volumes) {
fnobj<-shinyFiles::parseFilePaths(roots = volumes,
selection = input[[fileB]])
fn <- fnobj[['datapath']]
if (isThingFile(fn)) {
shiny::textInput(inputId = inputId,
label = label,
value = fn)
} else {
shiny::isolate(currFn <- input[[inputId]])
if (!isThingFile(currFn)) {
shiny::textInput(inputId = inputId,
label = label,
value = "")
} else {
message('Why is this happening so much?')
shiny::textInput(inputId = inputId,
label = label,
value = currFn)
}
}
}
rv_conf2conf <- function(rv) {
x <- shiny::reactiveValuesToList(rv$conf)
x$compounds<-shiny::reactiveValuesToList(rv$conf$compounds)
x
}
conf2rv_conf <- function(conf,rv) {
rv$conf <- shiny::reactiveValues(project=conf$project,
data=conf$data,
compounds=shiny::reactiveValues(known=conf$compounds$known,
unknown=conf$compounds$unknown,
setid=conf$compounds$setid))
rv
}