]> nmode's Git Repositories - Rnaught/commitdiff
Remove 'shinyjs' dependency
authorNaeem Model <me@nmode.ca>
Sun, 25 Jun 2023 01:57:27 +0000 (01:57 +0000)
committerNaeem Model <me@nmode.ca>
Sun, 25 Jun 2023 01:57:27 +0000 (01:57 +0000)
DESCRIPTION
R/app.R
R/server.R
R/ui.R

index 20ad0331fc291fcf9829c8897d5093e73d0c7899..d9fdfad64f3d6c017c83a8181bb0d41aeb551c17 100644 (file)
@@ -19,8 +19,7 @@ Imports:
     utils
 Suggests:
     shiny,
     utils
 Suggests:
     shiny,
-    shinyBS,
-    shinyjs
+    shinyBS
 Encoding: UTF-8
 LazyData: true
 RoxygenNote: 7.2.3
 Encoding: UTF-8
 LazyData: true
 RoxygenNote: 7.2.3
diff --git a/R/app.R b/R/app.R
index 8048fa4f1b2c987223ac2a272799f1fd097a2cf6..64b5d2a3925eb163e9ee7ef0cab8eea83ec9d85d 100644 (file)
--- a/R/app.R
+++ b/R/app.R
@@ -6,8 +6,6 @@ app <- function() {
         stop("The package 'shiny' must be installed to launch the Rnaught web application.")
     if (!requireNamespace("shinyBS", quietly=TRUE))
         stop("The package 'shinyBS' must be installed to launch the Rnaught web application.")
         stop("The package 'shiny' must be installed to launch the Rnaught web application.")
     if (!requireNamespace("shinyBS", quietly=TRUE))
         stop("The package 'shinyBS' must be installed to launch the Rnaught web application.")
-    if (!requireNamespace("shinyjs", quietly=TRUE))
-        stop("The package 'shinyjs' must be installed to launch the Rnaught web application.")
 
     shiny::shinyApp(ui(), server)
 }
 
     shiny::shinyApp(ui(), server)
 }
