quest-bih / clinical-dashboard

https://quest-bravo.bihealth.org
GNU Affero General Public License v3.0
0 stars 2 forks source link

Add URI routing #62

Closed delwen closed 1 year ago

delwen commented 1 year ago

Jan suggested we implement URI routing to improve navigation and thus usability (see: https://stackoverflow.com/questions/71541259/uri-routing-with-shiny-router-and-navbarpage-in-a-r-shiny-app/71807248?noredirect=1#comment126924825_71807248).

We'd just need to add this code in the server function (thanks @jantau):

observeEvent(session$clientData$url_hash, { currentHash <- sub("#", "", session$clientData$url_hash) if(is.null(input$navbarTabs) || !is.null(currentHash) && currentHash != input$navbarTabs){ freezeReactiveValue(input, "navbarTabs") updateTabsetPanel(session, "navbarTabs", selected = currentHash) } }, priority = 1)

observeEvent(input$navbarTabs, { currentHash <- sub("#", "", session$clientData$url_hash) pushQueryString <- paste0("#", input$navbarTabs) if(is.null(currentHash) || currentHash != input$navbarTabs){ freezeReactiveValue(input, "navbarTabs") updateQueryString(pushQueryString, mode = "push", session) } }, priority = 0)

ontogenerator commented 1 year ago

Added URI routing and it works.