From 62d449510b897855a2a8157cf510cbf14c4c472d Mon Sep 17 00:00:00 2001 From: "friedemann.blume" Date: Fri, 12 Jan 2024 21:18:29 +0100 Subject: [PATCH] bug fixes and add config page content --- Dockerfile | 4 +++- docker-compose.yml | 4 ++-- eprilog.r | 55 +++++++++++++++++++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 75a005f..46e03a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,13 +45,15 @@ VOLUME [ "/data/" ] # r packages RUN R -e 'install.packages("shiny")' +RUN R -e 'install.packages("DT")' + # copy the app directory into the image COPY ./eprilog.r / # copy status docker files -COPY ./.status-docker_dockerfile /app/.status-docker +COPY ./.status-docker_dockerfile /.status-docker WORKDIR / diff --git a/docker-compose.yml b/docker-compose.yml index d2d2395..420da42 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,8 @@ services: eprilog: image: git.nucleolus.xyz/fblume/eprilog/eprilog:latest container_name: eprilog - port: - 3839:3839/tcp + ports: + - 3839:3839/tcp volumes: - ./data:/data restart: unless-stopped \ No newline at end of file diff --git a/eprilog.r b/eprilog.r index 6b403d5..c2c5205 100644 --- a/eprilog.r +++ b/eprilog.r @@ -3,14 +3,23 @@ ################# require(shiny) +require(DT) # preperation: # Get the status if r shiny is running in docker or not readRenviron("./.status-docker") 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") + + ui <- navbarPage("EpriLog", - tabPanel("Eprilog", + tabPanel("Brews", sidebarLayout( mainPanel( h1('Brew History'), @@ -46,21 +55,36 @@ 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")), ) ) ), tabPanel("Configuration", - mainPanel( - h1('Add Coffees'), - h3('coming soon!') + sidebarLayout( + mainPanel( + h1('Already available Coffees'), + DT::dataTableOutput('coffees') + ), + sidebarPanel( + h2('Add New Coffees'), + textInput("brandName", "Brand Name", value = ""), + textInput("coffeeName", "Coffee Name", value = ""), + textInput("alias", "Nick Name", value = ""), + dateInput("expDate", "Expiration Date"), + numericInput("arabicaPercentage", "Arabica Percentage", value = "50"), + numericInput("robustaPercentage", "Robusta Percentage", value = "50"), + numericInput("sourPercentage", "Sourness Percentage", value = "50"), + numericInput("strongnessPercentage", "Strongness Percentage", value = "50"), + numericInput("roastDarknessPercentage", "Roast Darkness Percentage", value = 50), + textInput("originCountry", "Origin County of the Coffee", value = "Coffee World"), + ) ) - ) -) +)) -server <- function(input, output){ + +server <- function(input, output, session){ # loading data from csv files brews <- (read.csv(file = "./data/brews.csv", header = TRUE, sep = ",", row.names = 1)) @@ -69,12 +93,22 @@ server <- function(input, output){ coffees <- read.csv(file = "./data/coffees.csv") # Render History Table - output$history = DT::renderDataTable( + output$history = DT::renderDataTable( brews, server = TRUE, options = list(order = list(3, "desc"), - columnDefs = list(list(visible = FALSE, targets = c(1,2,10,11,12,13,14,15,16))) + list(scrollX = TRUE), + 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 observeEvent(input$createEntry, { @@ -125,6 +159,7 @@ server <- function(input, output){ # save changes to .csv file write.csv(brews, file = "./data/brews.csv") + session$reload() }) }