the small bugs are the most nasty ones ;D

This commit is contained in:
friedemann.blume 2024-01-12 22:03:44 +01:00
parent 62d449510b
commit f61c0bc375
3 changed files with 53 additions and 40 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
data/*.csv data/*.csv
notes

View File

@ -1,2 +1,2 @@
"","id","brandName","coffeeName","alias","expDate","arabicaPercentage","robustaPercentage","sourPercentage","strongnessPercentage","roastDarknessPercentage","originCountry" "","id","brandName","coffeeName","alias","expDate","arabicaPercentage","robustaPercentage","sourPercentage","strongnessPercentage","roastDarknessPercentage","originCountry","creationDate"

View File

@ -13,9 +13,10 @@ statusDocker <- Sys.getenv("statusDockerENV")
# loading data from csv files # loading data from csv files
brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1)) brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1))
machines <- read.csv(file = "./data/machines.csv") machines <- (read.csv(file = "./data/machines.csv", header = TRUE, sep = ",", row.names = 1))
grinders <- read.csv(file = "./data/grinders.csv") grinders <- (read.csv(file = "./data/grinders.csv", header = TRUE, sep = ",", row.names = 1))
coffees <- read.csv(file = "./data/coffees.csv") coffees <- (read.csv(file = "./data/coffees.csv", header = TRUE, sep = ",", row.names = 1))
ui <- navbarPage("EpriLog", ui <- navbarPage("EpriLog",
@ -79,6 +80,7 @@ ui <- navbarPage("EpriLog",
numericInput("strongnessPercentage", "Strongness Percentage", value = "50"), numericInput("strongnessPercentage", "Strongness Percentage", value = "50"),
numericInput("roastDarknessPercentage", "Roast Darkness Percentage", value = 50), numericInput("roastDarknessPercentage", "Roast Darkness Percentage", value = 50),
textInput("originCountry", "Origin County of the Coffee", value = "Coffee World"), textInput("originCountry", "Origin County of the Coffee", value = "Coffee World"),
actionButton("addCoffee", "Save new entry!", icon("save")),
) )
) )
)) ))
@ -88,11 +90,11 @@ server <- function(input, output, session){
# loading data from csv files # loading data from csv files
brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1)) brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1))
machines <- read.csv(file = "./data/machines.csv") machines <- (read.csv(file = "./data/machines.csv", header = TRUE, sep = ",", row.names = 1))
grinders <- read.csv(file = "./data/grinders.csv") grinders <- (read.csv(file = "./data/grinders.csv", header = TRUE, sep = ",", row.names = 1))
coffees <- read.csv(file = "./data/coffees.csv") coffees <- (read.csv(file = "./data/coffees.csv", header = TRUE, sep = ",", row.names = 1))
# Render History Table # Render Brew History Table
output$history = DT::renderDataTable( output$history = DT::renderDataTable(
brews, server = TRUE, brews, server = TRUE,
options = list(order = list(3, "desc"), options = list(order = list(3, "desc"),
@ -100,43 +102,14 @@ server <- function(input, output, session){
columnDefs = list(list(visible = FALSE, targets = c(1,2,3,10,11,12,13,14,15,16))) columnDefs = list(list(visible = FALSE, targets = c(1,2,3,10,11,12,13,14,15,16)))
)) ))
output$coffees = DT::renderDataTable( # Creating new brew record
coffees, server = TRUE, #
options = list(scrollX = TRUE)
#colnames = c("ID", "Brand Name", "Coffee Name", )
#options = list(order = list(3, "desc")
#columnDefs = list(list(visible = FALSE, targets = c(1,2,10,11,12,13,14,15,16)))
)
# insert new entry
observeEvent(input$createEntry, { observeEvent(input$createEntry, {
# get currentTime # get currentTime
currentTime <- Sys.time() currentTime <- Sys.time()
# count up for new brew id # count up for new brew id
newID <- (runif(1, 1, 10000000000)) newID <- (runif(1, 1, 10000000000))
# For debugging only
#
# print(input$date)
# print(currentTime)
# print(input$alias)
# print(input$coffeeName)
# print(input$grindTime)
# print(input$grindSize)
# print(input$flowResult)
# print(input$taste)
# print(input$wdt)
# print(input$brewTemp)
# print(input$brewPreinfusion)
# print(input$brewPreinfusionWait)
# print(input$brewTime)
# print(input$grinderDevice)
# print(input$machineDevice)
# print(input$portaInsert)
# print(input$notes)
# add new line entry to history # add new line entry to history
brews[nrow(brews) + 1, 1] <- newID brews[nrow(brews) + 1, 1] <- newID
brews[nrow(brews), 2] <- input$date brews[nrow(brews), 2] <- input$date
@ -162,6 +135,45 @@ server <- function(input, output, session){
session$reload() session$reload()
}) })
# Render Coffees Table for Configuration Page
#
output$coffees = DT::renderDataTable(
coffees, server = TRUE,
options = list(scrollX = TRUE)
#colnames = c("ID", "Brand Name", "Coffee Name", )
#options = list(order = list(3, "desc")
#columnDefs = list(list(visible = FALSE, targets = c(1,2,10,11,12,13,14,15,16)))
)
# Add new Coffee entry
#
observeEvent(input$addCoffee, {
# get currentTime
creationDate <- Sys.time()
# count up for new brew id
newID <- (runif(1, 1, 10000000000))
# inserting new row
coffees[nrow(coffees) + 1, 1] <- newID
coffees[nrow(coffees), 2] <- input$brandName
coffees[nrow(coffees), 3] <- input$coffeeName
coffees[nrow(coffees), 4] <- input$alias
coffees[nrow(coffees), 5] <- input$expDate
coffees[nrow(coffees), 6] <- input$arabicaPercentage
coffees[nrow(coffees), 7] <- input$robustaPercentage
coffees[nrow(coffees), 8] <- input$sourPercentage
coffees[nrow(coffees), 9] <- input$strongnessPercentage
coffees[nrow(coffees), 10] <- input$roastDarknessPercentage
coffees[nrow(coffees), 11] <- input$originCountry
coffees[nrow(coffees), 12] <- creationDate
# save changes to .csv file
write.csv(coffees, file = "./data/coffees.csv")
showNotification("New Coffee added.")
#session$reload()
})
} }
if (statusDocker == "false") { if (statusDocker == "false") {