From 13c2639705d6b51dda03f4297d7ad66868dcc313 Mon Sep 17 00:00:00 2001 From: Ivo Leist Date: Wed, 21 Feb 2024 14:39:46 +0100 Subject: [PATCH 1/2] started to implement landing page navigation triggered by the buttons --- phenoRankeR/R/app_server.R | 5 +++++ phenoRankeR/R/mod_landing_page.R | 26 +++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/phenoRankeR/R/app_server.R b/phenoRankeR/R/app_server.R index 666788e..e789721 100644 --- a/phenoRankeR/R/app_server.R +++ b/phenoRankeR/R/app_server.R @@ -89,6 +89,11 @@ app_server <- function(input, output, session) { print("dbDriver") print(db_driver) + mod_landing_page_server( + "landing_page", + session + ) + mod_sim_mode_server( "sim_mode", session, diff --git a/phenoRankeR/R/mod_landing_page.R b/phenoRankeR/R/mod_landing_page.R index 5085e4a..58b8754 100644 --- a/phenoRankeR/R/mod_landing_page.R +++ b/phenoRankeR/R/mod_landing_page.R @@ -43,7 +43,7 @@ mod_landing_page_ui <- function(id){ diseases, phenotypic features and treatments that you would like to be included in the simulated data. "), actionButton( - "navigateButton", + ns("navigateToSimulator"), "Simulate BFF/PXF", style = "width: 100%;" ), @@ -57,7 +57,7 @@ mod_landing_page_ui <- function(id){ as well as more complex ones with nested fields "), actionButton( - "navigateButton2", + ns("navigateToConverter"), "ConvertCSVs", style = "width: 100%;" ), @@ -88,7 +88,7 @@ mod_landing_page_ui <- function(id){ reference cohort according to their similarity to your patient. "), actionButton( - "navigateButton3", + ns("navigateToPatientMode"), "Individual vs Reference Cohort(s)", style = "width: 100%;" ), @@ -120,7 +120,7 @@ mod_landing_page_ui <- function(id){ ) ), actionButton( - "navigateButton4", + ns("navigateToCohortMode"), "Intra-/Inter-cohort comparison", style = "width: 100%;" ) @@ -131,6 +131,22 @@ mod_landing_page_ui <- function(id){ mod_landing_page_server <- function(id, session){ moduleServer(id, function(input, output, session){ - ns <- session$ns + print("Landing Page Server") + observeEvent(input$navigateToSimulator, { + print("Navigate to simulator") + # updateTabsetPanel(session, "mainTabset", "simulator") + }) + observeEvent(input$navigateToConverter, { + print("Navigate to converter") + # updateTabsetPanel(session, "mainTabset", "converter") + }) + observeEvent(input$navigateToPatientMode, { + print("Navigate to patient mode") + # updateTabsetPanel(session, "mainTabset", "patient") + }) + observeEvent(input$navigateToCohortMode, { + print("Navigate to cohort mode") + # updateTabsetPanel(session, "mainTabset", "cohort") + }) }) } \ No newline at end of file From aa7c5615a1cdcde600fc4a2964e661be6e24b447 Mon Sep 17 00:00:00 2001 From: Ivo Leist Date: Wed, 21 Feb 2024 16:01:22 +0100 Subject: [PATCH 2/2] javascript magic so clicking the action button redirects to the chosen mode of pheno-ranker-ui --- phenoRankeR/NAMESPACE | 1 + phenoRankeR/R/mod_landing_page.R | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phenoRankeR/NAMESPACE b/phenoRankeR/NAMESPACE index 53e81bf..df35bf2 100644 --- a/phenoRankeR/NAMESPACE +++ b/phenoRankeR/NAMESPACE @@ -77,6 +77,7 @@ importFrom(shinyjs,click) importFrom(shinyjs,extendShinyjs) importFrom(shinyjs,hideElement) importFrom(shinyjs,js) +importFrom(shinyjs,runjs) importFrom(shinyjs,showElement) importFrom(shinyjs,useShinyjs) importFrom(shinyvalidate,InputValidator) diff --git a/phenoRankeR/R/mod_landing_page.R b/phenoRankeR/R/mod_landing_page.R index 58b8754..f34e39a 100644 --- a/phenoRankeR/R/mod_landing_page.R +++ b/phenoRankeR/R/mod_landing_page.R @@ -9,6 +9,7 @@ #' @importFrom gridlayout grid_container grid_card grid_place #' @importFrom bslib card_header card_body #' @importFrom shiny NS actionButton +#' @importFrom shinyjs runjs mod_landing_page_ui <- function(id){ ns <- NS(id) @@ -134,19 +135,19 @@ mod_landing_page_server <- function(id, session){ print("Landing Page Server") observeEvent(input$navigateToSimulator, { print("Navigate to simulator") - # updateTabsetPanel(session, "mainTabset", "simulator") + runjs("window.history.pushState(null, '', '/?mode=sim')") }) observeEvent(input$navigateToConverter, { print("Navigate to converter") - # updateTabsetPanel(session, "mainTabset", "converter") + runjs("window.history.pushState(null, '', '/?mode=conv')") }) observeEvent(input$navigateToPatientMode, { print("Navigate to patient mode") - # updateTabsetPanel(session, "mainTabset", "patient") + runjs("window.history.pushState(null, '', '/?mode=patient')") }) observeEvent(input$navigateToCohortMode, { print("Navigate to cohort mode") - # updateTabsetPanel(session, "mainTabset", "cohort") + runjs("window.history.pushState(null, '', '/?mode=cohort')") }) }) } \ No newline at end of file