From 466cb221317e078695c137f0ef4e1cfc81354529 Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Mon, 5 Feb 2024 13:37:52 -0800 Subject: [PATCH 1/6] refactor to handle json config output --- R/app_server.R | 33 +++++++++++++++++---------------- R/app_ui.R | 3 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/app_server.R b/R/app_server.R index fd2f809..be3df0c 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -62,12 +62,12 @@ app_server <- function( input, output, session ) { # SELECT A DCC ############################################################# mod_select_dcc_out <- dfamodules::mod_select_dcc_server("select_dcc", - dcc_config, + tenants_config_path , access_token) # CONFIGURE APP ############################################################ observeEvent(mod_select_dcc_out()$btn_click, { - + # move to dashboard page shinydashboard::updateTabItems(session = session, inputId = "tabs", @@ -85,12 +85,13 @@ app_server <- function( input, output, session ) { shinyjs::show(selector = ".sidebar-menu") # update reactiveVals - selected_dcc_config_list$synapse_asset_view(mod_select_dcc_out()$selected_dcc_config$synapse_asset_view) - selected_dcc_config_list$manifest_dataset_id(mod_select_dcc_out()$selected_dcc_config$manifest_dataset_id) - selected_dcc_config_list$project_name(mod_select_dcc_out()$selected_dcc_config$project_name) - selected_dcc_config_list$schema_url(mod_select_dcc_out()$selected_dcc_config$schema_url) - selected_dcc_config_list$icon(mod_select_dcc_out()$selected_dcc_config$icon) + selected_dcc_config_list$synapse_asset_view(mod_select_dcc_out()$selected_dcc_config$dcc$synapse_asset_view) + selected_dcc_config_list$manifest_dataset_id(mod_select_dcc_out()$selected_dcc_config$dcc$manifest_dataset_id) + selected_dcc_config_list$project_name(mod_select_dcc_out()$selected_dcc_config$dcc$name) + selected_dcc_config_list$schema_url(mod_select_dcc_out()$selected_dcc_config$dcc$data_model_url) + selected_dcc_config_list$icon(mod_select_dcc_out()$selected_dcc_config$dfa_dashboard$icon) + # Check that user has appropriate permissions to use DFA # User must have DOWNLOAD access to the DFA manifest. manifest_perm <- dfamodules::synapse_access( id = selected_dcc_config_list$manifest_dataset_id(), @@ -126,26 +127,26 @@ app_server <- function( input, output, session ) { access_token = access_token, base_url = schematic_api_url ) - + # prep manifest for app prepped_manifest <- dfamodules::prep_manifest_dfa( manifest = manifest_obj$content, config = dash_config ) - + # update reactiveVals original_manifest(prepped_manifest) admin_manifest(prepped_manifest) - + dash_config_react(dash_config) - + # FILTER MANIFEST FOR DASH ############################################### filtered_manifest <- dfamodules::mod_datatable_filters_server( "datatable_filters_1", original_manifest ) - + # DATASET DASH ########################################################### dfamodules::mod_datatable_dashboard_server( @@ -153,9 +154,9 @@ app_server <- function( input, output, session ) { filtered_manifest, dash_config_react ) - + # DATASET DASH VIZ : DISTRIBUTIONS ######################################## - + dfamodules::mod_distribution_server( id = "distribution_contributor", df = filtered_manifest, @@ -165,7 +166,7 @@ app_server <- function( input, output, session ) { y_lab = "Number of Datasets", fill = "#0d1c38" ) - + dfamodules::mod_distribution_server( id = "distribution_datatype", df = filtered_manifest, @@ -175,7 +176,7 @@ app_server <- function( input, output, session ) { y_lab = "Number of Datasets", fill = "#0d1c38" ) - + # hide waiter waiter::waiter_hide() diff --git a/R/app_ui.R b/R/app_ui.R index 69f3212..73c04ad 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -79,8 +79,7 @@ app_ui <- function() { tabName = "tab_select_dcc", shiny::fluidRow( dfamodules::mod_select_dcc_ui( - "select_dcc", - dcc_config + "select_dcc" ) ) ), From 9964a7b902183848f789300132d046e5fd029e1c Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Mon, 5 Feb 2024 13:45:38 -0800 Subject: [PATCH 2/6] formatting --- R/app_server.R | 69 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/R/app_server.R b/R/app_server.R index be3df0c..0fc2e5e 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -23,11 +23,13 @@ app_server <- function( input, output, session ) { ) # get the access_token and userinfo token - req <- httr::POST(redirect_url, - encode = "form", - body = "", - httr::authenticate(app$key, app$secret, type = "basic"), - config = list()) + req <- httr::POST( + redirect_url, + encode = "form", + body = "", + httr::authenticate(app$key, app$secret, type = "basic"), + config = list() + ) # Stop the code if anything other than 2XX status code is returned httr::stop_for_status(req, task = "get an access token") @@ -61,17 +63,21 @@ app_server <- function( input, output, session ) { # SELECT A DCC ############################################################# - mod_select_dcc_out <- dfamodules::mod_select_dcc_server("select_dcc", - tenants_config_path , - access_token) + mod_select_dcc_out <- dfamodules::mod_select_dcc_server( + id = "select_dcc", + tenants_config_path = tenants_config_path , + access_token = access_token + ) # CONFIGURE APP ############################################################ observeEvent(mod_select_dcc_out()$btn_click, { # move to dashboard page - shinydashboard::updateTabItems(session = session, - inputId = "tabs", - selected = "tab_dashboard") + shinydashboard::updateTabItems( + session = session, + inputId = "tabs", + selected = "tab_dashboard" + ) # show waiter on button click waiter::waiter_show( @@ -85,11 +91,21 @@ app_server <- function( input, output, session ) { shinyjs::show(selector = ".sidebar-menu") # update reactiveVals - selected_dcc_config_list$synapse_asset_view(mod_select_dcc_out()$selected_dcc_config$dcc$synapse_asset_view) - selected_dcc_config_list$manifest_dataset_id(mod_select_dcc_out()$selected_dcc_config$dcc$manifest_dataset_id) - selected_dcc_config_list$project_name(mod_select_dcc_out()$selected_dcc_config$dcc$name) - selected_dcc_config_list$schema_url(mod_select_dcc_out()$selected_dcc_config$dcc$data_model_url) - selected_dcc_config_list$icon(mod_select_dcc_out()$selected_dcc_config$dfa_dashboard$icon) + selected_dcc_config_list$synapse_asset_view( + mod_select_dcc_out()$selected_dcc_config$dcc$synapse_asset_view + ) + selected_dcc_config_list$manifest_dataset_id( + mod_select_dcc_out()$selected_dcc_config$dcc$manifest_dataset_id + ) + selected_dcc_config_list$project_name( + mod_select_dcc_out()$selected_dcc_config$dcc$name + ) + selected_dcc_config_list$schema_url( + mod_select_dcc_out()$selected_dcc_config$dcc$data_model_url + ) + selected_dcc_config_list$icon( + mod_select_dcc_out()$selected_dcc_config$dfa_dashboard$icon + ) # Check that user has appropriate permissions to use DFA # User must have DOWNLOAD access to the DFA manifest. @@ -115,10 +131,12 @@ app_server <- function( input, output, session ) { waiter::waiter_hide() } + # generate dashboard config file dash_config <- dfamodules::generate_dashboard_config( schema_url = selected_dcc_config_list$schema_url(), icon = selected_dcc_config_list$icon(), - base_url = schematic_api_url) + base_url = schematic_api_url + ) # download manifest manifest_obj <- dfamodules::dataset_manifest_download( @@ -213,7 +231,9 @@ app_server <- function( input, output, session ) { # COLLECT WIDGET SELECTIONS ################################################ - mod_administrator_widgets_out <- dfamodules::mod_administrator_widgets_server("update_data_flow_status_1") + mod_administrator_widgets_out <- dfamodules::mod_administrator_widgets_server( + id = "update_data_flow_status_1" + ) # MAKE UPDATES TO MANIFEST ################################################# @@ -233,10 +253,10 @@ app_server <- function( input, output, session ) { }) dfamodules::mod_manifest_preview_server( - "highlight_datatable_1", - updated_manifest, - selected_rows, - "dataset_id" + id = "highlight_datatable_1", + df = updated_manifest, + selection = selected_rows, + df_match_colname = "dataset_id" ) # BUTTON CLICK ACTIONS ##################################################### @@ -261,8 +281,9 @@ app_server <- function( input, output, session ) { req(updated_manifest()) dfamodules::prep_manifest_submit( - updated_manifest(), - dash_config_react() + manifest = updated_manifest(), + config = dash_config_react(), + na_replace = "" ) }) From c4fec11b9f8959e77aa44162c0c4d22fe876b8e9 Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Mon, 5 Feb 2024 14:53:49 -0800 Subject: [PATCH 3/6] read in tenants config path --- R/global.R | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/R/global.R b/R/global.R index e8ed751..49a5bea 100644 --- a/R/global.R +++ b/R/global.R @@ -1,16 +1,12 @@ -# READ IN CONFIG -dcc_config <- Sys.getenv("DFA_DCC_CONFIG") -if (is.null(dcc_config) || nchar(dcc_config) == 0) stop("missing DFA_DCC_CONFIG environmental variable") - -dcc_config <- readr::read_csv(dcc_config, - show_col_types = FALSE) +# READ IN TENANTS.JSON +tenants_config_path <- Sys.getenv("DFA_DCC_CONFIG") +if (is.null(tenants_config_path) || nchar(tenants_config_path) == 0) stop("missing DFA_DCC_CONFIG environmental variable") # GET SCHEMATIC API URL schematic_api_url <- Sys.getenv("DFA_SCHEMATIC_API_URL") message("DFA is using ", schematic_api_url) # SET UP OAUTH - client_id <- Sys.getenv("DFA_CLIENT_ID") client_secret <- Sys.getenv("DFA_CLIENT_SECRET") app_url <- Sys.getenv("DFA_APP_URL") From 6ffa6824963f4a9003dc78740dfcdbb0dbf0d343 Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Mon, 5 Feb 2024 15:16:59 -0800 Subject: [PATCH 4/6] snapshot --- renv.lock | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/renv.lock b/renv.lock index 1521952..a692564 100644 --- a/renv.lock +++ b/renv.lock @@ -416,14 +416,14 @@ }, "dfamodules": { "Package": "dfamodules", - "Version": "23.12.1", + "Version": "24.2.1", "Source": "GitHub", "RemoteType": "github", "RemoteHost": "api.github.com", "RemoteUsername": "Sage-Bionetworks", "RemoteRepo": "dfamodules", - "RemoteRef": "main", - "RemoteSha": "186060a0107db12255b1c65275e9dfc3e77be53e", + "RemoteRef": "fds-1615-json-config", + "RemoteSha": "8604684b1326151d3228e476310cfa1b3f44344f", "Requirements": [ "DT", "dplyr", @@ -442,7 +442,7 @@ "shinyjs", "waiter" ], - "Hash": "05924f504f548e7b17adb4bb6fce1c37" + "Hash": "c16d8a19f94511df6d253102cb86942b" }, "diffobj": { "Package": "diffobj", @@ -1627,7 +1627,14 @@ "RemoteUsername": "dreamRs", "RemoteRepo": "shinypop", "RemoteRef": "master", - "RemoteSha": "7745a0b1ecf31f783fa59603f3c5cede0c948118" + "RemoteSha": "7745a0b1ecf31f783fa59603f3c5cede0c948118", + "Requirements": [ + "R", + "htmltools", + "jsonlite", + "shiny" + ], + "Hash": "ee29555190ce6a726046a5909cc91d9b" }, "sourcetools": { "Package": "sourcetools", From 32e85671c25f47a12c7524c386908931d701eb60 Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Mon, 5 Feb 2024 15:17:11 -0800 Subject: [PATCH 5/6] increment version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f107f56..e88a3fb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dataflow Title: Data Flow App Demo -Version: 23.10.1 +Version: 24.2.1 Authors@R: person('L', 'Wolfe', email = 'loren.wolfe@sagebase.org', role = c('cre', 'aut')) Description: A data flow package. License: MIT + file LICENSE From ca89f0a32171febb29afdf027493ee7d16efb51e Mon Sep 17 00:00:00 2001 From: lakikowolfe Date: Fri, 23 Feb 2024 15:21:40 -0800 Subject: [PATCH 6/6] update dfamodules --- renv.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/renv.lock b/renv.lock index a692564..99deb7b 100644 --- a/renv.lock +++ b/renv.lock @@ -422,8 +422,8 @@ "RemoteHost": "api.github.com", "RemoteUsername": "Sage-Bionetworks", "RemoteRepo": "dfamodules", - "RemoteRef": "fds-1615-json-config", - "RemoteSha": "8604684b1326151d3228e476310cfa1b3f44344f", + "RemoteRef": "dev", + "RemoteSha": "b195b41b40453b98bbc09ae81cf21155fb2a6745", "Requirements": [ "DT", "dplyr", @@ -442,7 +442,7 @@ "shinyjs", "waiter" ], - "Hash": "c16d8a19f94511df6d253102cb86942b" + "Hash": "8e16a925b17b61a27fc8c3ae2273c669" }, "diffobj": { "Package": "diffobj", @@ -492,9 +492,9 @@ }, "dplyr": { "Package": "dplyr", - "Version": "1.1.3", + "Version": "1.1.4", "Source": "Repository", - "Repository": "CRAN", + "Repository": "RSPM", "Requirements": [ "R", "R6", @@ -511,7 +511,7 @@ "utils", "vctrs" ], - "Hash": "e85ffbebaad5f70e1a2e2ef4302b4949" + "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, "ellipsis": { "Package": "ellipsis", @@ -888,13 +888,13 @@ }, "jsonlite": { "Package": "jsonlite", - "Version": "1.8.7", + "Version": "1.8.8", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "methods" ], - "Hash": "266a20443ca13c65688b2116d5220f76" + "Hash": "e1b9c55281c5adc4dd113652d9e26768" }, "knitr": { "Package": "knitr", @@ -1873,9 +1873,9 @@ }, "vctrs": { "Package": "vctrs", - "Version": "0.6.2", + "Version": "0.6.5", "Source": "Repository", - "Repository": "CRAN", + "Repository": "RSPM", "Requirements": [ "R", "cli", @@ -1883,7 +1883,7 @@ "lifecycle", "rlang" ], - "Hash": "a745bda7aff4734c17294bb41d4e4607" + "Hash": "c03fa420630029418f7e6da3667aac4a" }, "viridisLite": { "Package": "viridisLite",