Initial FarmCal MVP

This commit is contained in:
Kai
2026-02-16 11:22:50 +01:00
commit 745c93c77b
9 changed files with 862 additions and 0 deletions

145
templates/index.html Normal file
View File

@@ -0,0 +1,145 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FarmCal</title>
<link rel="stylesheet" href="/static/styles.css">
</head>
<body>
<header class="top">
<h1>FarmCal</h1>
<p>Planung fuer Felder, Aussaat und Ernte</p>
</header>
<main class="layout">
<section class="card">
<h2>Ingame-Zeit</h2>
<form method="get" action="/" class="grid">
<label>Monat
<select name="month">
{{range .Months}}
<option value="{{.Value}}" {{if eq $.NowMonth .Value}}selected{{end}}>{{.Label}}</option>
{{end}}
</select>
</label>
<label>Tag
<input type="number" name="day" min="1" max="{{.DaysPerMonth}}" value="{{.NowDay}}">
</label>
<button type="submit">Anzeigen</button>
</form>
<form method="post" action="/settings" class="grid mt">
<label>Tage pro Monat
<input type="number" name="days_per_month" min="1" max="31" value="{{.DaysPerMonth}}">
</label>
<button type="submit">Speichern</button>
</form>
</section>
<section class="card">
<h2>Heutige Aufgaben</h2>
{{if .Tasks}}
<ul class="tasks">
{{range .Tasks}}
<li>
<strong>{{.Type}}:</strong> {{.Message}}
</li>
{{end}}
</ul>
{{else}}
<p>Keine Aufgaben fuer diesen Ingame-Tag.</p>
{{end}}
</section>
<section class="card">
<h2>Feld anlegen</h2>
<form method="post" action="/fields" class="grid">
<label>Feldnummer
<input type="number" name="number" min="1" required>
</label>
<label>Name (optional)
<input type="text" name="name" maxlength="120">
</label>
<button type="submit">Feld speichern</button>
</form>
</section>
<section class="card">
<h2>Anbau planen</h2>
<form method="post" action="/plans" class="grid">
<label>Feld
<select name="field_id" required>
<option value="">Bitte waehlen</option>
{{range .Fields}}
<option value="{{.ID}}">Feld {{.Number}}{{if .Name}} ({{.Name}}){{end}}</option>
{{end}}
</select>
</label>
<label>Feldfrucht
<select name="crop_id" required>
<option value="">Bitte waehlen</option>
{{range .Crops}}
<option value="{{.ID}}">{{.Name}} (Aussaat Monat {{.SowStartMonth}}-{{.SowEndMonth}})</option>
{{end}}
</select>
</label>
<label>Startmonat
<select name="start_month" required>
{{range .Months}}
<option value="{{.Value}}" {{if eq $.NowMonth .Value}}selected{{end}}>{{.Label}}</option>
{{end}}
</select>
</label>
<label>Starttag
<input type="number" name="start_day" min="1" max="{{.DaysPerMonth}}" value="{{.NowDay}}" required>
</label>
<label class="full">Notiz
<input type="text" name="notes" maxlength="255">
</label>
<button type="submit">Plan speichern</button>
</form>
</section>
<section class="card">
<h2>Geplante Durchlaeufe</h2>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Feld</th>
<th>Frucht</th>
<th>Aussaat</th>
<th>Ernte</th>
<th>Notiz</th>
</tr>
</thead>
<tbody>
{{if .Plans}}
{{range .Plans}}
<tr>
<td>Feld {{.FieldNumber}}{{if .FieldName}} ({{.FieldName}}){{end}}</td>
<td>{{.CropName}}</td>
<td>Monat {{.StartMonth}} Tag {{.StartDay}}</td>
<td>Monat {{.HarvestMonth}} Tag {{.HarvestDay}}</td>
<td>{{.Notes}}</td>
</tr>
{{end}}
{{else}}
<tr><td colspan="5">Noch keine Planung vorhanden.</td></tr>
{{end}}
</tbody>
</table>
</div>
</section>
</main>
{{if .Error}}<div class="toast error">{{.Error}}</div>{{end}}
{{if .Info}}<div class="toast info">{{.Info}}</div>{{end}}
</body>
</html>