inst/pcdtest/ui.R

library(shinydashboard)
library(lubridate)
library(rpivotTable)

dates <- rev(seq.POSIXt(from = (lubridate::floor_date(Sys.time(), 'month') - months(13)),
                    to = (lubridate::floor_date(Sys.time(), 'month') - months(1)),
                    by = 'month'))
dates <- paste0(
  lubridate::year(
    dates
  ),
  ifelse(
    lubridate::month(
      dates
    ) < 10,
    paste0(0, lubridate::month(dates)),
    lubridate::month(dates)
  )
)

dashboardPage(
  dashboardHeader(title = 'Clincal Chemistry Reagent Diagnostics',
                  titleWidth = 400),
  dashboardSidebar(
    sidebarMenu(
      menuItem(text = 'Complaints by Technology', tabName = 'bytech',
               icon = icon('line-chart')),
      menuItem(text = 'Top Customers', tabName = 'customers',
               icon = icon('table')),
      menuItem(text = 'Top Reagents', tabName = 'reagents',
               icon = icon('table')),
      menuItem(text = 'Pareto Chart', tabName = 'ParetoChart',
               icon = icon('bar-chart')),
      menuItem(text = 'Control Chart', tabName = 'ControlChart',
               icon = icon('line-chart')),
      menuItem(text = 'Pivot Table', tabName = 'pivot',
               icon = icon('table')),
      menuItem(text = 'Raw Data', tabName = 'rawdata',
               icon = icon('table'))
    )
  ),
  dashboardBody(
    tags$head(tags$style(HTML('
        .skin-blue .main-header .logo {
          background-color: #3c8dbc;
        }
        .skin-blue .main-header .logo:hover {
          background-color: #3c8dbc;
        }
      '))),
    tabItems(
      tabItem(
        tabName = 'bytech',
        fluidRow(
          column(width = 10, DT::dataTableOutput('bytechtab'))
        ),
        br(),
        fluidRow(
          column(width = 10, plotOutput('bytechlines')),
          column(width = 2, downloadButton('dltechlines', 'Download Plot'))
        )
      ),
      tabItem(
        tabName = 'customers',
        fluidRow(
          column(
            width = 5,
            selectInput('custdate', 'Year, Month:', dates, selected = dates[1])
          ),
          column(width = 5, sliderInput('topcust', 'Top:', 5, 20, 10))
        ),
        fluidRow(
          column(width = 5, tableOutput('customers')),
          tags$head(tags$style('#customers table {background-color: white; }',
                               media = 'screen',
                               type = 'text/css')),
          column(
            width = 3,
            fluidRow(
              column(width = 3, radioButtons('custfiletype', 'File type:',
                                             choices = c('.xlsx', '.csv'))
              )
            ),
            fluidRow(
              column(width = 3, downloadButton('dlcustomers', 'Download'))
            )
          )
        )
      ),
      tabItem(
        tabName = 'reagents',
        fluidRow(
          column(
            width = 5,
            selectInput('reagdate', 'Year, Month:', dates, selected = dates[1])
          ),
          column(
            width = 5,
            sliderInput('topreag', 'Top:', 5, 20, 10)
          )
        ),
        fluidRow(
          column(width = 5, tableOutput('reagents')),
          tags$head(tags$style('#reagents table {background-color: white; }',
                               media = 'screen',
                               type = 'text/css')),
          column(
            width = 3,
            fluidRow(
              column(width = 3, radioButtons('reagfiletype', 'File type:',
                                             choices = c('.xlsx', '.csv')))
            ),
            fluidRow(width = 3, downloadButton('dlreagents', 'Download'))
          )
        )
      ),
      tabItem(
        tabName = 'ParetoChart',
        fluidRow(
          column(width = 5, uiOutput('callsubject')),
          column(width = 5, selectInput('date', 'Year, Month: ',
                                        dates, selected = dates[1]))
        ),
        br(),
        fluidRow(
          column(
            width = 10,
            plotOutput('pareto')
          ),
          column(width = 2, downloadButton('dlpareto', 'Download Pareto'))
        ),
        br(),
        fluidRow(
          column(width = 5,tableOutput('rawpareto')),
          tags$head(tags$style('#rawpareto table {background-color: white; }',
                               media = 'screen',
                               type = 'text/css')),
          column(
            width = 3,
            fluidRow(
              column(width = 3, radioButtons('parfiletype', 'File type:',
                                             choices = c('.xlsx', '.csv')))
            ),
            fluidRow(width = 3, downloadButton('dlparraw', 'Download'))
          )
        )
      ),
      tabItem(
        tabName = 'ControlChart',
        fluidRow(
          column(width = 5, uiOutput('callsubject2'))
        ),
        fluidRow(
          column(
            width = 10,
            plotOutput('controlchart')
          ),
          column(
            width = 2,
            downloadButton('dlcc', 'Download CC')
          )
        )
      ),
      tabItem(
        tabName = 'pivot',
        fluidRow(
          rpivotTableOutput('pivottable')
        )
      ),
      tabItem(
        tabName = 'rawdata',
        fluidRow(
          column(
            width = 3,
            radioButtons('rawdatafiletype', 'File type:',
                         choices = c('.xlsx', '.csv'))
          ),
          column(
            width = 2,
            downloadButton('dlrawdata', 'Download')
          )
        ),
        fluidRow(
          DT::dataTableOutput('rawdf')
        )
      )
    )
  )
)
kimjam/srms documentation built on May 20, 2019, 10:21 p.m.