hopefully fix for creating new record

This commit is contained in:
Friedemann 2024-01-12 14:43:27 +00:00
parent 3b53614737
commit 88fbaa37a2
1 changed files with 23 additions and 37 deletions

View File

@ -3,29 +3,14 @@
# Author: PMF
#
#####
require(shiny)
#theme_set(theme_minimal())
# preperation
# Get the status if r shiny is running in docker or not
readRenviron("./.status-docker")
statusDocker <- Sys.getenv("statusDockerENV")
ui <- navbarPage("EpriLog",
tabPanel("Eprilog",
sidebarLayout(
@ -76,8 +61,6 @@ ui <- navbarPage("EpriLog",
)
)
server <- function(input, output){
# loading data from csv files
@ -89,8 +72,9 @@ server <- function(input, output){
# Render History Table
output$history = DT::renderDataTable(
brews, server = TRUE,
options = list(order = list(3, "desc")))
# columnDefs = list(list(visible = FALSE, targets = c(4)))))
options = list(order = list(3, "desc")
columnDefs = list(list(visible = FALSE, targets = c(1,3,9,10,11,12,13,14,15)))
))
# insert new entry
@ -99,26 +83,28 @@ server <- function(input, output){
brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1))
# get currentTime
currentTime <- Sys.time()
# count up for new brew id
newID <- (brew$id + 1)
# add new line entry to history
brews[nrow(brews) + 1,] = list(
(brews$id + 1),
input$date,
currentTime,
input$coffeeName,
input$grindTime,
input$grindSize,
input$flowResult,
input$taste,
input$wdt,
input$brewTemp,
input$brewPreinfusion,
input$brewTime,
input$grinderDevice,
input$machineDevice,
input$portaInsert,
input$notes
)
brews[nrow(brews) + 1, 1] <- newID
brews[nrow(brews), 2] <- input$date
brews[nrow(brews), 3] <- currentTime
brews[nrow(brews), 4] <- input$coffeeName
brews[nrow(brews), 5] <- input$grindTime
brews[nrow(brews), 6] <- input$grindSize
brews[nrow(brews), 7] <- input$flowResult
brews[nrow(brews), 8] <- input$taste
brews[nrow(brews), 9] <- input$wdt
brews[nrow(brews), 10] <- input$brewTemp
brews[nrow(brews), 11] <- input$brewPreinfusion
brews[nrow(brews), 12] <- input$brewTime
brews[nrow(brews), 13] <- input$grinderDevice
brews[nrow(brews), 14] <- input$machineDevice
brews[nrow(brews), 15] <- input$portaInsert
brews[nrow(brews), 16] <- input$notes
# save changes to .csv file
print("New entry added:")
print(brews)
write.csv(brews, file = "./data/brews.csv")
})