Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shiny 基于用户限制SelectInput_Shiny_User Input_Shiny Reactivity_Selectinput - Fatal编程技术网

Shiny 基于用户限制SelectInput

Shiny 基于用户限制SelectInput,shiny,user-input,shiny-reactivity,selectinput,Shiny,User Input,Shiny Reactivity,Selectinput,我目前正在尝试构建一个应用程序来可视化员工的绩效。我正在尝试创建一个受密码保护的仪表板,其中标记为经理的用户可以查看所有其他用户统计数据,而非经理用户只能查看自己的统计数据。但是我不能让它工作。这是我到目前为止所拥有的。用户列表是与其用户名(2个变量)匹配的员工,凭据列表是用户名和密码(2个变量)。问题在于观察功能imo的某些地方。如果用户不是管理员,我希望他们的selectinput按钮锁定在自己的姓名上。会话$user==用户$user 任何指导都将不胜感激 data<-read.cs

我目前正在尝试构建一个应用程序来可视化员工的绩效。我正在尝试创建一个受密码保护的仪表板,其中标记为经理的用户可以查看所有其他用户统计数据,而非经理用户只能查看自己的统计数据。但是我不能让它工作。这是我到目前为止所拥有的。用户列表是与其用户名(2个变量)匹配的员工,凭据列表是用户名和密码(2个变量)。问题在于观察功能imo的某些地方。如果用户不是管理员,我希望他们的selectinput按钮锁定在自己的姓名上。会话$user==用户$user

任何指导都将不胜感激

data<-read.csv("Data/data.csv")
data$Create.Date<-as.Date(data$Create.Date)
credentials<-unique(read.csv("Data/credentials.csv"))

ui<-secure_app(head_auth=tags$script(inactivity),
             dashboardPage(

dashboardHeader(title = "Services Dashboard"),

dashboardSidebar(
  selectInput("name","Select a User", users[,1]),
  dateRangeInput("date", "Select a Date Range",format="mm-dd-yy"),
  actionButton("go", "Go")
),

dashboardBody(
  plotlyOutput("plot"),
  tableOutput("table"),
)
)
)

server<-function(input, output, session){

res_auth<-secure_server(check_credentials = check_credentials(credentials))

user<-reactive({
  session$user
}
)

manager<-reactive({
  if(user()=="manager"){
    return(TRUE)
  }else{
    return(FALSE)
  }
})

observe({
  if(manager()==FALSE){
    updateSelectInput(session, "names", "Select A User", 
choices=users$user[users$username==user()])
  }
 })

    
 masterdata<-eventReactive(input$go, {
  data %>%
    filter(
      as.Date(Create.Date) >= as.Date(input$date[1]),
      as.Date(Create.Date) <= as.Date(input$date[2]),
      Staff.Created == input$name)
  })

 aggdata<-eventReactive(input$go, {
  data %>%
    filter(
      as.Date(Create.Date) >= as.Date(input$date[1]),
      as.Date(Create.Date) <= as.Date(input$date[2]),
      Staff.Created == input$name)%>%
    summarise(`Services Provided in Period Selected`=sum(count))
    
 })

 output$plot<-renderPlotly({
  ggplot(masterdata(), 
         aes(x=Create.Date, y=count, label=count),
         xmin=input$date[1], xmax=input$date[2], ymin=0, fill = input$date)+
    xlab("Date")+
    ylab("Services Provided")+
    geom_line(group=1, colour="#000099")+
    theme(axis.text.x = element_text(angle=45, vjust=0.5, size=8))+
    scale_x_date(breaks = "days", date_labels = "%m.%d")+
    geom_point()
    })

  output$table<-renderTable({
  aggdata()
 })

}

shinyApp(ui = ui, server = server)
dataUse
req()
用于所有观察者服务器端的所有用户输入变量
input$abc
和反应函数
user()
manager()
等。