我的Shiny应用程序具有系统功能,可能需要一段时间。当我的应用程序继续执行该功能时,我想显示一条消息,例如“正在加载...”或正在加载。完成后,我希望动画消失或显示验证。我的功能看起来像这样:
observeEvent(input$send, {
shinyalert("Your request has been sent! Please wait. An email will be sent to you in the next few minutes.",type = "success")
#-------- SYSTEM FUNCTION --------#
sys <- paste('/home/user/sen2extract/blabla.sh ',
shpWGS$V1,' ',
paste(input$indice, collapse = ','), ' ',
input$dates[1], ' ',
input$dates[2],
sep = "")
system(sys)
答案 0 :(得分:1)
类似的东西:
// table
< table cellspacing="0" cellpadding="2" width="100%" >
#foreach($mmm in $ctx.result.rows)
< tr>
< td align="center" width="5%" > 11111111</td>
< /tr>
#end
</table>
我使用library(shiny)
library(shinyjs)
css <- "
.busy {
position: fixed;
z-index: 1000;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -50px;
display: none;
background-color: rgba(230,230,230,.8);
text-align: center;
padding-top: 20px;
padding-left: 30px;
padding-bottom: 40px;
padding-right: 30px;
border-radius: 5px;
}"
ui <- fluidPage(
useShinyjs(),
tags$head(tags$style(css)),
tags$div(class = "busy",
tags$img(src = "https://loading.io/spinners/comets/lg.comet-spinner.gif")),
actionButton("go", "Go")
)
server <- function(input, output, session){
observeEvent(input$go, {
runjs("$('.busy').show();")
}, priority = 1, ignoreInit = TRUE)
observeEvent(input$go, {
Sys.sleep(5)
runjs("$('.busy').hide();")
}, ignoreInit = TRUE)
}
shinyApp(ui, server)
模拟您的Sys.sleep
。