R/InputDataUploadModule.R

Defines functions InputDataUploadUI InputDataUpload

InputDataUploadUI <- function(id)
{
  ns <- NS(id)

  tagList(
    div(
      class = 'row',
      div(
        class = 'col',
        f7Card(
          title = 'Input data upload',
          f7Tabs(
            animated = FALSE,
            style = 'toolbar',
            f7Tab(
              style = 'background-color: transparent',
              tabName = 'Case-based data upload',
              active = TRUE,
              f7Block(
                style = 'margin-top: 20px',
                fileInput(ns('caseFileInput'), label = NULL),
                p(
                  'Maximum file size: 70MB',
                  tags$br(),
                  'Supported files types: rds, txt, csv, xls, xlsx (uncompressed and zip archives)'
                ),
                plotly::plotlyOutput(ns('plot'))
              )
            ),
            f7Tab(
              style = 'background-color: transparent',
              tabName = 'Aggregated data upload',
              active = FALSE,
              f7Block('asd akjshdj asd askjdhkj')
            )
          )
        )
      )
    )
  )
}

InputDataUpload <- function(input, output, session, appState)
{
  mgr <- isolate({appState$AppManager})

  # EVENT: Input data file name changed
  observeEvent(input[['caseFileInput']], {
    # Get reference to file input
    fileInput <- input$caseFileInput

    # Validate
    validate(need(fileInput, message = FALSE))

    # Read input data
    mgr$ReadCaseBasedData(fileInput$datapath)
    mgr$PreProcessCaseBasedData()
    mgr$ApplyOriginGrouping('REPCOUNTRY + UNK + OTHER')
    mgr$CreatePlots()
  })

  output[['plot']] <- plotly::renderPlotly({
    mgr$Plots$DiagnosisYearDensity
  })
}
nextpagesoft/hivEstimatesAccuracyReloaded documentation built on March 14, 2020, 7:06 a.m.