R/mod_save_publish.R

Defines functions mod_save_publish_server mod_save_publish_ui

#' save_publish UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd 
#'
#' @importFrom shiny NS tagList
#' @importFrom dplyr %>%
mod_save_publish_ui <- function(id){
  ns <- NS(id)
  tagList(
    uiOutput(ns("download"))
  )
}
    
#' save_publish Server Function
#'
#' @noRd 
mod_save_publish_server <- function(id, r){
  
  moduleServer(id, function(input, output, session){
    ns <- session$ns
    
  output$download <- renderUI({
    
    dsmodules::downloadDsUI(ns("download_data_button"),
                            display = "dropdown",
                            formats = c("html","jpeg", "pdf", "png"),
                            dropdownWidth = 170,
                            modalFormatChoices = c("HTML" = "html", "PNG" = "png"),
                            text = shi18ny::i_("download", lang = r$lang(), i18n = r$i18n), 
                            dropdownLabel = shi18ny::i_("download_viz", lang = r$lang(), i18n = r$i18n), 
                            getLinkLabel = shi18ny::i_("get_link", lang = r$lang(), i18n = r$i18n), 
                            modalTitle = shi18ny::i_("get_link", lang = r$lang(), i18n = r$i18n), 
                            modalButtonLabel = shi18ny::i_("gl_save", lang = r$lang(), i18n = r$i18n), 
                            modalLinkLabel = shi18ny::i_("gl_url", lang = r$lang(), i18n = r$i18n), 
                            modalIframeLabel = shi18ny::i_("gl_iframe", lang = r$lang(), i18n = r$i18n),
                            nameLabel = shi18ny::i_("gl_name", lang = r$lang(), i18n = r$i18n),
                            descriptionLabel = shi18ny::i_("gl_description", lang = r$lang(), i18n = r$i18n),
                            sourceLabel = shi18ny::i_("gl_source", lang = r$lang(), i18n = r$i18n),
                            sourceTitleLabel = shi18ny::i_("gl_source_name", lang = r$lang(), i18n = r$i18n),
                            sourcePathLabel = shi18ny::i_("gl_source_path", lang = r$lang(), i18n = r$i18n),
                            licenseLabel = shi18ny::i_("gl_license", lang = r$lang(), i18n = r$i18n),
                            tagsLabel = shi18ny::i_("gl_tags", lang = r$lang(), i18n = r$i18n),
                            tagsPlaceholderLabel = shi18ny::i_("gl_type_tags", lang = r$lang(), i18n = r$i18n),
                            categoryLabel = shi18ny::i_("gl_category", lang = r$lang(), i18n = r$i18n),
                            categoryChoicesLabels = shi18ny::i_("gl_no_category", lang = r$lang(), i18n = r$i18n)
    )
  })
  
  par <- list(user_name = "test", org_name = NULL)
  url_par <- reactive({
    shinyinvoer::url_params(par, session)
  })
  
  
  observe({
    req(r$hgch_viz)
    user_name <- url_par()$inputs$user_name
    org_name <- url_par()$inputs$org_name
    if (is.null(user_name) & is.null(user_name)) return()

    dsmodules::downloadDsServer(id = "download_data_button",
                                element = reactive(r$hgch_viz),
                                formats = c("html", "jpeg", "pdf", "png"),
                                errorMessage = shi18ny::i_("error_down", lang = r$lang(), i18n = r$i18n),
                                elementType = "dsviz",
                                user_name = user_name,
                                org_name = org_name)
  })
  
  observeEvent(url_par() ,{
    r$url_par <- url_par()
  })

  
  })
  
}
datasketch/DSAppTemplate documentation built on March 4, 2021, 12:49 a.m.