#' @import googleAuthR
#' @importFrom bigQueryR bqr_query
#' @importFrom dplyr pull nth
#' @importFrom DT renderDT DTOutput datatable
server <- function(input, output,session) {
# Load module logic
callModule(mod_home_server, "home")
google_token <- callModule(googleAuth, "login")
# UI ----------------------------------------------------------------------
output$ui_body <- renderUI({
tagList(
mod_home_ui("home"),
uiOutput("ui_dates"),
uiOutput("btn_fetch"),
DTOutput("dt_data")
)
})
output$ui_sidebar <- renderUI({
googleAuthUI("login")
})
output$btn_fetch <- renderUI({
req(google_token())
actionButton(inputId = "fetch",
label = "GO",
icon = icon("cloud-download"))
})
output$ui_dates <- renderUI({
req(google_token())
# Available dates are 2016-08-01 to 2017-08-01
dateRangeInput(inputId = "dates",
label = "Date Range:",
min = as.Date("2016-08-01"),
max = as.Date("2017-08-01"),
start = as.Date("2016-08-01"),
end = as.Date("2016-08-05"))
})
output$dt_data <- renderDT({
datatable(data = tbl_data())
})
# DATA --------------------------------------------------------------------
tbl_data <- eventReactive(
eventExpr = input$fetch,
valueExpr = {
req(google_token())
with_shiny(bqr_query,
google_token(),
query = query_fun(dates = input$dates))
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.