Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion to clean up URL #73

Closed
ResourceX opened this issue Nov 27, 2019 · 6 comments
Closed

Suggestion to clean up URL #73

ResourceX opened this issue Nov 27, 2019 · 6 comments

Comments

@ResourceX
Copy link

When I host an app the URL grows as the user clicks around. Would it be possible to turn off all the /w strings that get added to the URL. Very cosmetic, I know and I'm likely naive, but I don't know what this is doing. Thank you.

For example, what is all this after /bs4DashDemo/

https://dgranjon.shinyapps.io/bs4DashDemo/_w_2e516194/_w_9ab1ab52/_w_f7431d38/

@DivadNojnarg
Copy link
Member

This is just to ensure that bs4Dash works on all professional RStudio products (If you remove it, you will notice that tab navigation will fail). For instance, shiny apps.io allow to create new R processes based on the current load and each time a new worker is created there is an idea associated. What you see in the url is the workId, there is no bad intention behind it ;)

@ResourceX
Copy link
Author

ResourceX commented Apr 9, 2020

Thanks. I ran across this package and I like the functions for change_page, is_page as shown towards the end of this article. I like bs4Dash for all it's cool UI features. I wanted to be able to change tabs from the server. I also have users that try and push the back button, so this would also help here. I tried to combine packages for best of both worlds... am close but how do I disable the workerID in the URL?

https://appsilon.com/shiny-router-package/

This code works locally, but on shinyserver all the workerIDs ruin the navigation.

If I manage my own page or tab navigation how do I turn off the workID in the URL.


library(shiny)
library(bs4Dash)
library(shiny.router)

item1_page<-bs4TabItem(
      
      tabName = "item1",
      h2('Home')
      
    )

item2_page<-bs4TabItem(
      
      tabName = "item2",
      h2('Away from home.')
      
    )

router <- make_router(
  route("/", item1_page, NA),
  route("home2", item2_page, NA)
)

 
  ui = bs4DashPage(
   old_school = FALSE,
   sidebar_min = TRUE,
   sidebar_collapsed = FALSE,
   controlbar_collapsed = FALSE,
   controlbar_overlay = TRUE,
   title = "Basic Dashboard",
   navbar = bs4DashNavbar(),
   sidebar = bs4DashSidebar(
     
     
     HTML('
      <ul class="nav nav-pills nav-sidebar flex-column nav-child-indent" data-widget="treeview" id="sidebar-menu" role="menu" data-accordion="true">
          <li class="nav-item">
            <a class="nav-link" id="tab-item1" href="/#!/" >
              <i class="nav-icon fa fa-home"></i>
              <p>Home</p>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" id="tab-item2" href="/#!/home2" >
              <i class="nav-icon fa fa-tree"></i>
              <p>Away from home</p>
            </a>
          </li>
          <div id="test" class="sidebarMenuSelectedTabItem" data-value="null"></div>
    </ul>')
     
   ),
   
   
   controlbar = bs4DashControlbar(),
   footer = bs4DashFooter(),
   body = bs4DashBody(router_ui())
  )
  
  server = function(input, output,session) {
    router(input, output, session)
  }

 
 
shinyApp(ui, server)

@ResourceX
Copy link
Author

ResourceX commented Apr 9, 2020

I did get this to work. I cloned the repo and found workerID in bs4Dash.js in the inst folder and I just commented out window.history.replaceState.

It's still a work in progress for me, I'm not sure if this will be beneficial in the end. But I was able to host an app on shinyserver and use the shiny.router package to control the tabs and then have bs4Dash package for pretty UI elements.

When hosting on shiny server I also had to update the href ="" to include the full URL name of my app.

For what it's worth here is a link demoing what I did. I have yet to determine if this will be beneficial to me.

https://rxdev.dashpbb.net/bs4Router/#!/

var workerId = $('base').attr('href');
  // ensure that this code does not locally
  if (typeof workerId != "undefined") {
    var pathname = window.location.pathname;
    var newpath = pathname + workerId;
    //window.history.replaceState( {} , 'newpath', newpath);
  }

@DivadNojnarg
Copy link
Member

This looks interesting. I don't have a lot of experience with shiny.router.

@ResourceX
Copy link
Author

Neither do I. I thought it might be a way to help break up my app... Thanks for your help here. This package is great for a new look for shiny dashboards.

@aljrico
Copy link

aljrico commented Dec 28, 2020

Hi!

I am trying to deploy a Shiny App that, among other things, is capable of reading GET requests. This is possible if the user adds parameters to the address, like https://myapp.shinyapps.io/?param1=4234&param2=2342

Everything works perfectly until I moved the shinydashboard bits to bs4Dash. Whenever the user tries to input those parameters, the address gets quickly updated to https://myapp.shinyapps.io/w_88a98847/. So the request can't be captured.

Commenting out that line, as you mention, would be captured by shinyapps.io so that gets solved? Would that create other potential issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants