]> nmode's Git Repositories - Rnaught/blob - R/ui.R
111b5f3d5c7f4e78d8e4ff90c06d58613762664a
[Rnaught] / R / ui.R
1 ui <- function() { shiny::fluidPage(
2 # Title.
3 shiny::titlePanel(shiny::HTML(
4 paste0("Rnaught: An Estimation Suite for R", shiny::tags$sub("0")))),
5 # Sidebar layout.
6 shiny::sidebarLayout(
7 # Sidebar. Hidden if the 'About' tab is selected.
8 shiny::conditionalPanel(condition = "input.tabset != 'About'",
9 shiny::sidebarPanel(id = "sidebar",
10 # Data tab sidebar.
11 shiny::conditionalPanel(condition = "input.tabset == 'Data'",
12 shiny::h3("Enter data"),
13 # Data input method selection.
14 shiny::radioButtons(inputId = "dataInputMethod", label = "",
15 choices=list("Manually" = 1, "Upload a .csv file" = 2,
16 "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"),
21 style = "color: red;"),
22 shiny::fluidRow(
23 shiny::column(8,
24 shiny::textInput(inputId = "dataCounts", label = shiny::HTML(
25 paste0("Case counts", shiny::tags$sup("[?]",
26 title = paste0("Enter as a comma-separated list of ",
27 "positive integers, with at least two ",
28 "entries. Example: 1,1,2,3,5,8")))))),
29 shiny::column(4,
30 shiny::selectInput(inputId = "dataUnits",
31 label = "Reporting frequency",
32 choices = list("Daily", "Weekly")))
33 ),
34 shiny::span(shiny::textOutput(outputId = "dataCountsWarn"),
35 style = "color: red;")
36 ),
37 # Option 2: Upload .csv file.
38 shiny::conditionalPanel(condition = "input.dataInputMethod == '2'",
39 shiny::fileInput(inputId = "dataUpload", label = "",
40 accept = c("text/csv", "text/comma-separated-values,text/plain",
41 ".csv")),
42 ),
43 # Option 3: Paste .csv file.
44 shiny::conditionalPanel(condition = "input.dataInputMethod == '3'",
45 shiny::textAreaInput(inputId = "dataPaste", label = "",
46 rows = 8, resize = "none"),
47 ),
48 # Warning text for .csv upload / paste.
49 shiny::conditionalPanel(
50 condition = "['2', '3'].includes(input.dataInputMethod)",
51 shiny::span(shiny::textOutput(outputId = "dataCSVWarn"),
52 style = "color: red;"),
53 ),
54 # Button to add data.
55 shiny::actionButton(inputId = "addData", label = "Add"),
56 ),
57 # Estimators tab sidebar (collapsable entries).
58 shiny::conditionalPanel(condition = "input.tabset == 'Estimators'",
59 shiny::h3("Estimators"),
60 # WHITE & PANAGO (WP).
61 shiny::tags$details(
62 shiny::tags$summary(shiny::h4("White & Panago (WP)")),
63 shiny::p("This is a description of the method."),
64 shiny::br(),
65 shiny::radioButtons(inputId = "serialWPKnown",
66 label = "Is the mean serial interval known?",
67 inline = TRUE,
68 choices = list("Yes" = 1, "No" = 2)),
69 # Known serial interval.
70 shiny::conditionalPanel(condition = "input.serialWPKnown == '1'",
71 shiny::fluidRow(
72 shiny::column(8,
73 shiny::textInput(inputId = "serialWPInput",
74 label = "Mean Serial Interval")),
75 shiny::column(4,
76 shiny::selectInput(inputId = "serialWPUnits",
77 label = "Time units",
78 choices = list("Days", "Weeks")))
79 ),
80 shiny::span(shiny::textOutput(outputId = "serialWPWarn"),
81 style = "color: red;")
82 ),
83 # Unknown serial interval.
84 shiny::conditionalPanel(condition = "input.serialWPKnown == '2'",
85 shiny::h5("Grid Search Parameters"),
86 shiny::fluidRow(
87 shiny::column(4,
88 shiny::textInput(inputId = "gridLengthInput",
89 label = "Grid length", value = "100")),
90 shiny::column(4,
91 shiny::textInput(inputId = "gridShapeInput",
92 label = "Max. shape", value = "10")),
93 shiny::column(4,
94 shiny::textInput(inputId = "gridScaleInput",
95 label = "Max. scale", value = "10"))
96 ),
97 shiny::fluidRow(
98 shiny::column(4,
99 shiny::span(shiny::textOutput(outputId = "gridLengthWarn"),
100 style = "color: red;")),
101 shiny::column(4,
102 shiny::span(shiny::textOutput(outputId = "gridShapeWarn"),
103 style = "color: red;")),
104 shiny::column(4,
105 shiny::span(shiny::textOutput(outputId = "gridScaleWarn"),
106 style = "color: red;"))
107 )
108 ),
109 shiny::actionButton(inputId = "addWP", label = "Add")
110 ),
111 # SEQUENTIAL BAYES (seqB).
112 shiny::tags$details(
113 shiny::tags$summary(shiny::h4("Sequential Bayes (seqB)")),
114 shiny::p("This is a description of the method."),
115 shiny::br(),
116 shiny::fluidRow(
117 shiny::column(8,
118 shiny::textInput(inputId = "serialseqBInput",
119 label = "Mean Serial Interval")),
120 shiny::column(4,
121 shiny::selectInput(inputId = "serialseqBUnits",
122 label = "Time units",
123 choices = list("Days", "Weeks")))
124 ),
125 shiny::span(shiny::textOutput(outputId = "serialseqBWarn"),
126 style = "color: red;"),
127 shiny::textInput(inputId = "kappaInput",
128 label = shiny::HTML(paste0("Maximum value", shiny::tags$sup("[?]",
129 title = paste0("This describes the prior belief of R0, and ",
130 "should be set to a higher value if R0 is ",
131 "believed to be larger. (Default: 20)")))),
132 value = "20"),
133 shiny::span(shiny::textOutput(outputId = "kappaWarn"),
134 style = "color: red;"),
135 shiny::actionButton(inputId = "addseqB", label = "Add")
136 ),
137 # INCIDENCE DECAY (ID).
138 shiny::tags$details(
139 shiny::tags$summary(shiny::h4("Incidence Decay (ID)")),
140 shiny::p("This is a description of the method."),
141 shiny::br(),
142 shiny::fluidRow(
143 shiny::column(8,
144 shiny::textInput(inputId = "serialIDInput",
145 label = "Mean Serial Interval")),
146 shiny::column(4,
147 shiny::selectInput(inputId = "serialIDUnits",
148 label = "Time units",
149 choices = list("Days", "Weeks")))
150 ),
151 shiny::span(shiny::textOutput(outputId = "serialIDWarn"),
152 style = "color: red;"),
153 shiny::actionButton(inputId = "addID", label = "Add")
154 ),
155 # INCIDENCE DECAY & EXPONENTIAL ADJUSTEMENT (IDEA).
156 shiny::tags$details(
157 shiny::tags$summary(
158 shiny::h4("Incidence Decay and Exponential Adjustement (IDEA)")),
159 shiny::p("This is a description of the method."),
160 shiny::br(),
161 shiny::fluidRow(
162 shiny::column(8,
163 shiny::textInput(inputId = "serialIDEAInput",
164 label = "Mean Serial Interval")),
165 shiny::column(4,
166 shiny::selectInput(inputId = "serialIDEAUnits",
167 label = "Time units",
168 choices = list("Days", "Weeks")))
169 ),
170 shiny::span(shiny::textOutput(outputId = "serialIDEAWarn"),
171 style = "color: red;"),
172 shiny::actionButton(inputId = "addIDEA", label = "Add")
173 ),
174 shiny::tags$style(type = "text/css",
175 "summary { display: list-item; cursor: pointer; }"),
176 shiny::tags$style(type = "text/css",
177 "summary h4 { display: inline; }")
178 )
179 )
180 ),
181 # Main panel.
182 shiny::mainPanel(id = "main",
183 shiny::tabsetPanel(id = "tabset", type = "tabs",
184 shiny::tabPanel("About", shiny::br(), "Hello"),
185 shiny::tabPanel("Data", shiny::br(),
186 shiny::dataTableOutput(outputId = "dataTable"),
187 shiny::tags$style(type = "text/css",
188 "#dataTable tfoot { display:none; }")),
189 shiny::tabPanel("Estimators", shiny::br(),
190 shiny::dataTableOutput(outputId = "estTable"),
191 shiny::tags$style(type = "text/css",
192 "#estTable tfoot { display:none; }"),
193 shiny::downloadButton(outputId = "downloadEst",
194 label = "Download table as .csv"))
195 )
196 )
197 )
198 )}