Completely re-structured the project from scratch, wrote a better bootstrap script, changed configuration format to yaml, improved Caddyfile, and more. #15 #16 #20

This commit is contained in:
ChaoticByte 2023-02-11 17:23:57 +01:00
parent 0012214f9b
commit 5572fec9c1
91 changed files with 739 additions and 1345 deletions

View file

@ -1,61 +0,0 @@
.appform {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: max-content;
font-size: 1.1rem;
}
.appform > .forminfo {
width: 100%;
text-align: left;
margin: .4rem 0;
}
.forminfo > span:first-child {
margin-right: 1rem;
}
.forminfo > span:last-child {
float: right;
}
.appform > .forminput {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin: .8rem 0;
gap: 1rem;
}
.appform > .statusinfo {
margin-top: .5rem;
}
.appform > .formbuttons {
border-top: 1px solid var(--glass-border-color);
padding-top: 1rem;
margin-top: 1rem;
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 1rem;
}
.formbuttons button, .formbuttons .button {
box-sizing: content-box;
font-size: 1rem;
width: fit-content;
}
.formheading {
text-align: left;
width: 100%;
margin-top: 0;
}
@media only screen and (max-width: 700px) {
.appform > .forminput {
flex-direction: column;
gap: .5rem;
}
.formheading {
text-align: center;
}
}

View file

@ -1,39 +0,0 @@
/* custom number input */
.customnumberinput {
display: flex;
flex-direction: row;
height: 2.2rem;
}
.customnumberinput button {
min-width: 2.5rem !important;
width: 2.5rem !important;
padding: 0;
margin: 0;
height: 100%;
}
.customnumberinput-minus {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
z-index: 10;
}
.customnumberinput-plus {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
z-index: 10;
}
.customnumberinput input[type="number"] {
max-height: 100%;
width: 4rem;
padding: 0;
margin: 0;
font-size: .9rem;
color: var(--color);
text-align: center;
background: var(--glass-bg-color2);
outline: none;
border: none;
border-radius: 0 !important;
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
}

View file

@ -1,23 +0,0 @@
.history {
margin: 0;
padding: 0;
width: 40%;
min-width: 30rem;
}
.history td {
padding-top: .4rem !important;
padding-bottom: .4rem !important;
font-size: .95rem;
}
.history .historydate {
margin-left: auto;
text-align: right;
font-size: .8rem !important;
}
/* mobile devices */
@media only screen and (max-width: 700px) {
.history {
width: 90%;
min-width: 90%;
}
}

View file

@ -1,46 +0,0 @@
.availabledrinkslist {
width: 50%;
max-width: 45rem;
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
}
.availabledrinkslist li {
display: flex;
width: 100%;
height: fit-content;
margin-bottom: .6rem;
}
.availabledrinkslist li a {
display: flex;
width: 100%;
align-items: center;
justify-content: start;
color: var(--color);
padding: .8rem 1.1rem;
text-decoration: none;
font-size: 1rem;
}
.availabledrinkslist li a span:first-child {
margin-right: 1rem !important;
text-align: left;
}
.availabledrinkslist li a span:last-child {
margin-left: auto;
text-align: right;
font-size: 1rem;
}
/* mobile devices */
@media only screen and (max-width: 700px) {
.availabledrinkslist {
width: 95%;
}
.availabledrinkslist li a {
width: calc(100vw - (2 * .8rem)) !important;
padding: .8rem !important;
}
}

View file

