]> nmode's Git Repositories - Rnaught/blob - R/ui.R
Create shiny UI
[Rnaught] / R / ui.R
1 ui <- function() {
2 shiny::fluidPage(
3 shinyjs::useShinyjs(),
4
5 # Title.
6 shiny::titlePanel(shiny::HTML(paste0("Rnaught: an estimation suite for R", shiny::tags$sub("0")))),
7
8 # Sidebar layout.
9 shiny::sidebarLayout(
10 # Sidebar.
11 shiny::sidebarPanel(id="sidebar",
12 # Data tab sidebar.
13 shiny::conditionalPanel(condition="input.tabset == 'Data'",
14 shiny::h4("Enter data"),
15 # Data input method selection.
16 shiny::radioButtons(inputId="dataInputMethod", label="", choices=list("Manually"=1, "Upload a .csv file"=2, "Paste a .csv file"=3)),
17 # Option 1: Manual entry.
18 shiny::conditionalPanel(condition="input.dataInputMethod == '1'",
19 shiny::textInput(inputId="dataName", label="Dataset name"),
20 shiny::span(shiny::textOutput(outputId="dataNameWarn"), style="color: red"),
21 shiny::fluidRow(
22 shiny::column(8, shiny::textInput(inputId="dataCounts", label=shiny::HTML(paste0("Case counts", shiny::tags$sup(id="dataCountsHelp", "[?]"))))),
23 shiny::column(4, shiny::selectInput(inputId="dataUnits", label="Reporting frequency", choices=list("Daily", "Weekly")))
24 ),
25 shinyBS::bsTooltip(id="dataCountsHelp", "Enter as a comma-separated list of positive integers, with at least two entries. Ex: 1,1,2,3,5,8", placement="right", trigger="hover"),
26 shiny::span(shiny::textOutput(outputId="dataCountsWarn"), style="color: red")
27 ),
28 # Option 2: Upload .csv file.
29 shiny::conditionalPanel(condition="input.dataInputMethod == '2'",
30 shiny::fileInput(inputId="dataUpload", label="", accept=c("text/csv", "text/comma-separated-values,text/plain", ".csv")),
31 ),
32 # Option 3: Paste .csv file.
33 shiny::conditionalPanel(condition="input.dataInputMethod == '3'",
34 shiny::textAreaInput(inputId="dataPaste", label="", rows=8, resize="none"),
35 ),
36 # Warning text for .csv upload / paste.
37 shiny::conditionalPanel(condition="['2', '3'].includes(input.dataInputMethod)",
38 shiny::span(shiny::textOutput(outputId="dataCSVWarn"), style="color: red"),
39 ),
40 # Button to add data.
41 shiny::actionButton(inputId="addData", label="Add"),
42 ),
43 # Estimators tab sidebar
44 shiny::conditionalPanel(condition="input.tabset == 'Estimators'",
45 shiny::h4("Estimators"),
46 # Collapsible menu for estimation methods.
47 shinyBS::bsCollapse(id="estCollapse",
48 # WHITE & PANAGO (WP).
49 shinyBS::bsCollapsePanel(title="White & Panago (WP)",
50 "This is a description of the method.",
51 shiny::br(), shiny::br(),
52 shiny::radioButtons(inputId="serialWPKnown", label="Is the mean serial interval known?", inline=TRUE, choices=list("Yes"=1, "No"=2)),
53 # Known serial interval.
54 shiny::conditionalPanel(condition="input.serialWPKnown == '1'",
55 shiny::fluidRow(
56 shiny::column(8, shiny::textInput(inputId="serialWPInput", label="Mean Serial Interval")),
57 shiny::column(4, shiny::selectInput(inputId="serialWPUnits", label="Time units", choices=list("Days", "Weeks")))
58 ),
59 shiny::span(shiny::textOutput(outputId="serialWPWarn"), style="color: red")
60 ),
61 # Unknown serial interval.
62 shiny::conditionalPanel(condition="input.serialWPKnown == '2'",
63 shiny::h5("Grid Search Parameters"),
64 shiny::fluidRow(
65 shiny::column(4, shiny::textInput(inputId="gridLengthInput", label="Grid length", value="100")),
66 shiny::column(4, shiny::textInput(inputId="gridShapeInput", label="Max. shape", value="10")),
67 shiny::column(4, shiny::textInput(inputId="gridScaleInput", label="Max. scale", value="10"))
68 ),
69 shiny::fluidRow(
70 shiny::column(4, shiny::span(shiny::textOutput(outputId="gridLengthWarn"), style="color: red")),
71 shiny::column(4, shiny::span(shiny::textOutput(outputId="gridShapeWarn"), style="color: red")),
72 shiny::column(4, shiny::span(shiny::textOutput(outputId="gridScaleWarn"), style="color: red"))
73 )
74 ),
75 shiny::actionButton(inputId="addWP", label="Add")
76 ),
77 # SEQUENTIAL BAYES (seqB).
78 shinyBS::bsCollapsePanel(title="Sequential Bayes (seqB)",
79 "This is a description of the method.",
80 shiny::br(), shiny::br(),
81 shiny::fluidRow(
82 shiny::column(8, shiny::textInput(inputId="serialseqBInput", label="Mean Serial Interval")),
83 shiny::column(4, shiny::selectInput(inputId="serialseqBUnits", label="Time units", choices=list("Days", "Weeks")))
84 ),
85 shiny::span(shiny::textOutput(outputId="serialseqBWarn"), style="color: red"),
86 shiny::textInput(inputId="kappaInput", label=shiny::HTML(paste0("Maximum value of the uniform prior", shiny::tags$sup(id="kappaTool", "[?]"))), value="20"),
87 shinyBS::bsTooltip(id="kappaTool", "Some information. By default, this is set to 20.", placement="right", trigger="hover"),
88 shiny::span(shiny::textOutput(outputId="kappaWarn"), style="color: red"),
89 shiny::actionButton(inputId="addseqB", label="Add")
90 ),
91 # INCIDENCE DECAY (ID).
92 shinyBS::bsCollapsePanel(title="Incidence Decay (ID)",
93 "This is a description of the method.",
94 shiny::br(), shiny::br(),
95 shiny::fluidRow(
96 shiny::column(8, shiny::textInput(inputId="serialIDInput", label="Mean Serial Interval")),
97 shiny::column(4, shiny::selectInput(inputId="serialIDUnits", label="Time units", choices=list("Days", "Weeks")))
98 ),
99 shiny::span(shiny::textOutput(outputId="serialIDWarn"), style="color: red"),
100 shiny::actionButton(inputId="addID", label="Add")
101 ),
102 # INCIDENCE DECAY & EXPONENTIAL ADJUSTEMENT (IDEA).
103 shinyBS::bsCollapsePanel(title="Incidence Decay and Exponential Adjustement (IDEA)",
104 "This is a description of the method.",
105 shiny::br(), shiny::br(),
106 shiny::fluidRow(
107 shiny::column(8, shiny::textInput(inputId="serialIDEAInput", label="Mean Serial Interval")),
108 shiny::column(4, shiny::selectInput(inputId="serialIDEAUnits", label="Time units", choices=list("Days", "Weeks")))
109 ),
110 shiny::span(shiny::textOutput(outputId="serialIDEAWarn"), style="color: red"),
111 shiny::actionButton(inputId="addIDEA", label="Add")
112 )
113 )
114 )
115 ),
116 # Main panel.
117 shiny::mainPanel(id="main",
118 shiny::tabsetPanel(id="tabset", type="tabs",
119 shiny::tabPanel("About", shiny::br(), "Hello"),
120 shiny::tabPanel("Data", shiny::br(), shiny::dataTableOutput(outputId="dataTable"), shiny::tags$style(type="text/css", '#dataTable tfoot {display:none;}')),
121 shiny::tabPanel("Estimators", shiny::br(),
122 shiny::dataTableOutput(outputId="estTable"),
123 shiny::tags$style(type="text/css", "#estTable tfoot {display:none;}"),
124 shiny::downloadButton(outputId="downloadEst", label="Download table as .csv")
125 ),
126 )
127 )
128 )
129 )
130 }