diff --git a/R/schematic_rest_api.R b/R/schematic_rest_api.R index c2db54ad..b2e39e0e 100644 --- a/R/schematic_rest_api.R +++ b/R/schematic_rest_api.R @@ -21,8 +21,8 @@ check_success <- function(x){ manifest_download <- function(url = "http://localhost:3001/v1/manifest/download", access_token, asset_view, dataset_id, as_json=TRUE, new_manifest_name=NULL) { request <- httr::GET( url = url, + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query = list( - access_token = access_token, asset_view = asset_view, dataset_id = dataset_id, as_json = as_json, @@ -61,6 +61,7 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate", strict_validation = FALSE) { req <- httr::GET(url, + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query = list( schema_url=schema_url, title=title, @@ -69,7 +70,6 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate", dataset_id=dataset_id, asset_view=asset_view, output_format=output_format, - access_token = access_token, strict_validation = strict_validation )) @@ -161,12 +161,11 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit", use_schema_label=TRUE, manifest_record_type="table_and_file", file_name, table_manipulation="replace", hide_blanks=FALSE) { req <- httr::POST(url, - #add_headers(Authorization=paste0("Bearer ", pat)), + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query=list( schema_url=schema_url, data_type=data_type, dataset_id=dataset_id, - access_token=access_token, restrict_rules=restrict_rules, json_str=json_str, asset_view=asset_view, @@ -230,11 +229,10 @@ storage_project_datasets <- function(url="http://localhost:3001/v1/storage/proje access_token) { req <- httr::GET(url, - #add_headers(Authorization=paste0("Bearer ", pat)), + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query=list( asset_view=asset_view, - project_id=project_id, - access_token=access_token) + project_id=project_id) ) check_success(req) @@ -254,9 +252,9 @@ storage_projects <- function(url="http://localhost:3001/v1/storage/projects", access_token) { req <- httr::GET(url, + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query = list( - asset_view=asset_view, - access_token=access_token + asset_view=asset_view )) check_success(req) @@ -280,13 +278,12 @@ storage_dataset_files <- function(url="http://localhost:3001/v1/storage/dataset/ full_path=FALSE, access_token) { req <- httr::GET(url, - #add_headers(Authorization=paste0("Bearer ", pat)), + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query=list( asset_view=asset_view, dataset_id=dataset_id, file_names=file_names, - full_path=full_path, - access_token=access_token)) + full_path=full_path)) check_success(req) httr::content(req) @@ -302,9 +299,9 @@ get_asset_view_table <- function(url="http://localhost:3001/v1/storage/assets/ta access_token, asset_view, return_type="json") { req <- httr::GET(url, + httr::add_headers(Authorization = sprintf("Bearer %s", access_token)), query=list( asset_view=asset_view, - access_token=access_token, return_type=return_type)) check_success(req) diff --git a/server.R b/server.R index 83297e28..f9b37ffb 100644 --- a/server.R +++ b/server.R @@ -34,6 +34,12 @@ shinyServer(function(input, output, session) { ######## session global variables ######## # read config in + if (grepl("dev", dcc_config_file)) { + def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev-old/demo/dca-template-config.json") + } else if (grepl("staging", dcc_config_file)) { + def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/staging/demo/dca-template-config.json") + } else def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/main/demo/dca-template-config.json") + config <- reactiveVal() config_schema <- reactiveVal() @@ -234,10 +240,28 @@ shinyServer(function(input, output, session) { } # Use the template dropdown config file from the appropriate branch of # data_curator_config - conf_file <- reactiveVal( - file.path(config_dir, template_config_files[input$dropdown_asset_view]) - ) - + conf_file <- reactiveVal(template_config_files[input$dropdown_asset_view]) + if (!file.exists(conf_file())){ + if (grepl("dev", dcc_config_file)) { + conf_file( + file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev-old", + conf_file() + ) + ) + } else if (grepl("staging", dcc_config_file)) { + conf_file( + file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/staging", + conf_file() + ) + ) + } else { + conf_file( + file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/main", + conf_file() + ) + ) + } + } config_df <- jsonlite::fromJSON(conf_file()) conf_template <- setNames(config_df[[1]]$schema_name, config_df[[1]]$display_name) @@ -309,13 +333,14 @@ shinyServer(function(input, output, session) { }) observeEvent(input$info_box, { + nx_report_info( - title = "App Info", + title = sprintf("DCA for %s", dcc_config_react()$project_name), tags$ul( - tags$li("DCA Help Docs: ", "todo"), - tags$li("Portal Help Docs: ", "todo"), - tags$li("Data model: ", data_model()), - tags$li("Asset view: ", selected$master_asset_view()), + if (!is.na(dcc_config_react()$dca_help_link)) tags$li(tags$a(href = dcc_config_react()$dca_help_link, "DCA Help Docs", target = "_blank")), + if (!is.na(dcc_config_react()$portal_help_link)) tags$li(tags$a(href = dcc_config_react()$portal_help_link, "Portal Help Docs", target = "_blank")), + if (!is.na(dcc_config_react()$data_model_info)) tags$li(tags$a(href = dcc_config_react()$data_model_info, "Data Model Info", target = "_blank")), + tags$li(tags$a(href = paste0("https://www.synapse.org/#!Synapse:", selected$master_asset_view()), paste("Asset View:", selected$master_asset_view()), target = "_blank")), tags$li("DCA version: ", dca_version), tags$li("Schematic version: ", schematic_version), ) @@ -630,6 +655,7 @@ shinyServer(function(input, output, session) { p("Try again or contact the DCC for help"), p("For debugging: ", manifest_data()) )) + hide(selector = "#NXReportButton") # hide OK button so users can't continue shinyjs::enable("btn_template_select") updateTabsetPanel(session, "tab_template_select") } else { @@ -979,6 +1005,7 @@ shinyServer(function(input, output, session) { p("For debugging: ", manifest_id()) ) ) + hide(selector = "#NXReportButton") # hide OK button so users can't continue } else { manifest_path <- tags$a(href = paste0("https://www.synapse.org/#!Synapse:", manifest_id()), manifest_id(), target = "_blank") diff --git a/tests/testthat/test_schematic_rest_api.R b/tests/testthat/test_schematic_rest_api.R index 0fa2a1a1..0155b740 100644 --- a/tests/testthat/test_schematic_rest_api.R +++ b/tests/testthat/test_schematic_rest_api.R @@ -4,7 +4,7 @@ context("test schematic rest api wrappers") ### schematic server URL https://github.com/Sage-Bionetworks/schematic/tree/develop/api ### If not available, skip these tests. -schematic_url <- "https://schematic.api.sagebionetworks.org" +schematic_url <- "https://schematic-dev.api.sagebionetworks.org" ping <- try(httr::GET(schematic_url), silent = TRUE) skip_it <- function(skip=ping) { if (inherits(ping, "try-error")) skip(sprintf("schematic server URL unavailable (%s). Is it running locally?", schematic_url)) #nolint @@ -20,7 +20,7 @@ test_that("manifest_generate returns a URL if sucessful", { skip_it() url <- manifest_generate(url=file.path(schematic_url, "v1/manifest/generate"), - schema_url = schema_url, input_token = Sys.getenv("SNYAPSE_PAT"), + schema_url = schema_url, access_token = Sys.getenv("SNYAPSE_PAT"), title="Test biospecimen", data_type="Biospecimen", use_annotations = FALSE, dataset_id="syn33715357", asset_view="syn33715412", diff --git a/ui.R b/ui.R index d39afd82..7346bdd3 100644 --- a/ui.R +++ b/ui.R @@ -106,9 +106,9 @@ ui <- shinydashboardPlus::dashboardPage( ), # add sidebar footer here tags$a( - id = "sidebar_footer", `data-toggle` = "tab", href = "#shiny-info_box", + id = "sidebar_footer", `data-toggle` = "tab", tags$footer( - actionButton("info_box", "Info", icon("circle-info"), class="btn-info"), + actionButton("info_box", "About Data Curator", icon("circle-info"), class="btn-primary-color"), HTML('  Powered by and Sage Bionetworks') ) ) @@ -123,7 +123,7 @@ ui <- shinydashboardPlus::dashboardPage( ), uiOutput("sass"), # load dependencies - use_notiflix_report(width = "400px"), + use_notiflix_report(width = "500px", messageMaxLength = 10000), use_waiter(), tabItems( # second tab content @@ -297,9 +297,6 @@ ui <- shinydashboardPlus::dashboardPage( ), # waiter loading screen dcWaiter("show", landing = TRUE) - ), - footer = dashboardFooter( - left = sprintf("DCA %s - Schematic %s", dca_version, schematic_version) ) )