@ -1,131 +0,0 @@
/* login page */
main {
margin-top: 2vh;
}
main > h1 {
display: none;
}
.userlistcontainer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
}
.userlist {
width: 50vw;
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.userlist > li {
display: flex;
width: 100%;
align-items: center;
justify-content: center;
margin-bottom: .5rem;
padding: 0 .5rem;
}
.userlist > li > img {
margin-right: auto;
margin-left: 0;
height: 2rem;
width: 2rem;
}
.userlist > li > div {
display: flex;
flex-grow: 1;
align-items: center;
justify-content: center;
text-align: center;
padding: .8rem 1.1rem;
}
.userlistbutton {
font-size: 1.1rem;
}
.passwordoverlaycontainer {
position: absolute;
top: 0;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
background: var(--page-background);
z-index: 40;
}
.passwordoverlay {
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
}
.passwordoverlay > form {
min-width: unset;
width: fit-content;
}
.passwordoverlay > form > h1 {
margin-top: 2rem;
margin-bottom: 2rem;
}
/* loginform */
.loginform {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.loginform input[type="password"], form input[type="text"] {
width: 94%;
padding-top: .5rem;
padding-bottom: .5rem;
font-size: 1rem;
margin: .1rem 0;
}
.loginform .horizontalbuttonlist {
margin-top: 1.5rem;
}
.horizontalbuttonlist .button, .horizontalbuttonlist button {
font-size: 1rem;
}
/***/
.pinpad {
margin-top: 1.5rem;
margin-bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
max-width: 30vw;
}
.pinpad table {
box-shadow: none !important;
}
.pinpad table tr, .pinpad td {
padding: unset;
background: unset;
}
.pinpad tr td button {
height: 4.0rem;
width: 4.1rem;
font-size: 1.16rem;
margin: .2rem !important;
}
@media only screen and (max-width: 700px) {
.userlistcontainer {
width: 95vw;
}
.userlist {
width: 100%;
}
.pinpad table tr td button {
height: 4.2rem;
width: 4.2rem;
font-size: 1.16rem;
margin: .2rem;
}
}

View file

@ -1,341 +0,0 @@
/* VARIABLES */
:root {
/** FONT **/
--font-family: 'Liberation Sans', sans-serif;
/** colors **/
--color: #fafafa;
--color-error: rgb(255, 70, 70);
/** glass **/
--glass-bg-dropdown: #3a3b44ef;
--glass-bg-dropdown-hover: #55565efa;
--glass-bg-color1: #ffffff31;
--glass-bg-color2: #ffffff1a;
--glass-bg-hover-color1: #ffffff46;
--glass-bg-hover-color2: #ffffff1a;
--glass-blur: none;
--glass-border-color: #ffffff77;
--glass-bg: linear-gradient(var(--glass-bg-color1), var(--glass-bg-color2));
--glass-bg-hover: linear-gradient(var(--glass-bg-hover-color1), var(--glass-bg-hover-color2));
--glass-corner-radius: .5rem;
/** page background **/
--page-background-color1: #131d25;
--page-background-color2: #311d30;
--page-background: linear-gradient(-190deg, var(--page-background-color1), var(--page-background-color2));
/** global message banner **/
--bg-globalmessage: linear-gradient(135deg, #4b351c, #411d52, #1c404b);
}
@supports(backdrop-filter: blur(10px)) {
:root {
--glass-bg-dropdown: #ffffff1a;
--glass-bg-dropdown-hover: #ffffff46;
--glass-blur: blur(18px);
}
}
/* BASE LAYOUT */
body {
margin: 0;
padding: 0;
width: 100vw;
min-height: 100vh;
font-family: var(--font-family);
background: var(--page-background);
color: var(--color);
overflow-x: hidden;
}
.baselayout {
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
min-height: 100vh;
width: 100vw;
max-width: 100vw;
}
main {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
flex-grow: 1;
width: 100%;
margin-top: 5vh;
}
.userpanel {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin-top: 1rem;
font-size: 1rem;
width: 94%;
}
.userinfo > span {
font-size: 1.1rem;
vertical-align: middle;
}
.userinfo > img {
vertical-align: middle;
width: 1.8rem;
height: 1.8rem;
margin: .5rem;
}
.userpanel > .horizontalbuttonlist {
margin-left: auto;
margin-right: 0;
}
.userbalancewarn {
color: var(--color-error);
font-weight: bold;
}
.content {
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
width: 100%;
flex-grow: 1;
}
.globalmessage {
width: 100vw;
z-index: 999;
display: flex;
justify-content: center;
align-items: center;
background: var(--bg-globalmessage);
padding: .3rem 0;
}
.globalmessage div {
width: 96%;
text-align: center;
word-break: keep-all;
word-wrap: break-word;
box-sizing: border-box;
}
/* DROP DOWN MENUS */
.dropdownmenu {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
border-radius: var(--glass-corner-radius);
}
.dropdownbutton {
width: fit-content;
z-index: 190;
box-shadow: none;
text-align: center;
justify-content: center;
}
.dropdownbutton, .dropdownchoice {
font-size: 1rem;
}
.dropdownlist {
position: absolute;
display: flex;
flex-direction: column;
pointer-events: none;
border-radius: var(--glass-corner-radius) !important;
backdrop-filter: var(--glass-blur);
z-index: 200;
margin-top: 3.2rem;
opacity: 0%;
transition: opacity 100ms;
}
.dropdownchoice {
box-shadow: none;
border-radius: 0 !important;
margin: 0;
margin-top: -1px;
text-align: center;
justify-content: center;
background: var(--glass-bg-dropdown) !important;
backdrop-filter: none !important;
}
.dropdownchoice:hover {
background: var(--glass-bg-dropdown-hover) !important;
}
.dropdownlist :first-child {
border-top-left-radius: var(--glass-corner-radius) !important;
border-top-right-radius: var(--glass-corner-radius) !important;
}
.dropdownlist :last-child {
border-bottom-left-radius: var(--glass-corner-radius) !important;
border-bottom-right-radius: var(--glass-corner-radius) !important;
}
.dropdownvisible .dropdownlist {
opacity: 100%;
visibility: visible;
pointer-events: visible;
}
/* FOOTER */
.footer {
z-index: 900;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: wrap;
margin-top: auto;
padding-top: 3rem;
padding-bottom: .3rem;
text-align: center;
}
.footer div {
font-size: .95rem;
margin-top: .15rem;
margin-bottom: .15rem;
}
.footer div::after {
margin-left: .5rem;
content: "-";
margin-right: .5rem;
}
.footer div:last-child::after {
content: none;
margin-left: 0;
margin-right: 0;
}
/* TABLES */
table {
border-collapse: collapse;
border-spacing: 0;
text-align: left;
border-radius: var(--glass-corner-radius);
backdrop-filter: var(--glass-blur);
}
tr {
background: var(--glass-bg-color1);
}
tr:nth-child(2n+2) {
background: var(--glass-bg-color2);
}
/*
Rounded corners on table cells apparently don't work with
Firefox, so Firefox users won't have rounded corners
on tables. Can't fix that by myself.
*/
table tr:first-child th:first-child {
border-top-left-radius: var(--glass-corner-radius);
}
table tr:first-child th:last-child {
border-top-right-radius: var(--glass-corner-radius);
}
table tr:last-child td:first-child {
border-bottom-left-radius: var(--glass-corner-radius);
}
table tr:last-child td:last-child {
border-bottom-right-radius: var(--glass-corner-radius);
}
/* - */
td, th {
padding: .5rem .8rem;
}
th {
text-align: left;
border-bottom: 1px solid var(--color);
}
/* BUTTONS & OTHER INPUT ELEMENTS */
.button, button {
display: flex;
align-items: center;
justify-content: center;
font-family: var(--font-family);
text-decoration: none;
text-align: center !important;
background: var(--glass-bg);
color: var(--color);
padding: .6rem .8rem;
outline: none;
border: 1px solid var(--glass-border-color);
border-radius: var(--glass-corner-radius);
/*backdrop-filter: var(--glass-blur); disabled for performance reasons*/
cursor: pointer;
user-select: none;
}
.button:hover, button:hover, .button:active, button:active {
background: var(--glass-bg-hover);
}
.button:disabled, button:disabled {
opacity: 40%;
}
a {
color: var(--color);
}
input[type="number"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button {
display: none;
}
input[type="text"], input[type="password"], input[type="number"] {
background: var(--glass-bg-color2);
outline: none;
padding: .4rem .6rem;
font-size: .9rem;
color: var(--color);
text-align: center;
border: none;
border-radius: var(--glass-corner-radius);
}
/**** OTHER CLASSES ****/
.centeringflex {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 2rem 1rem;
}
.horizontalbuttonlist {
display: flex;
flex-direction: row;
align-items: flex-end;
justify-content: space-between;
}
.horizontalbuttonlist > .button, .horizontalbuttonlist > button, .horizontalbuttonlist > div {
margin: 0 .5rem;
}
.errortext {
margin-top: 1rem;
color: var(--color-error);
}
.nodisplay {
display: none !important;
}
.heading {
margin-top: 0;
}
/* MISC / GENERAL */
h1 {
text-align: center;
font-size: 1.8rem;
}
/* MOBILE OPTIMIZATIONS */
@media only screen and (max-width: 700px) {
main {
margin-top: 2rem;
}
.globalmessage span {
width: 90%;
}
.userpanel {
flex-direction: column;
justify-content: start;
align-items: center;
}
.userpanel > .horizontalbuttonlist {
margin-right: 0;
margin-left: 0;
margin-top: .5rem;
justify-content: center;
flex-wrap: wrap;
}
.userpanel > .horizontalbuttonlist > .button,
.userpanel > .horizontalbuttonlist > .dropdownmenu {
margin: 0.25rem;
}
}

View file

@ -1,53 +0,0 @@
.maincontainer {
min-width: 70vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
}
.tablescontainer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
width: 95%;
margin-top: 2rem;
}
.statisticstable {
margin-bottom: 2rem;
padding-bottom: 1rem;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
text-align: center;
}
.statisticstable h1 {
margin-top: 0;
font-size: 1.2rem;
text-align: left;
min-width: 10rem;
text-align: center;
}
.statisticstable table {
min-width: 20vw;
width: fit-content;
}
.statisticstable th:last-child {
text-align: right;
}
.statisticstable td:last-child {
text-align: right;
}
@media only screen and (max-width: 700px) {
.statisticstable h1 {
min-width: 90vw;
}
.statisticstable table {
min-width: 80vw;
}
.statisticstable {
margin-bottom: 2rem;
padding-bottom: 1rem;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

View file

@ -1,3 +0,0 @@
setInterval(() => {
location.reload();
}, 1000*60*2); // reload after 2 minutes

View file

@ -1,30 +0,0 @@
{
document.addEventListener("DOMContentLoaded", () => {
// get all customnumberinput Elements
let customNumberInputElements = document.getElementsByClassName("customnumberinput");
// Add Event Handler to the elements of the customnumberinputs
[...customNumberInputElements].forEach(element => {
// number input
let numberFieldElement = element.getElementsByClassName("customnumberinput-field")[0];
// minus button
element.getElementsByClassName("customnumberinput-minus")[0].addEventListener("click", () => {
alterCustomNumberField(numberFieldElement, -1)
});
// plus button
element.getElementsByClassName("customnumberinput-plus")[0].addEventListener("click", () => {
alterCustomNumberField(numberFieldElement, +1)
});
})
})
function alterCustomNumberField(numberFieldElement, n) {
numberFieldElement.value = Math.min(
Math.max(
(parseInt(numberFieldElement.value) + n), numberFieldElement.min || Number.MIN_VALUE
),
numberFieldElement.max || Number.MAX_VALUE
);
}
}

View file

@ -1,49 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
// elements
let depositForm = document.getElementById("depositform");
let statusInfo = document.getElementById("statusinfo");
let depositSubmitButton = document.getElementById("depositsubmitbtn");
// event listener for deposit form
// this implements a custom submit method
depositForm.addEventListener("submit", (event) => {
depositSubmitButton.disabled = true;
event.preventDefault(); // Don't do the default submit action!
let xhr = new XMLHttpRequest();
let formData = new FormData(depositForm);
xhr.addEventListener("load", (event) => {
status_ = event.target.status;
response_ = event.target.responseText;
if (status_ == 200 && response_ == "success") {
statusInfo.innerText = "Success. Redirecting soon.";
window.location.replace("/");
}
else {
statusInfo.classList.add("errortext");
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
window.setTimeout(() => { window.location.replace("/") }, 5000);
}
})
xhr.addEventListener("error", (event) => {
statusInfo.classList.add("errortext");
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
window.setTimeout(() => { window.location.replace("/") }, 5000);
})
xhr.open("POST", "/api/deposit");
xhr.send(formData);
});
})

View file

@ -1 +0,0 @@
window.location.replace("/");

View file

@ -1,87 +0,0 @@
(() => {
// Define variables
let usernameInputElement;
let passwordInputElement;
let submitButton;
let passwordOverlayElement;
let pwOverlayCancelButton;
let userlistButtons;
let pinpadButtons;
let userlistContainerElement;
// Add event listeners after DOM Content loaded
document.addEventListener("DOMContentLoaded", () => {
// elements
usernameInputElement = document.getElementById("id_username");
passwordInputElement = document.getElementById("id_password");
submitButton = document.getElementById("submit_login");
passwordOverlayElement = document.getElementById("passwordoverlaycontainer");
pwOverlayCancelButton = document.getElementById("pwocancel");
userlistContainerElement = document.getElementById("userlistcontainer");
userlistButtons = document.getElementsByClassName("userlistbutton");
pinpadButtons = document.getElementsByClassName("pinpadbtn");
// event listeners
// [...<html-collection>] converts an html collection to an array
[...userlistButtons].forEach(element => {
element.addEventListener("click", () => {
set_username(element.dataset.username);
show_password_overlay();
})
});
[...pinpadButtons].forEach(element => {
element.addEventListener("click", () => {
pinpad_press(element.dataset.btn);
})
})
pwOverlayCancelButton.addEventListener("click", () => {
hide_password_overlay();
});
})
function set_username(username) {
usernameInputElement.value = username;
}
function show_password_overlay() {
window.scrollTo(0, 0);
passwordOverlayElement.classList.remove("nodisplay");
userlistContainerElement.classList.add("nodisplay");
}
function hide_password_overlay() {
passwordOverlayElement.classList.add("nodisplay");
userlistContainerElement.classList.remove("nodisplay");
passwordInputElement.value = "";
}
function pinpad_press(key) {
if (key == "enter") {
submitButton.click();
}
else if (key == "x") {
passwordInputElement.value = "";
}
else {
passwordInputElement.value += key;
}
}
})()

View file

@ -1,21 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
let dropdownmenuElement = document.getElementById("dropdownmenu");
let dropdownmenuButtonElement = document.getElementById("dropdownmenu-button");
if (dropdownmenuButtonElement != null) {
dropdownmenuButtonElement.addEventListener("click", () => {
if (dropdownmenuElement.classList.contains("dropdownvisible")) {
dropdownmenuElement.classList.remove("dropdownvisible");
}
else {
dropdownmenuElement.classList.add("dropdownvisible");
}
})
}
})

View file

@ -1,82 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
// elements
let orderNumberofdrinksInput = document.getElementById("numberofdrinks");
let orderNumberofdrinksBtnA = document.getElementById("numberofdrinks-btn-minus");
let orderNumberofdrinksBtnB = document.getElementById("numberofdrinks-btn-plus");
let orderSumElement = document.getElementById("ordercalculatedsum");
let orderFormElement = document.getElementById("orderform");
let statusInfoElement = document.getElementById("statusinfo");
let orderSubmitButton = document.getElementById("ordersubmitbtn");
// calculate & display sum
let orderPricePerDrink = parseFloat(document.getElementById("priceperdrink").dataset.drinkPrice);
function calculateAndDisplaySum() {
setTimeout(() => {
let numberOfDrinks = parseFloat(orderNumberofdrinksInput.value);
if (isNaN(numberOfDrinks)) {
numberOfDrinks = 1;
}
let calculated_sum = orderPricePerDrink * numberOfDrinks;
orderSumElement.innerText = new Intl.NumberFormat(undefined, {minimumFractionDigits: 2}).format(calculated_sum);
}, 25);
}
orderNumberofdrinksInput.addEventListener("input", calculateAndDisplaySum);
orderNumberofdrinksBtnA.addEventListener("click", calculateAndDisplaySum);
orderNumberofdrinksBtnB.addEventListener("click", calculateAndDisplaySum);
// custom submit method
orderFormElement.addEventListener("submit", (event) => {
orderSubmitButton.disabled = true;
event.preventDefault(); // Don't do the default submit action!
if (isNaN(parseFloat(orderNumberofdrinksInput.value))) {
orderNumberofdrinksInput.value = 1;
}
let xhr = new XMLHttpRequest();
let formData = new FormData(orderFormElement);
xhr.addEventListener("load", (event) => {
status_ = event.target.status;
response_ = event.target.responseText;
if (status_ == 200 && response_ == "success") {
statusInfoElement.innerText = "Success.";
window.location.replace("/");
}
else {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
}
})
xhr.addEventListener("error", (event) => {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
})
xhr.open("POST", "/api/order-drink");
xhr.send(formData);
});
})

View file

@ -1,56 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
// elements
let supplyDescriptionElement = document.getElementById("supplydescription");
let supplyPriceElement = document.getElementById("supplyprice");
let supplyFormElement = document.getElementById("supplyform");
let statusInfoElement = document.getElementById("statusinfo");
let supplySubmitButton = document.getElementById("supplysubmitbtn");
// custom submit method
supplyFormElement.addEventListener("submit", (event) => {
supplySubmitButton.disabled = true;
event.preventDefault(); // Don't do the default submit action!
if (isNaN(parseFloat(supplyPriceElement.value)) || supplyDescriptionElement.value == "") {
statusInfoElement.innerText = "Please enter a description and price."
supplySubmitButton.disabled = false;
}
let xhr = new XMLHttpRequest();
let formData = new FormData(supplyFormElement);
xhr.addEventListener("load", (event) => {
status_ = event.target.status;
response_ = event.target.responseText;
if (status_ == 200 && response_ == "success") {
statusInfoElement.innerText = "Success.";
window.location.replace("/");
}
else {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
}
})
xhr.addEventListener("error", (event) => {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
})
xhr.open("POST", "/api/supply");
xhr.send(formData);
});
})