Skip to content

Commit 5cea51d

Browse files
committed
add button in preferences to update internal engine
1 parent d15bbbf commit 5cea51d

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

R-pkg/R/55_pref_page_module.R

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ pref_page_ui <- function(id) {
5151
"by default it is", tags$code("10 * n_core"),
5252
"(so that each core will generate 10 individuals",
5353
"of each batch)."
54+
),
55+
hr(),
56+
actionButton(
57+
ns("update_bin"),
58+
label = "Update DIYABC-RF internal engine",
59+
icon = icon("download"), width = "100%"
60+
),
61+
helpText(icon("clock"), "Downloading files may take some time."),
62+
uiOutput(ns("feedback_update")),
63+
helpText(
64+
icon("comment"),
65+
"DIYABC-RF internal engine is based on", tags$code("diyabc"),
66+
"and", tags$code("abcranger"), "softwares.",
67+
"See", tags$a(
68+
"DIYABC-RF GUI official website",
69+
href="https://diyabc.github.io/"
70+
),
71+
"for more details.",
72+
"It is recommended to update the internal engine",
73+
"from time to time (to get the latest bug fixes)."
5474
)
5575
)
5676
)
@@ -78,4 +98,66 @@ pref_page_server <- function(input, output, session) {
7898
shiny.maxRequestSize = as.integer(input$upload_file_size) * 1024^2
7999
)
80100
})
101+
102+
## update internal engine
103+
observeEvent(input$update_bin, {
104+
tmp_check <- execute_safely(dl_all_latest_bin(), session = session)
105+
106+
output$feedback_update <- renderUI({
107+
req(tmp_check$check_diyabc)
108+
req(tmp_check$check_abcranger)
109+
110+
tag_list1 <- switch(
111+
as.character(tmp_check$check_diyabc),
112+
"0" = tags$li(
113+
"Download of", tags$code("diyabc"), "succeeded."
114+
),
115+
"1" = tags$li(
116+
icon("warning"),
117+
"Download of", tags$code("diyabc"), "failed.",
118+
"If the issue persists, please contact DIYABC-RF support."
119+
),
120+
"-1" = tags$li(
121+
tags$code("diyabc"), "was already the latest version."
122+
),
123+
NULL
124+
)
125+
126+
tag_list2 <- switch(
127+
as.character(tmp_check$check_abcranger),
128+
"0" = tags$li(
129+
"Download of", tags$code("abcranger"), "succeeded."
130+
),
131+
"1" = tags$li(
132+
icon("warning"),
133+
"Download of", tags$code("abcranger"), "failed.",
134+
"If issue persists, please contact abcranger-RF support."
135+
),
136+
"-1" = tags$li(
137+
tags$code("abcranger"), "was already the latest version."
138+
),
139+
NULL
140+
)
141+
142+
143+
if(!is.null(tag_list1) || !is.null(tag_list2)) {
144+
145+
tmp_icon <- icon("info-circle")
146+
147+
if(any(
148+
c(tmp_check$check_diyabc, tmp_check$check_abcranger) != 0
149+
)) {
150+
tmp_icon <- icon("warning")
151+
}
152+
153+
tagList(helpText(tags$p(
154+
tmp_icon, "Download status:",
155+
tags$ul(tag_list1, tag_list2)
156+
)))
157+
158+
} else {
159+
NULL
160+
}
161+
})
162+
})
81163
}

0 commit comments

Comments
 (0)