我正在尝试在一个闪亮的应用程序中创建一个消息系统,当某些任务完成时会收到通知,但目前它不起作用:
用户界面:
library(shinydashboard)
dashboardPage(
dashboardHeader(title = "My Dashboard",
dropdownMenuOutput("messageMenu")
),
dashboardSidebar(),
dashboardBody("Hi", actionButton("go", label="DO STUFF!"), actionButton("go2", label="DO MORE STUFF!"))
)
服务器:
library(shinydashboard)
shinyServer(function(input, output) {
M_Store <- reactiveValues(DF = data.frame(
from = c("Admininstrator", "New User", "Support"),
message = c(
"Sales are steady this month.",
"How do I register?",
"The new server is ready."
),
stringsAsFactors = FALSE
))
output$messageMenu <- renderMenu({
msgs <- apply(M_Store$DF, 1, function(row) {
messageItem(from = row[["from"]], message = row[["message"]])
})
dropdownMenu(type = "messages", .list = msgs)
})
reactive({
input$go
message("Button pressed. Execute analysis!")
message("Pretend analysis got done!")
message("Now want to send a message that the analysis is done!")
M_Store$DF <- rbind(isolate(M_Store$DF), data.frame(from="Meee", message="Done message!"))
})
reactive({
input$go2
message("Second button pressed. Execute second analysis!")
message("Some computation!")
message("Want to update the user on progress with a message!")
M_Store$DF <- rbind(isolate(M_Store$DF), data.frame(from="Someone else!", message="Progress message2!"))
message("More computations....")
message("Done, want to tell user I'm done!")
M_Store$DF <- rbind(isolate(M_Store$DF), data.frame(from="Someone else!", message="Done message2!"))
})
})
你看出我的意图了吗?我希望能够推送分析或行动进展的消息。我认为在 M_Store 中有一个反应式 DF 意味着每当它被操纵时,任何依赖它的东西都是如此,即 output$messageMenu。
我想做的类似于闪亮的进度条:当您进行计算时,您只需更新它们的变量,它们就会在屏幕上发生变化。
谢谢,本。