index 99290107147bf33260f505b8ea59493177b96d87..e8d29705ac033a654d0b20a8a97cca938439008f 100644 (file)
@@ -1,19 +1,6 @@
 #' @importFrom methods is
 #' @importFrom utils read.csv write.csv
 server <- function(input, output) {
 #' @importFrom methods is
 #' @importFrom utils read.csv write.csv
 server <- function(input, output) {
-    # Hide the sidebar if the 'About' tab is active.
-    shiny::observeEvent(input$tabset, {
-        if (input$tabset == "About") {
-            shinyjs::hideElement(selector="#sidebar")
-            shinyjs::removeCssClass("main", "col-sm-8")
-            shinyjs::addCssClass("main", "col-sm-12")
-        } else {
-            shinyjs::showElement(selector="#sidebar")
-            shinyjs::removeCssClass("main", "col-sm-12")
-            shinyjs::addCssClass("main", "col-sm-8")
-        }
-    })
-
     reactive <- shiny::reactiveValues(
         data_table=data.frame(Name=character(0), `Reporting Frequency`=character(0), `Case Counts`=numeric(0), check.names=FALSE),
         est_table=data.frame(Dataset=character(0)),
     reactive <- shiny::reactiveValues(
         data_table=data.frame(Name=character(0), `Reporting Frequency`=character(0), `Case Counts`=numeric(0), check.names=FALSE),
         est_table=data.frame(Dataset=character(0)),
diff --git a/R/ui.R b/R/ui.R
index 8233ba5b00d71e3c19e152d5a28d2f53ccd57cb4..63e21eb5304fc82f618d9843172cf8ad80b1e743 100644 (file)
--- a/R/ui.R
+++ b/R/ui.R
 ui <- function() {
     shiny::fluidPage(
 ui <- function() {
     shiny::fluidPage(
-        shinyjs::useShinyjs(),
-
         # Title.
         shiny::titlePanel(shiny::HTML(paste0("Rnaught: an estimation suite for R", shiny::tags$sub("0")))),
   
         # Sidebar layout.
         shiny::sidebarLayout(
         # Title.
         shiny::titlePanel(shiny::HTML(paste0("Rnaught: an estimation suite for R", shiny::tags$sub("0")))),
   
         # Sidebar layout.
         shiny::sidebarLayout(
-            # Sidebar.
-            shiny::sidebarPanel(id="sidebar",
-                # Data tab sidebar.
-                shiny::conditionalPanel(condition="input.tabset == 'Data'",
-                    shiny::h4("Enter data"),
-                    # Data input method selection.
-                    shiny::radioButtons(inputId="dataInputMethod", label="", choices=list("Manually"=1, "Upload a .csv file"=2, "Paste a .csv file"=3)),
-                    # Option 1: Manual entry.
-                    shiny::conditionalPanel(condition="input.dataInputMethod == '1'",
-                        shiny::textInput(inputId="dataName", label="Dataset name"),
-                        shiny::span(shiny::textOutput(outputId="dataNameWarn"), style="color: red"),
-                        shiny::fluidRow(
-                            shiny::column(8, shiny::textInput(inputId="dataCounts", label=shiny::HTML(paste0("Case counts", shiny::tags$sup(id="dataCountsHelp", "[?]"))))),
-                            shiny::column(4, shiny::selectInput(inputId="dataUnits", label="Reporting frequency", choices=list("Daily", "Weekly")))
+            # Sidebar. Hidden if the 'About' tab is selected.
+            shiny::conditionalPanel(condition="input.tabset != 'About'",
+                shiny::sidebarPanel(id="sidebar",
+                    # Data tab sidebar.
+                    shiny::conditionalPanel(condition="input.tabset == 'Data'",
+                        shiny::h4("Enter data"),
+                        # Data input method selection.
+                        shiny::radioButtons(inputId="dataInputMethod", label="", choices=list("Manually"=1, "Upload a .csv file"=2, "Paste a .csv file"=3)),
+                        # Option 1: Manual entry.
+                        shiny::conditionalPanel(condition="input.dataInputMethod == '1'",
+                            shiny::textInput(inputId="dataName", label="Dataset name"),
+                            shiny::span(shiny::textOutput(outputId="dataNameWarn"), style="color: red"),
+                            shiny::fluidRow(
+                                shiny::column(8, shiny::textInput(inputId="dataCounts", label=shiny::HTML(paste0("Case counts", shiny::tags$sup(id="dataCountsHelp", "[?]"))))),
+                                shiny::column(4, shiny::selectInput(inputId="dataUnits", label="Reporting frequency", choices=list("Daily", "Weekly")))
+                            ),
+                            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"),
+                            shiny::span(shiny::textOutput(outputId="dataCountsWarn"), style="color: red")
                         ),
                         ),
-                        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"),
-                        shiny::span(shiny::textOutput(outputId="dataCountsWarn"), style="color: red")
-                    ),
-                    # Option 2: Upload .csv file.
-                    shiny::conditionalPanel(condition="input.dataInputMethod == '2'",
-                        shiny::fileInput(inputId="dataUpload", label="", accept=c("text/csv", "text/comma-separated-values,text/plain", ".csv")),
-                    ),
-                    # Option 3: Paste .csv file.
-                    shiny::conditionalPanel(condition="input.dataInputMethod == '3'",
-                        shiny::textAreaInput(inputId="dataPaste", label="", rows=8, resize="none"),
-                    ),
-                    # Warning text for .csv upload / paste.
-                    shiny::conditionalPanel(condition="['2', '3'].includes(input.dataInputMethod)",
-                        shiny::span(shiny::textOutput(outputId="dataCSVWarn"), style="color: red"),
+                        # Option 2: Upload .csv file.
+                        shiny::conditionalPanel(condition="input.dataInputMethod == '2'",
+                            shiny::fileInput(inputId="dataUpload", label="", accept=c("text/csv", "text/comma-separated-values,text/plain", ".csv")),
+                        ),
+                        # Option 3: Paste .csv file.
+                        shiny::conditionalPanel(condition="input.dataInputMethod == '3'",
+                            shiny::textAreaInput(inputId="dataPaste", label="", rows=8, resize="none"),
+                        ),
+                        # Warning text for .csv upload / paste.
+                        shiny::conditionalPanel(condition="['2', '3'].includes(input.dataInputMethod)",
+                            shiny::span(shiny::textOutput(outputId="dataCSVWarn"), style="color: red"),
+                        ),
+                        # Button to add data.
+                        shiny::actionButton(inputId="addData", label="Add"),
                     ),
                     ),
-                    # Button to add data.
-                    shiny::actionButton(inputId="addData", label="Add"),
-                ),
-                # Estimators tab sidebar
-                shiny::conditionalPanel(condition="input.tabset == 'Estimators'",
-                    shiny::h4("Estimators"),
-                    # Collapsible menu for estimation methods.
-                    shinyBS::bsCollapse(id="estCollapse",
-                        # WHITE & PANAGO (WP).
-                        shinyBS::bsCollapsePanel(title="White & Panago (WP)",
-                            "This is a description of the method.",
-                            shiny::br(), shiny::br(),
-                            shiny::radioButtons(inputId="serialWPKnown", label="Is the mean serial interval known?", inline=TRUE, choices=list("Yes"=1, "No"=2)),
-                            # Known serial interval.
-                            shiny::conditionalPanel(condition="input.serialWPKnown == '1'",
-                                shiny::fluidRow(
-                                    shiny::column(8, shiny::textInput(inputId="serialWPInput", label="Mean Serial Interval")),
-                                    shiny::column(4, shiny::selectInput(inputId="serialWPUnits", label="Time units", choices=list("Days", "Weeks")))
+                    # Estimators tab sidebar
+                    shiny::conditionalPanel(condition="input.tabset == 'Estimators'",
+                        shiny::h4("Estimators"),
+                        # Collapsible menu for estimation methods.
+                        shinyBS::bsCollapse(id="estCollapse",
+                            # WHITE & PANAGO (WP).
+                            shinyBS::bsCollapsePanel(title="White & Panago (WP)",
+                                "This is a description of the method.",
+                                shiny::br(), shiny::br(),
+                                shiny::radioButtons(inputId="serialWPKnown", label="Is the mean serial interval known?", inline=TRUE, choices=list("Yes"=1, "No"=2)),
+                                # Known serial interval.
+                                shiny::conditionalPanel(condition="input.serialWPKnown == '1'",
+                                    shiny::fluidRow(
+                                        shiny::column(8, shiny::textInput(inputId="serialWPInput", label="Mean Serial Interval")),
+                                        shiny::column(4, shiny::selectInput(inputId="serialWPUnits", label="Time units", choices=list("Days", "Weeks")))
+                                    ),
+                                    shiny::span(shiny::textOutput(outputId="serialWPWarn"), style="color: red")
                                 ),
                                 ),
-                                shiny::span(shiny::textOutput(outputId="serialWPWarn"), style="color: red")
+                                # Unknown serial interval.
+                                shiny::conditionalPanel(condition="input.serialWPKnown == '2'",
+                                    shiny::h5("Grid Search Parameters"),
+                                    shiny::fluidRow(
+                                        shiny::column(4, shiny::textInput(inputId="gridLengthInput", label="Grid length", value="100")),
+                                        shiny::column(4, shiny::textInput(inputId="gridShapeInput", label="Max. shape", value="10")),
+                                        shiny::column(4, shiny::textInput(inputId="gridScaleInput", label="Max. scale", value="10"))
+                                    ),
+                                    shiny::fluidRow(
+                                        shiny::column(4, shiny::span(shiny::textOutput(outputId="gridLengthWarn"), style="color: red")),
+                                        shiny::column(4, shiny::span(shiny::textOutput(outputId="gridShapeWarn"), style="color: red")),
+                                        shiny::column(4, shiny::span(shiny::textOutput(outputId="gridScaleWarn"), style="color: red"))
+                                    )
+                                ),
+                                shiny::actionButton(inputId="addWP", label="Add")
                             ),
                             ),
-                            # Unknown serial interval.
-                            shiny::conditionalPanel(condition="input.serialWPKnown == '2'",
-                                shiny::h5("Grid Search Parameters"),
+                            # SEQUENTIAL BAYES (seqB).
+                            shinyBS::bsCollapsePanel(title="Sequential Bayes (seqB)",
+                                "This is a description of the method.",
+                                shiny::br(), shiny::br(),
                                 shiny::fluidRow(
                                 shiny::fluidRow(
-                                    shiny::column(4, shiny::textInput(inputId="gridLengthInput", label="Grid length", value="100")),
-                                    shiny::column(4, shiny::textInput(inputId="gridShapeInput", label="Max. shape", value="10")),
-                                    shiny::column(4, shiny::textInput(inputId="gridScaleInput", label="Max. scale", value="10"))
+                                    shiny::column(8, shiny::textInput(inputId="serialseqBInput", label="Mean Serial Interval")),
+                                    shiny::column(4, shiny::selectInput(inputId="serialseqBUnits", label="Time units", choices=list("Days", "Weeks")))
                                 ),
                                 ),
-                                shiny::fluidRow(
-                                    shiny::column(4, shiny::span(shiny::textOutput(outputId="gridLengthWarn"), style="color: red")),
-                                    shiny::column(4, shiny::span(shiny::textOutput(outputId="gridShapeWarn"), style="color: red")),
-                                    shiny::column(4, shiny::span(shiny::textOutput(outputId="gridScaleWarn"), style="color: red"))
-                                )
+                                shiny::span(shiny::textOutput(outputId="serialseqBWarn"), style="color: red"),
+                                shiny::textInput(inputId="kappaInput", label=shiny::HTML(paste0("Maximum value of the uniform prior", shiny::tags$sup(id="kappaTool", "[?]"))), value="20"),
+                                shinyBS::bsTooltip(id="kappaTool", "Some information. By default, this is set to 20.", placement="right", trigger="hover"),
+                                shiny::span(shiny::textOutput(outputId="kappaWarn"), style="color: red"),
+                                shiny::actionButton(inputId="addseqB", label="Add")
                             ),
                             ),
-                            shiny::actionButton(inputId="addWP", label="Add")
-                        ),
-                        # SEQUENTIAL BAYES (seqB).
-                        shinyBS::bsCollapsePanel(title="Sequential Bayes (seqB)",
-                            "This is a description of the method.",
-                            shiny::br(), shiny::br(),
-                            shiny::fluidRow(
-                                shiny::column(8, shiny::textInput(inputId="serialseqBInput", label="Mean Serial Interval")),
-                                shiny::column(4, shiny::selectInput(inputId="serialseqBUnits", label="Time units", choices=list("Days", "Weeks")))
-                            ),
-                            shiny::span(shiny::textOutput(outputId="serialseqBWarn"), style="color: red"),
-                            shiny::textInput(inputId="kappaInput", label=shiny::HTML(paste0("Maximum value of the uniform prior", shiny::tags$sup(id="kappaTool", "[?]"))), value="20"),
-                            shinyBS::bsTooltip(id="kappaTool", "Some information. By default, this is set to 20.", placement="right", trigger="hover"),
-                            shiny::span(shiny::textOutput(outputId="kappaWarn"), style="color: red"),
-                            shiny::actionButton(inputId="addseqB", label="Add")
-                        ),
-                        # INCIDENCE DECAY (ID).
-                        shinyBS::bsCollapsePanel(title="Incidence Decay (ID)",
-                            "This is a description of the method.",
-                            shiny::br(), shiny::br(),
-                            shiny::fluidRow(
-                                shiny::column(8, shiny::textInput(inputId="serialIDInput", label="Mean Serial Interval")),
-                                shiny::column(4, shiny::selectInput(inputId="serialIDUnits", label="Time units", choices=list("Days", "Weeks")))
-                            ),
-                            shiny::span(shiny::textOutput(outputId="serialIDWarn"), style="color: red"),
-                            shiny::actionButton(inputId="addID", label="Add")
-                        ),
-                        # INCIDENCE DECAY & EXPONENTIAL ADJUSTEMENT (IDEA).
-                        shinyBS::bsCollapsePanel(title="Incidence Decay and Exponential Adjustement (IDEA)",
-                            "This is a description of the method.",
-                            shiny::br(), shiny::br(),
-                            shiny::fluidRow(
-                                shiny::column(8, shiny::textInput(inputId="serialIDEAInput", label="Mean Serial Interval")),
-                                shiny::column(4, shiny::selectInput(inputId="serialIDEAUnits", label="Time units", choices=list("Days", "Weeks")))
+                            # INCIDENCE DECAY (ID).
+                            shinyBS::bsCollapsePanel(title="Incidence Decay (ID)",
+                                "This is a description of the method.",
+                                shiny::br(), shiny::br(),
+                                shiny::fluidRow(
+                                    shiny::column(8, shiny::textInput(inputId="serialIDInput", label="Mean Serial Interval")),
+                                    shiny::column(4, shiny::selectInput(inputId="serialIDUnits", label="Time units", choices=list("Days", "Weeks")))
+                                ),
+                                shiny::span(shiny::textOutput(outputId="serialIDWarn"), style="color: red"),
+                                shiny::actionButton(inputId="addID", label="Add")
                             ),
                             ),
-                            shiny::span(shiny::textOutput(outputId="serialIDEAWarn"), style="color: red"),
-                            shiny::actionButton(inputId="addIDEA", label="Add")
+                            # INCIDENCE DECAY & EXPONENTIAL ADJUSTEMENT (IDEA).
+                            shinyBS::bsCollapsePanel(title="Incidence Decay and Exponential Adjustement (IDEA)",
+                                "This is a description of the method.",
+                                shiny::br(), shiny::br(),
+                                shiny::fluidRow(
+                                    shiny::column(8, shiny::textInput(inputId="serialIDEAInput", label="Mean Serial Interval")),
+                                    shiny::column(4, shiny::selectInput(inputId="serialIDEAUnits", label="Time units", choices=list("Days", "Weeks")))
+                                ),
+                                shiny::span(shiny::textOutput(outputId="serialIDEAWarn"), style="color: red"),
+                                shiny::actionButton(inputId="addIDEA", label="Add")
+                            )
                         )
                     )
                 )
                         )
                     )
                 )