timelyportfolio / sweetalertR

R htmlwidget for sweetalert by @t4t5
MIT License
21 stars 2 forks source link

add htmlwidgets to imports field? #2

Closed rpodcast closed 8 years ago

rpodcast commented 8 years ago

Greetings, I'm getting back to creating a Shiny app that's composed with the new modules framework while incorporating sweetalertR. It was fairly easy to adapt your example from issue 1 and I put the snippet below. My question is regarding deploying this app on the new RStudio Connect beta service (it's like a supercharged Shiny server and works similarly as their Shinyapps.io service for deployment). Basically I'm getting an error every time complaining that the htmlwidgets package is not available when it gets to the installation of sweetalertR:

Deploying to R version '3.2.2' (Local version is '3.2.3')
2016/02/04 02:46:52.283865802 R version: 3.2.2
2016/02/04 02:46:52.284010150 packrat version: 0.4.5.17
2016/02/04 02:46:52.429331508 Audited package hashes with local packrat installation.
2016/02/04 02:46:55.746279348 Installing R6 (2.1.2) ... 
2016/02/04 02:46:55.778908353   OK (symlinked cache)
2016/02/04 02:46:55.779194622 Installing Rcpp (0.12.3) ... 
2016/02/04 02:46:55.802138486   OK (symlinked cache)
2016/02/04 02:46:55.802413407 Installing digest (0.6.9) ... 
2016/02/04 02:46:55.834369494   OK (symlinked cache)
2016/02/04 02:46:55.834649736 Installing jsonlite (0.9.19) ... 
2016/02/04 02:46:55.864475939   OK (symlinked cache)
2016/02/04 02:46:55.864740100 Installing mime (0.4) ... 
2016/02/04 02:46:55.887368376   OK (symlinked cache)
2016/02/04 02:46:55.887638581 Installing packrat (0.4.6-9) ... 
2016/02/04 02:46:59.740869319   OK (built source)
2016/02/04 02:46:59.741309845 Installing sweetalertR (0.1) ... 
2016/02/04 02:47:02.061841267 Error: Command failed (1)
2016/02/04 02:47:02.061856190 
2016/02/04 02:47:02.061872574 Failed to run system command:
2016/02/04 02:47:02.061874909 
2016/02/04 02:47:02.061881664   '/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpyFleH0/sweetalertR-20b3bbae1938db167d95813e90878d140c5e7413' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.2' --install-tests --no-docs --no-multiarch --no-demo 
2016/02/04 02:47:02.061889580 
2016/02/04 02:47:02.061895511 The command failed with output:
2016/02/04 02:47:02.061897521 * installing *source* package 'sweetalertR' ...
2016/02/04 02:47:02.061903759 ** R
2016/02/04 02:47:02.061906258 ** inst
2016/02/04 02:47:02.061921980 ** preparing package for lazy loading
2016/02/04 02:47:02.061924295 Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
2016/02/04 02:47:02.061930562   there is no package called 'htmlwidgets'
2016/02/04 02:47:02.061932606 ERROR: lazy loading failed for package 'sweetalertR'
2016/02/04 02:47:02.061937792 * removing '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.2/sweetalertR'

I tried this deployment out with another Shiny app that uses the [visNetwork]() widget and during that deployment the htmlwidgets package was installed correctly before trying to install visNetwork and I'm guessing that's because the visNetwork package imports htmlwidgets. Sorry for the long wall of text again, but would it be possible to declare htmlwidgets in the imports field of the DESCRIPTION file? I'd be glad to put in a pull request if it helps.

Test app code:

library(sweetalertR)

jscode <- "shinyjs.swal = function(params) { swal.apply(this, params); }"

app <- function(input, output, session) {
  observeEvent(input$submit, {
    shinyjs::js$swal(input$title, input$text, input$type)
  })
}

appUI <- function(id) {
  ns <- NS(id)
  tagList(
    textInput(ns("title"), "Title"),
    textInput(ns("text"), "Text"),
    selectInput(ns("type"), "Type", c("warning", "error", "success")),
    actionButton(ns("submit"), "Action!"),
    sweetalert()  
  )
}

ui <- fluidPage(
  shinyjs::useShinyjs(),
  shinyjs::extendShinyjs(text = jscode, functions = "swal"),
  appUI("myid")
)

server <- function(input, output, session) {
  callModule(app, "myid")
}

shinyApp(ui = ui, server = server)
timelyportfolio commented 8 years ago

I'm looking forward to seeing all the neat things created by the folks that were lucky enough to attend the conference. I'll be happy to add that to the DESCRIPTION. Thanks for the report. Probably time to revisit this nifty little htmlwidget also...

timelyportfolio commented 8 years ago

Actually, I did not complete my htmlwidget checklist on this one. The DESCRIPTION is a mess. I'll need to get on my development machine to make sure that I don't screw something up. Ok if I complete first thing in the morning?

rpodcast commented 8 years ago

Thanks @timelyportfolio! Yeah it's no rush, whenever you get to it. The bigger app I'm working on has a lot more on the to-do list. BTW keep me posted when you want to chat for a future episode of the podcast!

timelyportfolio commented 8 years ago

@thercast hopefully 44c3775dcaf39bc66f3dc4a201569044d2bbbef6 fixes. Thanks for the issue. Loved the podcast with Dean. Ready when you are.

rpodcast commented 8 years ago

:thumbsup: success! The app deployed flawlessly this time. This little widget will go a long way to help improve the user experience of my apps going forward. I'll be in touch next week about the future episode.