Title: | Show a Nice Message When a 'Shiny' App Disconnects or Errors |
---|---|
Description: | A 'Shiny' app can disconnect for a variety of reasons: an unrecoverable error occurred in the app, the server went down, the user lost internet connection, or any other reason that might cause the 'Shiny' app to lose connection to its server. With 'shinydisconnect', you can call disonnectMessage() anywhere in a Shiny app's UI to add a nice message when this happens. Works locally (running Shiny apps within 'RStudio') and on Shiny servers (such as shinyapps.io, 'RStudio Connect', 'Shiny Server Open Source', 'Shiny Server Pro'). See demo online at <https://daattali.com/shiny/shinydisconnect-demo/>. |
Authors: | Dean Attali [aut, cre, cph] |
Maintainer: | Dean Attali <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-16 05:20:48 UTC |
Source: | https://github.com/daattali/shinydisconnect |
A shiny app can disconnect for a variety of reasons: an unrecoverable error occurred in
the app, the server went down, the user lost internet connection, or any other reason
that might cause the shiny app to lose connection to its server.
Call disonnectMessage()
anywhere in a Shiny app's UI to add a nice message when this happens. Works
locally (running Shiny apps within RStudio) and on Shiny servers (such as shinyapps.io,
RStudio Connect, Shiny Server Open Source, Shiny Server Pro).
See the demo Shiny app online for examples.
Note that it's not possible to distinguish between errors and timeouts - they will both
show the same message.
disconnectMessage( text = "An error occurred. Please refresh the page and try again.", refresh = "Refresh", width = 450, top = 50, size = 22, background = "white", colour = "#444444", overlayColour = "black", overlayOpacity = 0.6, refreshColour = "#337ab7", css = "" )
disconnectMessage( text = "An error occurred. Please refresh the page and try again.", refresh = "Refresh", width = 450, top = 50, size = 22, background = "white", colour = "#444444", overlayColour = "black", overlayOpacity = 0.6, refreshColour = "#337ab7", css = "" )
text |
The text to show in the message. |
refresh |
The text to show in a link that allows the user to refresh the page.
Use |
width |
The width of the message box. Must be either an integer, or the string
|
top |
The distance from the message to the top of the page. Must be either
an integer, or the string |
size |
The font size of the text. (integer). |
background |
The background colour of the message box. |
colour |
The colour of the text of the message box. |
overlayColour |
The colour of the overlay to draw on the page behind the message box.
An overlay is used to "grey out" the application and draw attention to the message. Use
|
overlayOpacity |
The opacity of the overlay, from 0 (fully transparent/not visible) to 1
(fully opaque). Use |
refreshColour |
The colour of the refresh text link |
css |
Any additional CSS rules to apply to the message box. For example,
|
You can also use disconnectMessage2()
to use a pre-set combination of parameters
that produces a large centered message.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( disconnectMessage(), actionButton("disconnect", "Disconnect the app") ), server = function(input, output, session) { observeEvent(input$disconnect, { session$close() }) } ) }
if (interactive()) { library(shiny) shinyApp( ui = fluidPage( disconnectMessage(), actionButton("disconnect", "Disconnect the app") ), server = function(input, output, session) { observeEvent(input$disconnect, { session$close() }) } ) }
This function is a version of disconnectMessage()
with a pre-set combination
of parameters that results in a large centered message.
disconnectMessage2()
disconnectMessage2()