This commit is contained in:
friedemann.blume 2024-01-12 19:25:14 +01:00
parent 0ba52843de
commit abdaedb63a
7 changed files with 69 additions and 34 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
data/*
data/*.csv

View File

@ -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!

1
data/brews.csv.example Normal file
View File

@ -0,0 +1 @@
"","ID","Date","Time","Alias","CoffeeName","GrindTime","GrindSize","FlowResult","Taste","WDT","BrewTemp","BrewPreinfusion","BrewPreinfusionWait","BrewTime","GrinderDevice","MachineDevice","PortaInsert","Notes"

2
data/coffees.csv.example Normal file
View File

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

View File

@ -0,0 +1,2 @@
"","id","name","modelnumber","year"
"1","0001","Sage Smart Grinder Pro","SCG820BSS4EEU1","2020"

View File

@ -0,0 +1,2 @@
"","id","name","modelnumber","year","notes"

View File

@ -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")
})