-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.R
89 lines (68 loc) · 2 KB
/
helpers.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# authentication ----------
# send email ------------------------
send_email <- function(mail_text) {
error_email <-
gm_mime() %>%
gm_to("[email protected]") %>%
gm_from("[email protected]") %>%
gm_subject("Error in rvent_app") %>%
gm_text_body(mail_text)
# If all is good with your draft, then you can send it
gm_send_message(error_email)
}
# snapshot-------------
# save inputs and outputs
# others : other var to uploads
get_status <- function(others = NULL) {
sess_outputs <- outputOptions(output)
sess_inputs <- lapply(names(input), function(x) {
input[[x]]
})
names(sess_inputs) <- names(input)
sess_rc <- list(
dpath(),
reactiveValuesToList(c_comments),
vent(),
rc_ses(),
rc_plots(),
summarized_dat(),
rc_tabs(),
demo_imp(),
reactiveValuesToList(p_hide)
)
list(
sess_outputs = sess_outputs,
sess_inputs = sess_inputs,
sess_rc = sess_rc, others = others
)
}
# new_folder <- paste("session_errors", Sys.time(), sep = "/")
# upload status and iox file
# others R objects to upload
upload_snapshot <- function(others = NULL) {
new_folder <- paste("rvent_errors", Sys.time(), sep = "/")
drive_mkdir(new_folder)
iox_files <- input$iox_files$datapath
lapply(iox_files, drive_upload, path = paste0(new_folder, "/"))
status <- get_status()
all_status <- list(status, others)
save(all_status, file = "status.RDA")
drive_upload("status.RDA", path = paste0(new_folder, "/"))
return(new_folder)
}
# callback for alert ----------
# if the user want to send an error report...
# https://stackoverflow.com/questions/34813231/create-a-popup-dialog-box-interactive
# type = "error"
modalCallback <- function(value) {
if (value == TRUE) {
withProgress(
newfolder <- upload_snapshot(),
message = "Sending data...please wait")
mail_text <- paste0("An error occured. Check the error report at ", newfolder)
send_email(mail_text = mail_text)
js$reset()
} else {
js$reset()
}
}