This commit is contained in:
friedemann.blume 2024-01-12 14:57:59 +01:00
parent 427c7b219e
commit 3b53614737
5 changed files with 136 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
data/*

1
.status-docker Normal file
View File

@ -0,0 +1 @@
statusDockerENV='false'

View File

@ -0,0 +1 @@
statusDockerENV='true'

View File

@ -1,2 +1,3 @@
# eprilog
A little shiny r web app to log and view your espresso settings for le perfect taste!

132
eprilog.r Normal file
View File

@ -0,0 +1,132 @@
#####
#
# 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(
mainPanel(
h1('Brew History'),
DT::dataTableOutput('history')
),
sidebarPanel(
h1('New Entry'),
dateInput("date", "Date:"), #maybe better to automatically generate with time
selectInput("coffeeName", "Whats the name of the coffee?", coffees$coffeeName, multiple = FALSE),
# Grind Time
sliderInput("gindTime", "Ginding Time", value = 14, min = 0, max = 30),
# Grind Size
sliderInput("gindSize", "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)
sliderInput("taste", "Taste (0=Sour, 10=perfect, 20=bitter):", value = 10, min = 0, max = 20),
# WDT Tool
checkboxInput("wdt", "WDT Tool used?", value = TRUE),
# Brew Temp
numericInput("brewTemp", "Brew Temperature:", value = 94, min = 0, max = 110),
# Brew preinfusion time
numericInput("brewPreinfusion", "Brew Preinfusion Time", value =2, min = 0, max = 60),
# Brew wait Time after Preinfusion
numericInput("brewPreinfusionWait", "Brew Wait after Preinfusion Time", value = 5, min = 0, max = 60),
# Brew Time
numericInput("brewTime", "Brew Time after Preinfusion Time", value = 21, min = 0, max = 100),
# Grinder Device
selectInput("grinderDevice", "Which Grinder was used?", grinders$name, multiple = FALSE),
# Espresso Device
selectInput("machineDevice", "Which Espresso machine was used?", machines$name, multiple = FALSE),
# Siebeinsatz
numericInput("portaInsert", "Siever insert size", value = 12, min = 0, max = 100),
# Notes
textInput("notes", "Notes:", value = "Keine Notizen"),
# submit
actionButton("createEntry", "Submit new entry!", icon("save")),
)
)
),
tabPanel("Configuration",
mainPanel(
h1('Add Coffees'),
h3('coming soon!')
)
)
)
server <- function(input, output){
# 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")
# Render History Table
output$history = DT::renderDataTable(
brews, server = TRUE,
options = list(order = list(3, "desc")))
# columnDefs = list(list(visible = FALSE, targets = c(4)))))
# 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()
# 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
)
# save changes to .csv file
print(brews)
write.csv(brews, file = "./data/brews.csv")
})
}
if (statusDocker == "false") {
runApp(shinyApp(ui = ui, server = server, options = list(launch.browser = TRUE)))
} else {
shinyApp(ui = ui, server = server)
}