# #Shiny web application # ::Asitav Sen:: # ******Important******* # Please check the template. This code supports only single select option. In the csv, separate the answer options with "/" # library(shiny) library(DBI) library(shinymanager) library(DT) library(excelR) library(bslib) library(dplyr) library(shinydashboard) library(shinydashboardPlus) library(dbplyr) source("utilities.R") source("helper_ui.R") source("helper_server.R") # Define UI ui <- secure_app(uidet, enable_admin = TRUE) # Define server logic server <- function(input, output) { onStop(db.disc, session = getDefaultReactiveDomain()) res_auth <- secure_server( check_credentials = check_credentials("cred.sqlite", passphrase = "kJuyhG657Hj&^%gshj*762hjsknh&662") ) output$menu <- renderMenu({ if (res_auth$admin == FALSE) { survey.menu } else admin.menu }) output$grouptable <- renderUI({ tablelist <- lapply(1:no.of.dims, function(i) { tablename <- paste("table", i, unique(question.dfs[[i]]$segment), sep = "") list(tabPanel( unique(question.dfs[[i]]$segment), h2(unique(question.dfs[[i]]$segment)), excelOutput(tablename, height = "900px") )) }) do.call(tabsetPanel, unlist(tablelist, recursive = FALSE)) }) for (i in 1:no.of.dims) { local({ mdf <- question.dfs[[i]] tablename <- paste("table", i, unique(question.dfs[[i]]$segment), sep = "") output[[tablename]] <- renderExcel({ nrmdf <- nrow(mdf) dat <- data.frame(matrix(nrow = nrow(use_cases), ncol = nrow(mdf) + 2)) colnames(dat) <- c("Strategic Pillar","Use Cases", mdf$question) dat[, 1] <- use_cases$strategy dat[, 2] <- use_cases$use_cases qlist <- list(0,0) olist <- strsplit(mdf$answers, split = "/") excelTable( data = dat, columns = data.frame( title = c("Strategic Pillar","Use Cases", mdf$question), type = c("text","text", rep("dropdown", nrow(mdf))), source = I(append(qlist, olist)) ), #autoWidth = TRUE, #autoFill = TRUE, #wordWrap = TRUE, columnSorting = FALSE, rowDrag = FALSE, allowDeleteColumn = FALSE, allowRenameColumn = FALSE, allowInsertRow = FALSE, allowInsertColumn = FALSE, allowDeleteRow = FALSE, tableHeight = 400 ) }) }) } } # Run the application shinyApp(ui = ui, server = server)