RinteRface / shinydashboardPlus

extensions for shinydashboard
https://shinydashboardplus.rinterface.com
Other
454 stars 77 forks source link

Can't run current dev version #103

Closed M3IT closed 3 years ago

M3IT commented 3 years ago

CRAN version of shinydashboardPlus is fine, but I'm wanting to use updateBoxPlus() and am trying to run the example from #69. On loading dashboardPagePlus, I get: Couldn't normalize path in addResourcePath, with arguments: prefix = 'shinydashboardPlus-2.0.0.9000'; directoryPath = ''

Packages loaded are:

package     version
assertthat  0.2.1
cli     2.2.0
colorspace  2.0-0
compiler    4.0.3
crayon      1.3.4
digest      0.6.27
dplyr       1.0.2
DT      0.16
ellipsis    0.3.1
fansi       0.4.1
fastmap     1.0.1
generics    0.1.0
ggplot2     3.3.3
glue        1.4.2
grid        4.0.3
gtable      0.3.0
htmltools   0.5.0.9003
htmlwidgets 1.5.3
httpuv      1.5.4
later       1.1.0.1
lifecycle   0.2.0
magrittr    2.0.1
mime        0.9
munsell     0.5.0
pillar      1.4.7
pkgconfig   2.0.3
promises    1.1.1
purrr       0.3.4
R6      2.5.0
Rcpp        1.0.5
rlang       0.4.10
rstudioapi  0.13
scales      1.1.1
tibble      3.0.4
tidyselect  1.1.0
tinytex     0.28
tools       4.0.3
vctrs       0.3.6
xfun        0.19
xtable      1.8-4
yaml        2.2.1
DivadNojnarg commented 3 years ago

Try to remove {shinydashboardPlus}, then reinstall and run:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
        tags$style("body { background-color: ghostwhite}"),
        fluidRow(
            actionButton("toggle_box", "Toggle Box"),
            actionButton("remove_box", "Remove Box", class = "bg-danger"),
            actionButton("restore_box", "Restore Box", class = "bg-success")
        ),
        actionButton("update_box", "Update Box", class = "bg-info"), 
        actionButton("update_box2", "Update Box 2", class = "bg-info"),
        br(),
        br(),
        box(
            title = textOutput("box_state"),
            id = "mybox",
            status = "danger", 
            background = "maroon", 
            gradient = TRUE,
            collapsible = TRUE,
            closable = TRUE,
            plotOutput("plot")
        )
    )
)

server <- function(input, output, session) {
    output$plot <- renderPlot({
        req(!input$mybox$collapsed)
        plot(rnorm(200))
    })

    output$box_state <- renderText({
        state <- if (input$mybox$collapsed) "collapsed" else "uncollapsed"
        paste("My box is", state)
    })

    observeEvent(input$toggle_box, {
        updateBox("mybox", action = "toggle")
    })

    observeEvent(input$remove_box, {
        updateBox("mybox", action = "remove")
    })

    observeEvent(input$restore_box, {
        updateBox("mybox", action = "restore")
    })

    observeEvent(input$mybox$visible, {
        collapsed <- if (input$mybox$collapsed) "collapsed" else "uncollapsed"
        visible <- if (input$mybox$visible) "visible" else "hidden"
        message <- paste("My box is", collapsed, "and", visible)
        showNotification(message, type = "warning", duration = 1)
    })

    observeEvent(input$update_box, {
        updateBox(
            "mybox", 
            action = "update", 
            options = list(
                title = h2("hello", dashboardLabel(1, status = "primary")),
                status = "warning", 
                solidHeader = TRUE, 
                width = 12, 
                background = NULL, 
                height = "900px", 
                closable = FALSE
            )
        )
    })

    observeEvent(input$update_box2, {
        updateBox(
            "mybox", 
            action = "update", 
            options = list(
                status = NULL, 
                solidHeader = FALSE,
                width = 4, 
                background = "green", 
                height = "500px", 
                closable = TRUE
            )
        )
    })

}

shinyApp(ui, server)
M3IT commented 3 years ago

Working well now. Thanks.