diff --git a/R/app_server.R b/R/app_server.R index 610786a..796d957 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -411,9 +411,31 @@ app_server <- function(input, output, session) { }) output$start_button <- shiny::renderUI({ - if (scenario_validation()) { + if (!scenario_validation()) { + return(NULL) + } + + p <- shiny::req(params_with_inputs()) + + if ( + input$scenario_type == "Edit existing" && + !is.null(p[["__inputs_app__"]]) && + !is.null(p[["__inputs_app__"]][["model_run_id"]]) + ) { + # go to the model run progress app + url <- glue::glue( + get_config("model_run_progress_url"), + "?model_run_id={p[['dataset']]}/{p[['__inputs_app__']][['model_run_id']]}" + ) + + button_text <- "View Progress" + } else { f <- tempfile_name() - p <- shiny::req(params_with_inputs()) + if (input$scenario_type == "Create new from existing") { + # remove existing inputs app metadata + p[["__inputs_app__"]] <- NULL + } + # go to the inputs app jsonlite::write_json(p, f, pretty = TRUE, auto_unbox = TRUE) # used by the variable in get_config("app_url") @@ -425,16 +447,18 @@ app_server <- function(input, output, session) { utils::URLencode(basename(f)) ) - bslib::layout_columns( - col_widths = c(9, 3), - shiny::tags$span(), - shiny::tags$a( - "Start", - class = "btn btn-success text-white", - href = url - ) - ) + button_text <- "Start" } + + bslib::layout_columns( + col_widths = c(9, 3), + shiny::tags$span(), + shiny::tags$a( + button_text, + class = "btn btn-success text-white", + href = url + ) + ) }) |> shiny::bindEvent(filename(), params_with_inputs()) diff --git a/inst/config.yml b/inst/config.yml index a59e20f..76685aa 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -1,11 +1,14 @@ default: app_url: "http://localhost:8080/" params_data_path: "." + model_run_progress_url: "http://localhost:8081/" development: app_url: "/nhp/dev/inputs/" params_data_path: "/data/nhp/dev/inputs" + model_run_progress_url: "/nhp/model_run_progress/" production: app_url: "/nhp/{version}/inputs/" params_data_path: "/data/nhp/prod/inputs" + model_run_progress_url: "/nhp/model_run_progress/"