Initialer Import: Raceplaner mit Flask & Nginx Proxy

This commit is contained in:
root
2026-01-23 21:42:48 +01:00
commit 634d3d865a
23 changed files with 993 additions and 0 deletions

157
app/templates/index.html Normal file
View File

@@ -0,0 +1,157 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RACEPLANNER 2026</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');
body { font-family: 'Inter', sans-serif; background-color: #0a0e17; color: #e2e8f0; }
.glass { background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.05); }
.stint-card { transition: all 0.2s ease; border-left: 4px solid transparent; }
.stint-card:hover { transform: translateX(4px); background: rgba(30, 41, 59, 0.7); }
.handle { cursor: grab; }
input, select { background: #0f172a; border: 1px solid #1e293b; color: white; padding: 0.5rem; border-radius: 0.375rem; }
</style>
</head>
<body class="p-4 md:p-8">
<div class="max-w-7xl mx-auto">
<div class="flex flex-col md:flex-row justify-between items-center mb-8 gap-4">
<h1 class="text-3xl font-black italic tracking-tighter text-blue-500 uppercase">Raceplanner <span class="text-white">2026</span></h1>
<div class="flex gap-4 items-center glass p-4 rounded-xl">
<form action="/save_scenario" method="POST" class="flex gap-2">
<input type="text" name="scenario_name" placeholder="Scenario Name" class="text-xs w-32" required>
<button class="bg-green-600 hover:bg-green-500 text-[10px] font-bold px-3 py-2 rounded uppercase">Save</button>
</form>
<form action="/load_scenario" method="POST" class="flex gap-2 border-l border-slate-700 pl-4">
<select name="scenario_file" class="text-xs w-32">
{% for s in scenarios %}<option value="{{ s }}">{{ s }}</option>{% endfor %}
</select>
<button class="bg-blue-600 hover:bg-blue-500 text-[10px] font-bold px-3 py-2 rounded uppercase">Load</button>
</form>
<a href="/logout" class="text-xs text-slate-500 hover:text-white ml-2">Logout</a>
</div>
</div>
<form action="/update_config" method="POST" class="glass p-6 rounded-2xl mb-12 grid grid-cols-2 md:grid-cols-6 gap-6 items-end">
<div class="col-span-2">
<label class="block text-[10px] uppercase font-bold text-slate-500 mb-2">Race Start</label>
<input type="datetime-local" name="start_datetime" value="{{ config.start_time.strftime('%Y-%m-%dT%H:%M') }}" class="w-full font-mono text-sm">
</div>
<div><label class="block text-[10px] uppercase font-bold text-slate-500 mb-2">Dur(h)</label><input type="number" name="race_duration_hours" value="{{ config.race_duration_hours }}" class="w-full text-center"></div>
<div><label class="block text-[10px] uppercase font-bold text-slate-500 mb-2">Tank</label><input type="number" step="0.1" name="tank_capacity" value="{{ config.tank_capacity }}" class="w-full text-center"></div>
<div><label class="block text-[10px] uppercase font-bold text-slate-500 mb-2">Box(s)</label><input type="number" name="min_pit_stop_sec" value="{{ config.min_pit_stop_sec }}" class="w-full text-center"></div>
<div class="flex items-center gap-2 pb-3">
<input type="checkbox" name="always_change_tires" id="tires" {% if config.always_change_tires %}checked{% endif %}>
<label for="tires" class="text-[10px] uppercase font-bold text-slate-400">Force Tires</label>
<button type="submit" class="ml-4 bg-blue-600 hover:bg-blue-500 text-white font-black text-xs px-6 py-2 rounded uppercase shadow-lg shadow-blue-900/20">Apply</button>
</div>
</form>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12">
{% for car_num, drivers, schedule in [(1, car1_drivers, schedule1), (2, car2_drivers, schedule2)] %}
<div class="space-y-6">
<div class="flex items-center justify-between border-b border-slate-800 pb-4">
<h2 class="text-2xl font-black italic uppercase"><span class="text-blue-500">#{{ car_num }}</span> Vehicle Dashboard</h2>
<div class="flex gap-2">
<a href="/export/car/{{ car_num }}" target="_blank" class="bg-slate-800 hover:bg-slate-700 text-[10px] font-bold px-3 py-1.5 rounded uppercase">PDF Plan</a>
<a href="/generate_schedule/{{ car_num }}" class="bg-red-950 text-red-400 border border-red-900/50 text-[10px] font-bold px-3 py-1.5 rounded uppercase">Auto-Generate</a>
</div>
</div>
<div class="space-y-3">
{% for d in drivers %}
<form action="/update_driver/{{ d.id }}" method="POST" class="glass p-4 rounded-xl flex items-center gap-4 stint-card">
<div class="w-8 h-8 rounded-full bg-orange-500/20 text-orange-500 flex items-center justify-center font-black text-xs">{{ stint_counts.get(d.id, 0) }}</div>
<div class="flex-1"><input type="text" name="name" value="{{ d.name }}" class="bg-transparent border-none p-0 font-bold text-blue-400 w-full"></div>
<div class="text-right"><label class="block text-[8px] uppercase text-slate-500">L/R</label><input type="number" step="0.1" name="cons" value="{{ d.cons_per_lap }}" class="w-16 bg-slate-900/50 text-[10px] text-center"></div>
<div class="text-right"><label class="block text-[8px] uppercase text-slate-500">Sec</label><input type="number" step="0.1" name="lap_time" value="{{ d.avg_lap_time }}" class="w-16 bg-slate-900/50 text-[10px] text-center"></div>
<div class="flex gap-2 ml-auto">
<button type="submit" class="bg-blue-600/20 text-blue-400 text-[10px] px-2 py-1 rounded font-black border border-blue-600/30">OK</button>
<a href="/export/driver/{{ d.id }}" target="_blank" class="bg-gray-800 px-2 py-1 rounded text-xs hover:bg-green-600">📄</a>
<a href="/driver/{{ d.id }}" class="bg-gray-800 px-2 py-1 rounded text-xs hover:bg-blue-600">👁️</a>
<a href="/delete_driver/{{ d.id }}" class="text-slate-600 hover:text-red-500"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M6 18L18 6M6 6l12 12"/></svg></a>
</div>
</form>
{% endfor %}
<form action="/add_driver" method="POST" class="flex gap-2 mt-4">
<input type="hidden" name="car_number" value="{{ car_num }}">
<input type="text" name="name" placeholder="Driver Name" class="flex-1 text-sm h-10" required>
<input type="number" step="0.1" name="cons" placeholder="L/R" class="w-20 text-sm h-10">
<input type="number" step="0.1" name="lap_time" placeholder="Sec" class="w-20 text-sm h-10">
<button class="bg-blue-600 text-white font-black text-[10px] px-6 py-2 rounded uppercase">Add</button>
</form>
</div>
<div class="relative py-8">
<div class="absolute inset-0 flex items-center" aria-hidden="true">
<div class="w-full border-t border-slate-800"></div>
</div>
<div class="relative flex justify-center">
<span class="bg-[#0a0e17] px-4 text-xs font-black text-slate-500 uppercase tracking-widest">Race Schedule #{{ car_num }}</span>
</div>
</div>
<div id="stints-car-{{ car_num }}" class="space-y-2">
{% for s in schedule %}
<div class="stint-item glass rounded-xl p-4 stint-card grid grid-cols-12 gap-2 items-center" data-id="{{ s.stint_id }}">
<div class="col-span-1 text-sm font-black text-blue-400">#{{ s.number }}</div>
<div class="col-span-1 handle text-slate-700 hover:text-slate-400">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path d="M7 7h2v2H7V7zm0 4h2v2H7v-2zm4-4h2v2h-2V7zm0 4h2v2h-2v-2zM7 15h2v2H7v-2zm4 0h2v2h-2v-2z"/></svg>
</div>
<div class="col-span-2 font-mono">
<div class="text-[11px] font-bold text-slate-300 mb-0.5">{{ s.date }}</div>
<div class="text-sm font-black text-blue-500">{{ s.start }}</div>
<div class="text-[10px] text-slate-500">{{ s.end }}</div>
</div>
<div class="col-span-4">
<select onchange="updateStintDriver('{{ s.stint_id }}', this.value)" class="w-full bg-slate-900/80 border-slate-800 text-xs font-bold py-1">
{% for d in drivers %}<option value="{{ d.id }}" {% if d.id == s.driver_id %}selected{% endif %}>{{ d.name }}</option>{% endfor %}
</select>
</div>
<div class="col-span-2 text-center">
<div class="font-black">{{ s.laps }} R</div>
<div class="text-[10px] text-green-500">{{ s.fuel }}L</div>
</div>
<div class="col-span-2 text-right">
{% if s.is_finish %}<span class="bg-blue-600 text-[8px] font-black px-2 py-1 rounded text-white uppercase">Finish</span>
{% elif s.change_tires %}<span class="bg-green-600/20 text-green-500 text-[8px] font-black px-2 py-1 rounded border border-green-500/30 uppercase">Tires</span>{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
<script>
function updateStintDriver(stintId, driverId) {
fetch('/update_stint_driver', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({stint_id: stintId, driver_id: driverId})
}).then(() => window.location.reload());
}
[1, 2].forEach(num => {
const el = document.getElementById('stints-car-' + num);
if(el) {
Sortable.create(el, {
handle: '.handle', animation: 150,
onEnd: function() {
const order = Array.from(el.children).map(item => item.dataset.id);
fetch('/reorder_stints', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({order: order})
}).then(() => window.location.reload());
}
});
}
});
</script>
</body>
</html>