From abdaedb63a5e93e65091d7199886d65bdbee5b1e Mon Sep 17 00:00:00 2001 From: "friedemann.blume" Date: Fri, 12 Jan 2024 19:25:14 +0100 Subject: [PATCH] =?UTF-8?q?v1.0=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 14 ++++++- data/brews.csv.example | 1 + data/coffees.csv.example | 2 + data/grinders.csv.example | 2 + data/machines.csv.example | 2 + eprilog.r | 80 ++++++++++++++++++++++++--------------- 7 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 data/brews.csv.example create mode 100644 data/coffees.csv.example create mode 100644 data/grinders.csv.example create mode 100644 data/machines.csv.example diff --git a/.gitignore b/.gitignore index 07f43b8..4064c4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -data/* \ No newline at end of file +data/*.csv \ No newline at end of file diff --git a/README.md b/README.md index daf1b55..5acea67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ -# eprilog +# EpriLog + +A little shiny r web app to log and view your espresso settings for le perfect taste! + + +## Setup: + +in the `data` folder rename the `*.example` files to end just with `*.csv` + +`docker-compose up -d` + +-> visit http://localhost:3839 -A little shiny r web app to log and view your espresso settings for le perfect taste! \ No newline at end of file diff --git a/data/brews.csv.example b/data/brews.csv.example new file mode 100644 index 0000000..f141831 --- /dev/null +++ b/data/brews.csv.example @@ -0,0 +1 @@ +"","ID","Date","Time","Alias","CoffeeName","GrindTime","GrindSize","FlowResult","Taste","WDT","BrewTemp","BrewPreinfusion","BrewPreinfusionWait","BrewTime","GrinderDevice","MachineDevice","PortaInsert","Notes" diff --git a/data/coffees.csv.example b/data/coffees.csv.example new file mode 100644 index 0000000..0c1c510 --- /dev/null +++ b/data/coffees.csv.example @@ -0,0 +1,2 @@ +"","id","brandName","coffeeName","alias","expDate","arabicaPercentage","robustaPercentage","sourPercentage","strongnessPercentage","roastDarknessPercentage","originCountry" + diff --git a/data/grinders.csv.example b/data/grinders.csv.example new file mode 100644 index 0000000..ed0b48c --- /dev/null +++ b/data/grinders.csv.example @@ -0,0 +1,2 @@ +"","id","name","modelnumber","year" +"1","0001","Sage Smart Grinder Pro","SCG820BSS4EEU1","2020" diff --git a/data/machines.csv.example b/data/machines.csv.example new file mode 100644 index 0000000..57d8a1d --- /dev/null +++ b/data/machines.csv.example @@ -0,0 +1,2 @@ +"","id","name","modelnumber","year","notes" + diff --git a/eprilog.r b/eprilog.r index a157933..6b403d5 100644 --- a/eprilog.r +++ b/eprilog.r @@ -1,12 +1,10 @@ -##### -# -# Author: PMF -# -##### -require(shiny) -#theme_set(theme_minimal()) +################# +# Author: PMF # +################# -# preperation +require(shiny) + +# preperation: # Get the status if r shiny is running in docker or not readRenviron("./.status-docker") statusDocker <- Sys.getenv("statusDockerENV") @@ -21,11 +19,12 @@ ui <- navbarPage("EpriLog", sidebarPanel( h1('New Entry'), dateInput("date", "Date:"), #maybe better to automatically generate with time + selectInput("alias", "Whats the nick name of the coffee?", coffees$alias, multiple = FALSE), selectInput("coffeeName", "Whats the name of the coffee?", coffees$coffeeName, multiple = FALSE), # Grind Time - sliderInput("gindTime", "Ginding Time", value = 14, min = 0, max = 30), + sliderInput("grindTime", "Ginding Time", value = 14, min = 0, max = 30), # Grind Size - sliderInput("gindSize", "Ginding Size", value = 7, min = 0, max = 70), + sliderInput("grindSize", "Ginding Size", value = 7, min = 0, max = 70), # Flow rate (0 = none, 10 = perfect, 20 = water) sliderInput("flowResult", "Flow rate (10 is Perfect):", value = 10, min = 0, max = 20), # Taste Rating (sour = none, 10 = perfect, 20 = bitter) @@ -47,7 +46,7 @@ ui <- navbarPage("EpriLog", # Siebeinsatz numericInput("portaInsert", "Siever insert size", value = 12, min = 0, max = 100), # Notes - textInput("notes", "Notes:", value = "Keine Notizen"), + textInput("notes", "Notes:", value = 'Keine Notizen'), # submit actionButton("createEntry", "Submit new entry!", icon("save")), ) @@ -72,40 +71,59 @@ 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(1,3,9,10,11,12,13,14,15))) + 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, { - # load current brews history - 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) + 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 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 + brews[nrow(brews), 4] <- input$alias + brews[nrow(brews), 5] <- input$coffeeName + brews[nrow(brews), 6] <- input$grindTime + brews[nrow(brews), 7] <- input$grindSize + brews[nrow(brews), 8] <- input$flowResult + brews[nrow(brews), 9] <- input$taste + brews[nrow(brews), 10] <- input$wdt + brews[nrow(brews), 11] <- input$brewTemp + brews[nrow(brews), 12] <- input$brewPreinfusion + brews[nrow(brews), 13] <- input$brewPreinfusionWait + brews[nrow(brews), 14] <- input$brewTime + brews[nrow(brews), 15] <- input$grinderDevice + brews[nrow(brews), 16] <- input$machineDevice + brews[nrow(brews), 17] <- input$portaInsert + brews[nrow(brews), 18] <- input$notes # save changes to .csv file - print("New entry added:") - print(brews) write.csv(brews, file = "./data/brews.csv") })