SHARE
TWEET

Untitled

a guest Jul 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(shiny)
  2. library(rhandsontable)
  3. library(shinythemes)
  4.  
  5.  
  6. df <- data.frame(
  7.  
  8.   "project number" = c( ''),
  9.   "project name" = c( ''),
  10.   "description" = c(''),
  11.   "estimated delivery date" = seq(from = Sys.Date(), by = "days", length.out = 10),
  12.   "actual delivery date" =seq(from = Sys.Date(), by = "days", length.out = 10),
  13.   "current status " = c(''),
  14.   "note" = c(''),
  15.   "GA status" =  factor(NA, c('approved','awaiting','no needed')),
  16.   "GA hours" = c(''),
  17.   "GA actual" = c(''),
  18.   "SSEC hours" = c(''),
  19.   "SSEC actual" = c(''),
  20.   "steel hours" = c(''),
  21.   "steel actual" = c(''),
  22.   "steel drawing sent" = FALSE,
  23.   "steel drawing date" = seq(from = Sys.Date(), by = "days", length.out = 10),
  24.   "tarp hours" = c(''),
  25.   "tarp actual" = c(''),
  26.   "tarp drawing sent" = FALSE,
  27.   "tarp drawing date" = seq(from = Sys.Date(), by = "days", length.out = 10),
  28.   "installation hours " = c(''),
  29.   "installation actual " = c(''),
  30.   "generate component list " = FALSE,
  31.   "drawings checked"= FALSE,
  32.   "tarp drawing" = FALSE,
  33.   "estimated completion date"= c(''),
  34.   "material"= factor(NA, c("Armourtex", "Landmark", "Armourtex FR", "Armourtex White/Silver")),
  35.   "drawing availability date"= c(''),
  36.   "tarp production status" = c(""),
  37.   "estimated completion date" = c(""),
  38.   "estimated completion date" = c(""),
  39.   "drawing availability date" = c(""),
  40.   "rolling group" = c(""),
  41.   "rolling date" = c(""),
  42.   "Hoop group" = c(""),
  43.   "Hoop date" = c(""),
  44.   "mounting rail group" = c(""),
  45.   "mounting rail date" = c(""),
  46.   "P-B group" = c(""),
  47.   "P-B date" = c(""),
  48.   "Posts group" = c(""),
  49.   "Posts date" = c(""),
  50.   "Endwall group" = c(""),
  51.   "Endwall date" = c(""),
  52.   "galv sent date" = seq(from = Sys.Date(), by = "days", length.out = 10),
  53.   "galv return date" = seq(from = Sys.Date(), by = "days", length.out = 10),
  54.   "tarp received" = FALSE,
  55.   "steel received" = FALSE,
  56.   "instruction list" = FALSE,
  57.   "packing" = FALSE,
  58.   "delivery target date" = seq(from = Sys.Date(), by = "days", length.out = 1),
  59.   "project comment" = c(""),
  60.   stringsAsFactors = FALSE, check.names = FALSE)
  61. fields <- c("project number",
  62.             "project name",
  63.             "description",
  64.             "estimated delivery date")
  65. #########################################
  66. shinyApp(
  67.   ui = tagList(
  68.   navbarPage(
  69.       theme = shinytheme("flatly"),  
  70.       "Group Production Portal",
  71.       tabPanel("production panel",
  72.                sidebarPanel(
  73.                  fileInput("file", "File input:"),
  74.                  textInput("project number", "Project Number"),
  75.                  textInput("project name", "Project Name"),
  76.                  textInput("description", "Job Description: "),
  77.                  dateInput("estimated delivery date",h3("Due Date")),
  78.                  
  79.                  #sliderInput("slider", "Slider input:", 1, 100, 30),
  80.                  tags$h5("Deafult actionButton:"),
  81.                  
  82.                  #actionButton("actionAdd", "Add Project"),
  83.                  
  84.                  
  85.                  tags$h5("actionButton with CSS class:"),
  86.                  actionButton("actionAdd", "Add Project", class = "btn-primary")
  87.                  , width = 2
  88.                ),
  89.                mainPanel(
  90.                  tabsetPanel(
  91.                    tabPanel("Resource Allocation", "This panel is intentionally left blank"
  92.                            
  93.                            
  94.                            
  95.                    ),
  96.                    tabPanel("Timeline",
  97.                             h4("Table"),
  98.                             DT::dataTableOutput("responses", width = 500), tags$hr(),
  99.                             h4("Verbatim text output"),
  100.                             verbatimTextOutput("txtout"),
  101.                             h1("Header 1"),
  102.                             h2("Header 2"),
  103.                             h3("Header 3"),
  104.                             h4("Header 4"),
  105.                             h5("Header 5")),
  106.                    tabPanel("Gantt Chart", "This panel is intentionally left blank")
  107.                  )
  108.                )
  109.       ),
  110.       tabPanel("logistic", rHandsontableOutput("table")
  111.                
  112.                
  113.                
  114.                
  115.       ),
  116.       tabPanel("drafting", rHandsontableOutput("table1")
  117.       ),
  118.       tabPanel("tarp production", rHandsontableOutput("table2")
  119.       ),
  120.       tabPanel(" steel fabrication",  rHandsontableOutput("table3"))
  121.     )
  122.   ),
  123.   #########################################################################################SERVERWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
  124.   server = function(input, output, session) {
  125.     responses <-df
  126.     saveData <- function(data) {
  127.       data <- as.data.frame(t(data))
  128.       if (exists("responses")) {
  129.         responses <<- rbind.fill(responses, data)
  130.       } else {
  131.         responses <<- data
  132.       }
  133.     }
  134.    
  135.     loadData <- function() {
  136.       if (exists("responses")) {
  137.         responses
  138.       }
  139.     }
  140.     formData <- reactive({
  141.       data <- sapply(fields, function(x) input[[x]])
  142.       data
  143.     })
  144.     observeEvent(input$actionAdd, {
  145.       saveData(formData())
  146.     })
  147.     output$responses <- DT::renderDataTable({
  148.       input$actionAdd
  149.       loadData()
  150.     })    
  151.  
  152.     output$txtout <- renderText({
  153.       paste(input$txt, input$slider, format(input$date), sep = ", ")
  154.     })
  155.     df<-responses
  156.     output$table = renderRHandsontable({
  157.     rhandsontable(responses[,c("project number","project name","description","estimated delivery date","actual delivery date","current status ", "drawings checked", "tarp received",  
  158.                           "steel received","instruction list", "packing", "delivery target date",
  159.                           "project comment"  )], search = TRUE,columnSorting = TRUE) %>%
  160.     hot_context_menu(customOpts = list(search = list(name = "Search",
  161.                                                          callback = htmlwidgets::JS(
  162.                                                            "function (key, options) {
  163.                          var srch = prompt('Search criteria');
  164.                          this.search.query(srch);
  165.                          this.render();
  166.                        }"))))
  167.      
  168.     })
  169.     #####################################################################################################
  170.     ##############################################drafting
  171.    
  172.    
  173.    
  174.    
  175.    
  176.    
  177.     output$table1 = renderRHandsontable({
  178.      
  179.       if (!is.null(input$hot)) {
  180.         DF = hot_to_r(input$hot)
  181.       } else {
  182.         DF = df
  183.       }
  184.      
  185.      
  186.       rhandsontable(DF[,c("project number","project name","description","estimated delivery date","GA status", "GA hours", "GA actual","SSEC hours", "SSEC actual", "steel hours","steel actual", "tarp hours", "tarp actual","installation hours ", "installation actual "  )], search = TRUE,columnSorting = TRUE)
  187.      
  188.     })
  189.    
  190.     ###############################################################################tarp table
  191.    
  192.     output$table2 = renderRHandsontable({
  193.      
  194.       if (!is.null(input$hot)) {
  195.         DF = hot_to_r(input$hot)
  196.       } else {
  197.         DF = df
  198.       }
  199.      
  200.      
  201.       rhandsontable(DF[,c("project number","project name","description","estimated delivery date","drawings checked","tarp drawing sent","material", "drawing availability date", "tarp production status","estimated completion date" )], search = TRUE,columnSorting = TRUE)%>% hot_col("material", type = "dropdown" )
  202.      
  203.     })
  204.    
  205.     ################################################### Steel Fabrication
  206.    
  207.     output$table3 = renderRHandsontable({
  208.      
  209.       if (!is.null(input$hot)) {
  210.         DF = hot_to_r(input$hot)
  211.       } else {
  212.         DF = df
  213.       }
  214.       rhandsontable(DF[,c("project number","project name","description","estimated delivery date","drawings checked", "rolling group", "rolling date","Hoop group", "Hoop date","mounting rail group",
  215.                           "mounting rail date", "P-B group", "P-B date","Posts group",  "Posts date", "Endwall group", "Endwall date","galv sent date", "galv return date"     )], search = TRUE,columnSorting = TRUE)
  216.      
  217.     })
  218.    
  219.    
  220.   }
  221. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top