Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ data/
build/
web/node_modules/
web/dist/
web/.vite-cache/
data-template/

media/pcb/
media/pcb/
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// v2.0.4
// v2.0.5
132 changes: 0 additions & 132 deletions data-template/index.html

This file was deleted.

7 changes: 0 additions & 7 deletions data-template/manifest.json

This file was deleted.

1,244 changes: 620 additions & 624 deletions lib/WebService/generated/web_files.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/deploy-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ echo -e "${BLUE}🚀 Starting deployment...${NC}"
# Clean target directory (except config.json backup)
echo -e "${YELLOW}🧹 Cleaning target directory...${NC}"
find "$TARGET_DIR" -type f -not -name "config.json" -delete 2>/dev/null || true
find "$TARGET_DIR" -type d -empty -delete 2>/dev/null || true
find "$TARGET_DIR" -mindepth 1 -type d -empty -delete 2>/dev/null || true

# Copy web files to temporary location for processing
echo -e "${YELLOW}📂 Copying source files...${NC}"
Expand Down
1 change: 1 addition & 0 deletions web/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
web:
image: node:20-alpine
container_name: chicken-feeder-web
user: "${UID:-1000}:${GID:-1000}"
working_dir: /app
ports:
- "8000:8000"
Expand Down
6 changes: 0 additions & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chicken Feeder Control</title>
<script>
// Optional mock API: add ?mock=1 to the URL to enable local fake endpoints
if (new URLSearchParams(window.location.search).has('mock')) {
document.write('<script src="./mock/api.js"><\\/script>');
}
</script>
</head>
<body>
<div class="page">
Expand Down
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chicken-feeder-web",
"version": "2.0.4",
"version": "2.0.5",
"private": true,
"type": "module",
"scripts": {
Expand Down
40 changes: 33 additions & 7 deletions web/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ export class ChickenFeederApp {

// Portion unit change
if (this.elements.portionUnitInput) {
this.elements.portionUnitInput.addEventListener('change', () => this.updatePortionUnit());
this.elements.portionUnitInput.addEventListener('input', () => this.updatePortionUnit());
this.elements.portionUnitInput.addEventListener('change', () => this.updatePortionUnit({ commit: true }));
this.elements.portionUnitInput.addEventListener('blur', () => this.updatePortionUnit({ commit: true }));
}

// OTA firmware selection
Expand Down Expand Up @@ -681,6 +682,8 @@ export class ChickenFeederApp {

async saveScheduleOnly() {
try {
this.updatePortionUnit({ commit: true });

const scheduleConfig = {
schedules: this.config.schedules,
portion_unit_grams: this.getPortionUnitGrams()
Expand Down Expand Up @@ -899,21 +902,44 @@ export class ChickenFeederApp {
reader.readAsText(file);
}

updatePortionUnit() {
refreshPortionUnitDisplays() {
if (!this.config) return;
const val = parseInt(this.elements.portionUnitInput.value, 10);
const grams = Math.min(100, Math.max(1, isNaN(val) ? this.getPortionUnitGrams() : val));
this.config.portion_unit_grams = grams;
this.elements.portionUnitInput.value = grams;

// Refresh inline displays
this.elements.timerRows.forEach((row, index) => {
if (this.config.schedules[index]) {
this.updatePortionDisplay(row, this.config.schedules[index].portion_units);
}
});
}

updatePortionUnit({ commit = false } = {}) {
if (!this.config) return;

const rawValue = this.elements.portionUnitInput.value.trim();
if (rawValue === '') {
if (commit) {
this.elements.portionUnitInput.value = this.getPortionUnitGrams();
}
return;
}

const val = parseInt(rawValue, 10);
if (isNaN(val)) {
if (commit) {
this.elements.portionUnitInput.value = this.getPortionUnitGrams();
}
return;
}

const grams = Math.min(100, Math.max(1, val));
this.config.portion_unit_grams = grams;
if (commit) {
this.elements.portionUnitInput.value = grams;
}

this.refreshPortionUnitDisplays();
}

bindDeepSleepGesture(button) {
let holdTimer = null;
const holdDelay = 600; // ms
Expand Down
1 change: 1 addition & 0 deletions web/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const appVersion = versionMatch || 'v1.0.0';

export default defineConfig({
base: './',
cacheDir: '.vite-cache',
server: {
host: true,
port: 8000
Expand Down
Loading