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

Flexdashboard #51

Open
ffalcolini opened this issue Aug 26, 2020 · 16 comments
Open

Flexdashboard #51

ffalcolini opened this issue Aug 26, 2020 · 16 comments

Comments

@ffalcolini
Copy link

Hi!

Is it possible to use shinymanager with flexdashboard?
If so, could I have an example?

Thanks a lot for the cooperation

@upendrak
Copy link

upendrak commented Sep 4, 2020

I am also interested in this. Thanks

@ffalcolini
Copy link
Author

ffalcolini commented Sep 7, 2020

I have made several attempts, but I cannot use shiny manager with flex dashbaord.

If we suppose we have this flexdashboard code:

---
title: "Multiple Pages"
output: flexdashboard::flex_dashboard
---

Page 1
===================================== 
    
### Chart 1
    

### Chart 2


   
Page 2
=====================================     

### Chart 1
    
    
### Chart 2

how should I put shinymanager in the code?

Thanks a lot for your cooperation

@enricodata
Copy link

I am also interested in this. Did you figurate out how to do it?

@bthieurmel
Copy link
Contributor

Perhaps some answer on #25 ?

@bthieurmel
Copy link
Contributor

bthieurmel commented Oct 26, 2020

First, you can't use shinymanager in flexdashboard without the option runtime: shiny, and so document must be deployed using shiny-server

@bthieurmel
Copy link
Contributor

bthieurmel commented Oct 26, 2020

This is one solution :

---
title: "Old Faithful Eruptions"
output: 
  flexdashboard::flex_dashboard:
    css: inst/assets/styles-auth.css
runtime: shiny
---

You need to add a css file with at least this content (here in inst/assets/styles-auth.css) :

.panel-auth {
  position: fixed;
  top:0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #FFF;
  opacity: 1;
  z-index: 99997;
  overflow-x: hidden;
  overflow-y: scroll;
}

Then in global chunk, load shinymanager and define credentials :

```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
library(shinymanager)
data(faithful)

# define some credentials (you can also use sqlite database)
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  stringsAsFactors = FALSE
)
```

Finally, anywhere, call the two modules :

```{r}
auth_ui(id = "auth")

auth <- callModule(
    module = auth_server,
    id = "auth",
    check_credentials = check_credentials(credentials) # data.frame
    # check_credentials = check_credentials("path/to/credentials.sqlite", passphrase = "supersecret") # sqlite
)
```

@bthieurmel
Copy link
Contributor

bthieurmel commented Oct 26, 2020

Full example :


---
title: "Old Faithful Eruptions"
output: 
  flexdashboard::flex_dashboard:
    css: inst/assets/styles-auth.css
runtime: shiny
---

```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
library(shinymanager)
data(faithful)

# define some credentials (you can also use sqlite database)
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  stringsAsFactors = FALSE
)
```

Column {.sidebar}
-----------------------------------------------------------------------

Waiting time between eruptions and the duration of the eruption for the
Old Faithful geyser in Yellowstone National Park, Wyoming, USA.

```{r}
selectInput("n_breaks", label = "Number of bins:",
            choices = c(10, 20, 35, 50), selected = 20)

sliderInput("bw_adjust", label = "Bandwidth adjustment:",
            min = 0.2, max = 2, value = 1, step = 0.2)
```

Column
-----------------------------------------------------------------------

### Geyser Eruption Duration

```{r}

renderPlot({
  hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
       xlab = "Duration (minutes)", main = "Geyser Eruption Duration")

  dens <- density(faithful$eruptions, adjust = input$bw_adjust)
  lines(dens, col = "blue")
})


auth_ui(id = "auth")

auth <- callModule(
    module = auth_server,
    id = "auth",
    check_credentials = check_credentials(credentials) # data.frame
    # check_credentials = check_credentials("path/to/credentials.sqlite", passphrase = "supersecret") # sqlite
)
```

@enricodata
Copy link

I tested the last solution of @bthieurmel but it does not work. It just shows an empty flexdashboard.
Do you have any ideas why it does not show anything?

@dsaada
Copy link

dsaada commented Nov 23, 2020

Hi,

I test this solution, it work,
but when I run this on shiny, I saw that the app is running, and do not wait the login.

Any idea?

@dsaada
Copy link

dsaada commented Nov 23, 2020

How to put timeout=0?

@zjmarg
Copy link

zjmarg commented Jan 4, 2021

Thanks so much @bthieurmel. This solution worked for me. Do you know if it's possible to utilize admin mode with this flexdashboard use?

@dsaada
Copy link

dsaada commented Jan 4, 2021 via email

@zjmarg
Copy link

zjmarg commented Jan 4, 2021

I see thank you. Is there anyway to make the shiny manager more secure considering that you can "overpass" the user authentication in the developer's console? Alternatively, is there any package or module that could create a secure authentication for a flexdashboard?

@dsaada
Copy link

dsaada commented Jan 5, 2021 via email

@zjmarg
Copy link

zjmarg commented Jan 5, 2021

Not a problem, I have been hesitant to do a shinydashboard because I am a novice, but it seems like it's the route I need to go with ultimately. Thanks so much for doing that research and for the help.

@dsaada
Copy link

dsaada commented Jan 5, 2021 via email

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

6 participants