# Module UI
#' @title mod_output_review_ui and mod_output_review_server
#' @description A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname mod_output_review
#'
#' @keywords internal
#' @export
#' @importFrom shiny NS tagList
mod_output_review_ui <- function(id){
ns <- NS(id)
shinydashboard::tabItem(
tabName = "output_review",
uiOutput(ns("output_info")),
tabsetPanel(
tabPanel("Output",
column(width = 12,
shinydashboard::box(
title = textOutput(ns("myTitle")),
width = NULL,
solidHeader = TRUE,
status = "primary",
htmlOutput(ns("myFile"))
),
actionButton(ns("G_dr"), "Post to Google Drive")
)
),
tabPanel("Data",
h5("Discuss whether to move this to new sidebar option")
),
tabPanel("Program",
tabsetPanel(
tabPanel(
"Program",
div(style="display:inline-block;",
h2(textOutput(ns("myProgram_name"))),
actionButton(ns("Workflow"), "Workflow"),
actionButton(ns("Run_R"), "Run"),
actionButton(ns("Save_R"), "Save"),
actionButton(ns("eval"),"Evaluate code"),
shinyBS::bsTooltip("eval", "To evalute the code below pleae add this:
source(\"setup.R\") at the top and remove it before to save",
"top", options = list(container = "body"))
) ,
p(""),
fluidRow(
column(6,
shinyAce::aceEditor(
ns("ace"),
value = " Enter your text here " ,
mode = "r",
height = "900px",
fontSize = 10,
autoScrollEditorIntoView = TRUE,
minLines = 50,
maxLines = 50
)) ,
column(6,
verbatimTextOutput(ns("outpuuut"), placeholder = TRUE),
shiny::tags$head(shiny::tags$style(
"#outpuuut{color:black; font-size:12px; font-style:italic;
overflow-y:scroll; max-height: 600px; background: ghostwhite;}"))
)
),
tabPanel("Log",
fluidRow(
column(width = 12,
h3(textOutput(ns("myProgram_log"))),
htmlOutput(ns("log"))
)
))
) #tab panel (Log + prgram)
) #tabsetPanel
), #tabPanel
tabPanel("Comments",
h2("Comments"),
column(width = 4,
shinydashboard::box(
title = NULL, width = 6, solidHeader = TRUE, status = "primary",
textOutput(ns("myDateOutp"))
) ,
shinydashboard::box(
title = NULL , width = 6, solidHeader = TRUE, status = "primary",
textInput(ns("caption"), "Caption", "Data Summary"),
verbatimTextOutput(ns("valcom") )
))
)
) #tabsetPanel
) #tabItem
}
# Module Server
#' @rdname mod_output_review
#' @export
#' @keywords internal
mod_output_review_server <- function(input, output, session, state, report_path){
ns <- session$ns
report_txt <- reactive({
txt <- readr::read_file(report_path)
})
#------------------------------
# Top of page output info
#------------------------------
output$output_info <- renderUI({
tagList(
h4(tags$strong("Output:"), glue::glue("{state$output_name}")),
h4(tags$strong("Program location:"), glue::glue("{state$output_path}")),
h4(tags$strong("Output location:"), glue::glue("{state$output_path}")),
h4(tags$strong("Output status:"), glue::glue("Unknown - not implemented"))
# h4("Location: Output file"),
# h4("Output status: Draft"),
# h4("Github repo: Not linked to Github"),
# p("This is currently not dynamic")
)
})
#------------------------------
# Program info and editor
#------------------------------
output$myProgram <- renderText({ txt })
output$valcom <- renderText({ input$caption })
####r EDITOR AND RESULT####
shinyAce::updateAceEditor(session, "ace", txt ,
mode = "r", theme = "ambiance")
output$outpuuut <- renderPrint({
input$eval
return(isolate(eval(parse(text=input$ace))))
})
##### save code
observeEvent(input$Save_R, {
writeLines(input$ace, program_path)
})
observeEvent(input$Run_R, {
execute_R_prog(study,s_path,row_ID)
})
observeEvent(input$Run_SAS, {
execute_SAS_prog()
})
observeEvent(input$clear, {
updateAceEditor(session, "ace", value = "\r")
})
observeEvent(input$Workflow, {
showModal(modalDialog(title = "Push program to github - Promote program",
shiny::div("You are about to push on production", style='color:red'),
textInput("commit_txt", "Enter commit text (default = No Comment)"),
footer = column(shiny::modalButton('Cancel'),
shiny::actionButton("Push", 'Push to Github'),
width=12),
size = 'm', ##modal.size
easyClose = TRUE
))
})
observeEvent(input$Push, {
if (!is.null(input$commit_txt) && nzchar(input$commit_txt)) {
comment_commit <- input$commit_txt
} else {
comment_commit <- "No Comment"
}
promote_git(study,s_pathhh,program_file,comment_commit)
removeModal()
})
#------------------------------
# Comments editor
#------------------------------
output$valcom <- renderText({ input$caption })
# file.copy(paste0(study_path,"output/",output_file), paste0("www/",output_file), overwrite = TRUE)
# date_outp <- file.info(output_path)
output$myDateOutp <- renderText({
paste("Output viewed the:", as.character(date_outp$atime))
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.