2024-11-15 20:42:25 +01:00
ui <-
bslib :: page (
theme = bslib :: bs_theme ( preset = " united" ) ,
title = " REDCap database creator" ,
bslib :: page_navbar (
title = " Easy REDCap database creation" ,
2024-11-18 08:17:55 +01:00
sidebar = bslib :: sidebar (
width = 300 ,
2024-11-15 20:42:25 +01:00
shiny :: h5 ( " 1) Database meta data" ) ,
shiny :: fileInput (
inputId = " ds" ,
2024-11-18 08:17:55 +01:00
label = " Upload spreadsheet" ,
2024-11-15 20:42:25 +01:00
multiple = FALSE ,
accept = c (
" .csv" ,
" .xls" ,
" .xlsx" ,
" .dta" ,
" .ods"
)
) ,
2024-11-18 16:26:10 +01:00
shiny :: actionButton (
inputId = " load_data" ,
label = " Load data" ,
icon = shiny :: icon ( " circle-down" )
) ,
shiny :: helpText ( " Have a look at the preview panels to validate the data dictionary and imported data." ) ,
2024-11-18 08:17:55 +01:00
# For some odd reason this only unfolds when the preview panel is shown..
2024-11-18 16:26:10 +01:00
# This has been solved by adding an arbitrary button to load data
2024-11-18 08:17:55 +01:00
shiny :: conditionalPanel (
2024-11-18 16:26:10 +01:00
# condition = "output.uploaded=='yes'",
condition = " input.load_data" ,
# shiny::helpText("Below you can download the dataset formatted for upload and the
# corresponding data dictionary for a new data base, if you want to upload manually."),
2024-11-18 08:17:55 +01:00
# Button
2024-11-18 16:26:10 +01:00
shiny :: downloadButton ( outputId = " downloadData" , label = " Download renamed data" ) ,
2024-11-15 20:42:25 +01:00
2024-11-18 08:17:55 +01:00
# Button
2024-11-18 16:26:10 +01:00
shiny :: downloadButton ( outputId = " downloadMeta" , label = " Download data dictionary" ) ,
2024-11-15 20:42:25 +01:00
2024-11-18 08:17:55 +01:00
# Button
2024-11-18 16:26:10 +01:00
shiny :: downloadButton ( outputId = " downloadInstrument" , label = " Download as instrument" ) ,
2024-11-15 20:42:25 +01:00
2024-11-18 08:17:55 +01:00
# Horizontal line ----
shiny :: tags $ hr ( ) ,
shiny :: radioButtons (
inputId = " upload_redcap" ,
label = " Upload directly to REDCap server?" ,
selected = " no" ,
inline = TRUE ,
choices = list (
" No" = " no" ,
" Yes" = " yes"
)
) ,
shiny :: conditionalPanel (
condition = " input.upload_redcap=='yes'" ,
shiny :: h4 ( " 2) Data base upload" ) ,
shiny :: helpText ( " This tool is usable for now. Detailed instructions are coming." ) ,
shiny :: textInput (
inputId = " uri" ,
label = " URI" ,
value = " https://redcap.your.institution/api/"
) ,
shiny :: textInput (
inputId = " api" ,
label = " API key" ,
value = " "
) ,
shiny :: helpText ( " An API key is an access key to the REDCap database. Please" , shiny :: a ( " see here for directions" , href = " https://www.iths.org/news/redcap-tip/redcap-api-101/" ) , " to obtain an API key for your project." ) ,
shiny :: actionButton (
inputId = " upload.meta" ,
label = " Upload datadictionary" , icon = shiny :: icon ( " book-bookmark" )
) ,
shiny :: helpText ( " P l e a s e n o t e , t h a t b e f o r e u p l o a d i n g a n y r e a l d a t a , p u t y o u r p r o j e c t
2024-11-15 20:42:25 +01:00
into production mode. " ) ,
2024-11-18 08:17:55 +01:00
shiny :: actionButton (
inputId = " upload.data" ,
label = " Upload data" , icon = shiny :: icon ( " upload" )
)
)
2024-11-15 20:42:25 +01:00
) ,
shiny :: br ( ) ,
shiny :: br ( ) ,
shiny :: br ( ) ,
shiny :: p (
2024-11-18 08:17:55 +01:00
" License: " , shiny :: a ( " GPL-3+" , href = " https://agdamsbo.github.io/REDCapCAST/LICENSE.html" )
) ,
2024-11-15 20:42:25 +01:00
shiny :: p (
2024-11-18 08:17:55 +01:00
shiny :: a ( " Package documentation" , href = " https://agdamsbo.github.io/REDCapCAST" )
)
2024-11-15 20:42:25 +01:00
) ,
bslib :: nav_panel (
title = " Intro" ,
shiny :: markdown ( readLines ( " www/SHINYCAST.md" ) ) ,
shiny :: br ( )
) ,
2024-11-18 08:17:55 +01:00
# bslib::nav_spacer(),
2024-11-15 20:42:25 +01:00
bslib :: nav_panel (
title = " Data preview" ,
2024-11-18 08:17:55 +01:00
gt :: gt_output ( outputId = " data.tbl" )
# shiny::htmlOutput(outputId = "data.tbl", container = shiny::span)
2024-11-15 20:42:25 +01:00
) ,
bslib :: nav_panel (
title = " Dictionary overview" ,
2024-11-18 08:17:55 +01:00
gt :: gt_output ( outputId = " meta.tbl" )
# shiny::htmlOutput(outputId = "meta.tbl", container = shiny::span)
2024-11-15 20:42:25 +01:00
) ,
bslib :: nav_panel (
title = " Upload" ,
shiny :: h3 ( " Meta upload overview" ) ,
2024-11-18 08:17:55 +01:00
shiny :: textOutput ( outputId = " upload.meta.print" ) ,
2024-11-15 20:42:25 +01:00
shiny :: h3 ( " Data upload overview" ) ,
2024-11-18 08:17:55 +01:00
shiny :: textOutput ( outputId = " upload.data.print" )
2024-11-15 20:42:25 +01:00
)
)
)
2024-11-18 16:26:10 +01:00