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

regression from 1.4 to 1.5 #350

Closed
smartinsightsfromdata opened this issue Oct 5, 2019 · 3 comments
Closed

regression from 1.4 to 1.5 #350

smartinsightsfromdata opened this issue Oct 5, 2019 · 3 comments

Comments

@smartinsightsfromdata
Copy link

The following reprex worked with htmlwidgets 1.4, but I get stuck with the login page with 1.5.

This is the session info() with htmlwidgets 1.3 (I cannot install 1.4 any longer ?).

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin18.7.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /usr/local/Cellar/openblas/0.3.7/lib/libopenblasp-r0.3.7.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.9               dplyr_0.8.3          shinydashboard_0.7.1
[4] shiny_1.3.2         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       rstudioapi_0.10  magrittr_1.5     tidyselect_0.2.5
 [5] xtable_1.8-4     R6_2.4.0         rlang_0.4.0      tools_3.6.1     
 [9] packrat_0.5.0    crosstalk_1.0.0  htmltools_0.4.0  yaml_2.2.0      
[13] assertthat_0.2.1 digest_0.6.21    tibble_2.1.3     crayon_1.3.4    
[17] purrr_0.3.2      later_1.0.0      htmlwidgets_1.3  promises_1.1.0  
[21] glue_1.3.1       mime_0.7         compiler_3.6.1   pillar_1.4.2    
[25] jsonlite_1.6     httpuv_1.5.2     pkgconfig_2.0.3 

This is my reprex:

library(shiny)
library(shinydashboard)
library(dplyr)
library(DT)


# Main login screen
loginpage <- div(id = "loginpage", style = "width: 500px; max-width: 100%; margin: 0 auto; padding: 20px;",
                 wellPanel(
                   tags$h2("LOG IN", class = "text-center", style = "padding-top: 0;color:#333; font-weight:600;"),
                   textInput("userName", placeholder="Username", label = tagList(icon("user"), "Username")),
                   passwordInput("passwd", placeholder="Password", label = tagList(icon("unlock-alt"), "Password")),
                   br(),
                   div(
                     style = "text-align: center;",
                     actionButton("login", "SIGN IN", style = "color: white; background-color:#3c8dbc;
                                 padding: 10px 15px; width: 150px; cursor: pointer;
                                 font-size: 18px; font-weight: 600;")
                   ))
)

user_data <- data.frame(
  user = c("a", "b", "c"),
  password = c("a","b","c"), 
  permissions = c("admin","admin","admin"),
  name = c("Andreas", "Sascha", "Tobias"),
  stringsAsFactors = FALSE,
  row.names = NULL
)

header <- dashboardHeader( title = "Simple Dashboard", uiOutput("logoutbtn"))

sidebar <- dashboardSidebar(uiOutput("sidebarpanel")) 
body <- dashboardBody(uiOutput("body"))
ui<-dashboardPage(header, sidebar, body, skin = "blue")

server <- function(input, output, session) {
  
  login = FALSE
  USER <- reactiveValues(login = login)
  
  observeEvent(input$login,{
    
    username_input = input$userName
    pw_input = input$passwd
    
    # get pw of user_name stored in user_data
    pw <- user_data%>%
      filter(user==username_input)%>%
      select(password)%>%
      as.character()
    
    # if input pw matches pw stored in db set login to true
    if(pw_input==pw){
      USER$login <- TRUE
    }
    # else show error
    else{
      print("error")
    }
  }, ignoreNULL = TRUE, ignoreInit = TRUE)
  
  output$logoutbtn <- renderUI({
    req(USER$login)
    tags$li(a(icon("fa fa-sign-out"), "Logout", 
              href="javascript:window.location.reload(true)"),
            class = "dropdown", 
            style = "background-color: #eee !important; border: 0;
                    font-weight: bold; margin:5px; padding: 10px;")
  })
  
  output$sidebarpanel <- renderUI({
    if (USER$login == TRUE ){ 
      sidebarMenu(
        menuItem("Main Page", tabName = "dashboard", icon = icon("dashboard"))
      )
    }
  })
  
  output$body <- renderUI({
        if (USER$login == TRUE ) {
          tabItem(tabName ="dashboard", class = "active",
                  fluidRow(
                    box(width = 12, dataTableOutput('results'))
                  ))
      }
      else {
        loginpage
      }
  })

  output$results <-  DT::renderDataTable({
    datatable(iris, options = list(autoWidth = TRUE,
                                   searching = FALSE))
  })
  
}

runApp(list(ui = ui, server = server), launch.browser = TRUE)

This is the error in javascript console - I cannot login.

TypeError: undefined is not an object (evaluating 'postRenderHandlers.length')
@vnijs
Copy link

vnijs commented Oct 6, 2019

I had a (seemingly) related issue with htmlwidgets 1.5 that was resolved by using the latest versions of the packages listed below and shiny release candidate 1.4.0. Perhaps you could try that out as well?

install.packages(c("later", "promises", "htmltools", "htmlwidgets"), type = "source")
remotes::install_github("rstudio/shiny@rc-v1.4.0")

EDIT: As suggested by @jcheng5 here

@smartinsightsfromdata
Copy link
Author

@vnijs Is correct: with the changes above this reprex works fine.

@jcheng5
Copy link
Collaborator

jcheng5 commented Oct 7, 2019

Please refer to #349

@jcheng5 jcheng5 closed this as completed Oct 7, 2019
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