@@ -19,15 +19,25 @@ synapseLogin()
1919checkForProject <- function (projectId ) {
2020 length(synQuery(sprintf(' select id from project where projectId=="syn%s" LIMIT 1' , projectId ))) == 1
2121}
22- renderMyDocument <- function (reportType , projectId , nMonths , aclTeamOrder , outputFile ) {
22+ renderMyDocument <- function (reportType , projectId , nMonths , aclTeamOrder , useTeamGrouping , outputFile ) {
2323 res <- rmarkdown :: render(input = paste0(" ../../" , reportType , " .Rmd" ),
2424 output_file = outputFile ,
25- params = list (projectId = projectId , nMonths = nMonths , aclTeamOrder = aclTeamOrder ))
25+ params = list (projectId = projectId , nMonths = nMonths ,
26+ aclTeamOrder = aclTeamOrder ,
27+ useTeamGrouping = useTeamGrouping ))
2628}
2729
2830# Define UI for application that draws a histogram
2931ui <- shinyUI(fluidPage(
3032
33+ tags $ head(
34+ tags $ style(HTML("
35+ .shiny-output-error-validation {
36+ color: red;
37+ }
38+ " ))
39+ ),
40+
3141 # Application title
3242 titlePanel(" Synapse Project Usage" ),
3343
@@ -40,6 +50,7 @@ ui <- shinyUI(fluidPage(
4050 uiOutput(' teamList' ),
4151 selectInput(' reportType' , " Report Type:" , choices = c(" webAccess" , " downloads" ),
4252 selected = " downloads" ),
53+ checkboxInput(' useTeamGrouping' , ' Group by teams' , value = FALSE ),
4354 sliderInput(" months" , " Months" , min = 1 , max = 12 , value = 2 , step = 1 ),
4455 actionButton(' report' , " Make Report" )
4556 ),
@@ -58,6 +69,7 @@ ui <- shinyUI(fluidPage(
5869 p(" Then, click the 'Make Report' button, A 'Download' button will appear when the report has been generated." ),
5970 br(),
6071 p(" A PDF of this report can be generated in most browsers by printing the HTML to a PDF file." ),
72+ hr(),
6173 uiOutput(" results" )
6274 )
6375 )
@@ -69,6 +81,11 @@ server <- shinyServer(function(input, output) {
6981 myVals <- reactiveValues()
7082
7183 teamACL <- eventReactive(input $ lookup , {
84+ validate(
85+ need(try(checkForProject(isolate(input $ projectId ))),
86+ " That project doesn't exist. Please try again." )
87+ )
88+
7289 acl <- synGetEntityACL(paste0(" syn" , input $ projectId ))
7390 aclToMemberList(acl ) %> %
7491 filter(userName != " PUBLIC" , ! isIndividual )
@@ -87,18 +104,26 @@ server <- shinyServer(function(input, output) {
87104 res <- eventReactive(input $ report , {
88105 print(" Making Report" )
89106 withProgress(message = ' Making report' , value = 0 , {
90-
91- validate(
107+
108+ validate(
92109 need(try(checkForProject(input $ projectId )),
93110 " That project doesn't exist. Please try again." )
94- )
95-
111+ )
112+
113+ if (input $ useTeamGrouping ) {
114+ validate(
115+ need(try(input $ teamOrder != " " ),
116+ " Please select a Team ordering before generating a report." )
117+ )
118+ }
119+
96120 myVals [[' reportName' ]] <- ' myreport.html'
97121
98122 renderMyDocument(reportType = input $ reportType ,
99123 projectId = input $ projectId ,
100124 nMonths = input $ months ,
101125 aclTeamOrder = input $ teamOrder ,
126+ useTeamGrouping = input $ useTeamGrouping ,
102127 # outputFile=paste0(as.numeric(as.POSIXct(Sys.Date())), "_", reportType, ".html"),
103128 outputFile = ' myreport.html' )
104129 })
@@ -120,7 +145,7 @@ server <- shinyServer(function(input, output) {
120145
121146 output $ results <- renderUI({
122147 report <- res()
123- downloadButton(' download' )
148+ list (h3( " Results " ), downloadButton(' download' ) )
124149 })
125150})
126151
0 commit comments