R/about.R

#' About UI
#'
#' Landing page UI module
#'
#' @param id A string of the namespace id.
#' @param label A string of the module label.
#'
#' @return Modified SQLite database.
#'
#' @export
about_ui <- function(id, label = 'about') {
    ns <- NS(id)

    fluidRow(
      column(1,
             HTML("")),
      column(11,
             h4(paste("Welcome to the app!")),
             br(),
             p("This app was not designed for use on a mobile."),
             br(),
             h5(paste("These tools have been designed to supplement data management and reporting for the project.")),
             br(),
             h5("If you have any questions or concerns you can", actionLink(ns('contactUs'), label = 'message us.')),
             shinyjs::hidden(div(id = ns('feedbackForm'),
                                 br(),
                                 wellPanel(div(textAreaInput(ns("comment"), label = NULL, width = "100%", height = '100px'),
                                               class = 'error-message'),
                                           actionButton(ns("submitFeedback"), "Submit"))))))
}

#' About server
#'
#' Landing page server module
#'
#' @param conn A connection object.
#' @param table_name A string of the name of the table.
#' @param column_name A string of the name of the column.
#'
#' @return Modified SQLite database.
#'
#' @export
about_server <- function(input, output, session) {
  observeEvent(input$contactUs, {
    shinyjs::toggle("feedbackForm", anim = TRUE, animType = "slide", time = 0.2)
  })

  ### --- feedback
  create_feedback <- reactive({
    email <- if(!is.null(session$user)){
      session$user
    } else {
      'test'
    }

    data.frame(Project = proj,
               Email = email,
               Comment = input$comment)
  })

  observe({
    shinyjs::toggleState("submitFeedback", condition = input$comment != "")
  })

  observeEvent(input$submitFeedback, {
    progress <- shiny::Progress$new()
    on.exit(progress$close())
    progress$set(message = "Sending message...", value = 0.5)
    slackr::slackr(create_feedback())
    showModal(modalDialog(
      footer = modalButton("OK"),
      title = "",
      "Thanks! Your message was successfully submitted."
    ))
    shinyjs::reset('feedbackForm')
    shinyjs::hide('feedbackForm')})
}
poissonconsulting/poisshiny documentation built on May 14, 2019, 7:22 p.m.