Skip to content

Commit

Permalink
added error status
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 18, 2024
1 parent 7f43a86 commit 534764e
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion R/capture.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' @param options Options (as a list) passed to [html-to-image](https://github.com/bubkoo/html-to-image#options)
#' method, for example you can use `backgroundColor` to set background color.
#' @param loading Add a loading indicator if taking screenshot take time, see [loading()] for usage.
#' @param statusInputId Retrieve status information in an `input` value server-side.
#' @param statusInputId Retrieve status information in an `input` value server-side with
#' following structure: `list(status = "started|finished|error", timestamp = <POSIX timestamp>)`.
#' @param button_class Class to use for the HTML tag `<button>`
#'
#' @note It's only possible to take screenshot of elements that are actually visible on screen. It doesn't work in Internet Explorer.
Expand Down
1 change: 1 addition & 0 deletions examples/status.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ server <- function(input, output, session) {
})

observeEvent(input$loading, {
print(input$loading)
if (identical(input$loading$status, "started")) {
showNotification(ui = "Capturing screenshot, please wait...")
}
Expand Down
2 changes: 1 addition & 1 deletion inst/packer/capture-image.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/packer/capture-image.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/packer/capture-pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/packer/capture-pdf.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion man/capture.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/capture_pdf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions srcjs/exts/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ import { Loading } from "notiflix/build/notiflix-loading-aio";
}
})
.catch(function(error) {
Loading.remove();
if (statusId !== null) {
Shiny.setInputValue(statusId, {status: "error", timestamp: Date.now()});
}
console.error("Capture: oops, something went wrong!", error);
});
}
Expand Down
4 changes: 4 additions & 0 deletions srcjs/exts/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ import * as utils from "../modules/utils";
}
})
.catch(function(error) {
Loading.remove();
if (statusId !== null) {
Shiny.setInputValue(statusId, {status: "error", timestamp: Date.now()});
}
console.error("Capture: oops, something went wrong!", error);
});
}
Expand Down

0 comments on commit 534764e

Please sign in to comment.