Skip to content

Commit

Permalink
Add conditional run name input
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpenn1 committed Dec 18, 2023
1 parent 66b9800 commit 1a92c09
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions h2/components/modules/mod_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,17 @@ run_ui <- function(id) {
"RF - Volcanic Activity" = RF_VOL(),
"RF - CH4" = RF_CH4())),
selected = "Atmospheric CO2", multiple = FALSE),
)
),
fluidRow(
column(2,
actionBttn(ns("run"),"Run", color = "primary")
),
),
column(3,
materialSwitch(ns("savetoggle"),"Save Run", value = FALSE)
),
materialSwitch(ns("savetoggle"), "Save Run", status = "success")
),
column(5,
textInput(ns("run_name"), label = "Run Name", placeholder = "Run 1")
),
conditionalPanel(
condition = "input.savetoggle == true",
ns = ns,
textInput(ns("run_name"), label = "Run Name", placeholder = "Run 1")
)
),
column(2,
dropdownButton(inputId = ns("dropdown"),
icon = icon("gear"),
Expand All @@ -76,7 +75,11 @@ run_ui <- function(id) {
dataTableOutput(ns("savetable")),
actionButton(ns("deleteRuns"), "Delete Selected")
)
)
)
),
fluidRow(
actionBttn(ns("run"),"Run", color = "primary"),

),
fluidRow(
withSpinner(plotlyOutput(ns("graph")))
Expand Down Expand Up @@ -126,6 +129,8 @@ run_server <- function(id, r6) {
r6$output[[r6$run_name()]] <- fetchvars(core(), r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
mutate(run = r6$run_name(), Scenario = input$ssp_path)

updateSwitchInput(session = session, "savetoggle", value = FALSE)

} else if (r6$save == FALSE) {

r6$no_save_output <- fetchvars(core(), r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
Expand All @@ -146,6 +151,11 @@ run_server <- function(id, r6) {
}) %>%
bindEvent(input$run, ignoreNULL = TRUE, ignoreInit = FALSE)

observe({
updateTextInput(session = session, "run_name", value = NA)
}) %>%
bindEvent(input$savetoggle == FALSE)

})
}

Expand Down

0 comments on commit 1a92c09

Please sign in to comment.