diff --git a/.gitignore b/.gitignore index 4064c4e..53c9612 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -data/*.csv \ No newline at end of file +data/*.csv +notes \ No newline at end of file diff --git a/data/coffees.csv.example b/data/coffees.csv.example index 0c1c510..c69b255 100644 --- a/data/coffees.csv.example +++ b/data/coffees.csv.example @@ -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" diff --git a/eprilog.r b/eprilog.r index c2c5205..ff807e1 100644 --- a/eprilog.r +++ b/eprilog.r @@ -13,9 +13,10 @@ statusDocker <- Sys.getenv("statusDockerENV") # loading data from csv files brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1)) -machines <- read.csv(file = "./data/machines.csv") -grinders <- read.csv(file = "./data/grinders.csv") -coffees <- read.csv(file = "./data/coffees.csv") +machines <- (read.csv(file = "./data/machines.csv", header = TRUE, sep = ",", row.names = 1)) +grinders <- (read.csv(file = "./data/grinders.csv", header = TRUE, sep = ",", row.names = 1)) +coffees <- (read.csv(file = "./data/coffees.csv", header = TRUE, sep = ",", row.names = 1)) + ui <- navbarPage("EpriLog", @@ -79,6 +80,7 @@ ui <- navbarPage("EpriLog", numericInput("strongnessPercentage", "Strongness Percentage", value = "50"), numericInput("roastDarknessPercentage", "Roast Darkness Percentage", value = 50), 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 brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1)) - machines <- read.csv(file = "./data/machines.csv") - grinders <- read.csv(file = "./data/grinders.csv") - coffees <- read.csv(file = "./data/coffees.csv") + machines <- (read.csv(file = "./data/machines.csv", header = TRUE, sep = ",", row.names = 1)) + grinders <- (read.csv(file = "./data/grinders.csv", header = TRUE, sep = ",", row.names = 1)) + coffees <- (read.csv(file = "./data/coffees.csv", header = TRUE, sep = ",", row.names = 1)) - # Render History Table + # Render Brew History Table output$history = DT::renderDataTable( brews, server = TRUE, 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))) )) - 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))) - ) - - - - # insert new entry + # Creating new brew record + # observeEvent(input$createEntry, { # get currentTime currentTime <- Sys.time() # count up for new brew id 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 brews[nrow(brews) + 1, 1] <- newID brews[nrow(brews), 2] <- input$date @@ -162,6 +135,45 @@ server <- function(input, output, session){ 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") {