aggregate_ui <- function(id) {
  ns <- NS(id)
  tabPanel(
    title = "Aggregate",
    value = ns("tab"),

    tags$br(),
    ## Load data ------------------------------------------------------------

    h3("Load data"),
    uiOutput(ns("agg_load")),
    tags$hr(),

    ## agreggate --------------------------------------------------------------

    h3("Select columns to aggregate"),
    tags$hr(),

    fluidRow(
      column(
        width = 4,
        selectInput(ns("agg_time_col"),
                    label = "Temporal variable to aggregate",
                    choices = c(""),
                    selected = "")
      ),
      column(
        width = 4,
        selectInput(ns("agg_space_col"),
                    label = "Spatial variable to aggregate",
                    choices = c(""),
                    selected = "")
      ),
      column(
        width = 4,
        selectInput(ns("agg_option_col"),
                    label = "Optional additional variabbles to aggregate",
                    choices = c(""), selected = "", multiple = TRUE)
      )
    ),
    tags$br(),
    uiOutput(ns("aggregate_codeui")),
    actionButton(ns("aggregate_button"), "Aggregate data"),
    tags$br(),
    tags$br(),


    ## finish up: download and continue to next tab ------------------------
    fluidRow(
      column(
        width = 6,
        downloadButton(ns("download_aggregate"),
                       label = "Download Aggregated Data")
      ),
      column(
        width = 6,
        actionButton(ns("go_aggregation_visualisation"),
                     "Continue with aggregated data to visualisation")
      )
    )
  )
}

### END
