Initial commit: Gridseed WebGUI implementation

This commit is contained in:
Gemini Bot
2026-01-20 10:46:00 +00:00
commit ef7dcecea2
13 changed files with 806 additions and 0 deletions

58
templates/base.html Normal file
View File

@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="de" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gridseed Control</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row flex-nowrap">
<div class="col-auto col-md-3 col-xl-2 px-sm-2 px-0 bg-dark border-end border-secondary min-vh-100">
<div class="d-flex flex-column align-items-center align-items-sm-start px-3 pt-3 text-white min-vh-100">
<a href="/" class="d-flex align-items-center pb-3 mb-md-0 me-md-auto text-white text-decoration-none">
<i class="fa-solid fa-microchip fa-2x me-2"></i>
<span class="fs-4 d-none d-sm-inline">GridseedPi</span>
</a>
<ul class="nav nav-pills flex-column mb-sm-auto mb-0 align-items-center align-items-sm-start w-100" id="menu">
<li class="nav-item w-100">
<a href="{{ url_for('index') }}" class="nav-link align-middle px-0 {{ 'active' if active_page == 'dashboard' else 'text-white' }}">
<i class="fs-4 fa-solid fa-gauge"></i> <span class="ms-1 d-none d-sm-inline">Dashboard</span>
</a>
</li>
<li class="nav-item w-100">
<a href="{{ url_for('settings') }}" class="nav-link align-middle px-0 {{ 'active' if active_page == 'settings' else 'text-white' }}">
<i class="fs-4 fa-solid fa-gears"></i> <span class="ms-1 d-none d-sm-inline">Einstellungen</span>
</a>
</li>
</ul>
<hr>
<div class="pb-4 w-100 text-center">
<span class="d-none d-sm-inline text-muted small">v1.0.0</span>
</div>
</div>
</div>
<div class="col py-3 bg-black">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="{{ url_for('static', filename='js/dashboard.js') }}"></script>
</body>
</html>

108
templates/dashboard.html Normal file
View File

@@ -0,0 +1,108 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="row mb-4">
<div class="col-12">
<h2 class="text-white border-bottom border-secondary pb-2">Übersicht</h2>
</div>
</div>
<!-- Top Stats Cards -->
<div class="row mb-4 g-3">
<div class="col-md-3">
<div class="card text-bg-primary h-100">
<div class="card-header">Hashrate (5s)</div>
<div class="card-body">
<h2 class="card-title display-6 fw-bold" id="stat-mhs">0.00</h2>
<p class="card-text">MH/s</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-bg-success h-100">
<div class="card-header">Accepted Shares</div>
<div class="card-body">
<h2 class="card-title display-6 fw-bold" id="stat-accepted">0</h2>
<p class="card-text">Shares</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-bg-danger h-100">
<div class="card-header">HW Errors</div>
<div class="card-body">
<h2 class="card-title display-6 fw-bold" id="stat-hw">0</h2>
<p class="card-text">Errors</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-bg-warning h-100 text-dark">
<div class="card-header">Max Temp</div>
<div class="card-body">
<h2 class="card-title display-6 fw-bold" id="stat-temp">0</h2>
<p class="card-text">°C</p>
</div>
</div>
</div>
</div>
<!-- Charts Row -->
<div class="row mb-4 g-3">
<div class="col-lg-8">
<div class="card bg-dark border-secondary h-100">
<div class="card-header border-secondary">Hashrate History (Last Hour)</div>
<div class="card-body">
<canvas id="hashrateChart" style="max-height: 300px;"></canvas>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card bg-dark border-secondary h-100">
<div class="card-header border-secondary">Pool Status</div>
<div class="card-body">
<div id="pool-list" class="list-group list-group-flush">
<!-- Pool items injected via JS -->
<div class="text-center text-muted">Lade Pools...</div>
</div>
</div>
</div>
</div>
</div>
<!-- Device Details -->
<div class="row g-3">
<div class="col-12">
<div class="card bg-dark border-secondary">
<div class="card-header border-secondary">Gerätestatus</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-dark table-hover mb-0">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Enabled</th>
<th>Status</th>
<th>Temp (°C)</th>
<th>MHS 5s</th>
<th>MHS avg</th>
<th>Accepted</th>
<th>Rejected</th>
<th>HW Errors</th>
</tr>
</thead>
<tbody id="devs-table-body">
<tr>
<td colspan="10" class="text-center text-muted">Keine Geräte gefunden oder Verbindung getrennt...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

97
templates/settings.html Normal file
View File

@@ -0,0 +1,97 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="row mb-4">
<div class="col-12 d-flex justify-content-between align-items-center border-bottom border-secondary pb-2">
<h2 class="text-white mb-0">Einstellungen</h2>
<button onclick="restartMiner()" class="btn btn-outline-danger">
<i class="fa-solid fa-power-off me-2"></i>Miner Neustarten
</button>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="card bg-dark border-secondary">
<div class="card-header border-secondary">Konfiguration</div>
<div class="card-body">
<form action="{{ url_for('save_settings') }}" method="POST">
<h5 class="card-title text-info mb-3">Pool Einstellungen</h5>
<!-- Assuming single pool editing for MVP -->
{% set pool = config['pools'][0] if config['pools'] and config['pools']|length > 0 else {} %}
<div class="mb-3">
<label for="pool_url" class="form-label text-white">Pool URL</label>
<input type="text" class="form-control bg-black text-white border-secondary" id="pool_url" name="pool_url" value="{{ pool.get('url', '') }}" required>
<div class="form-text text-muted">Beispiel: stratum+tcp://pool.example.com:3333</div>
</div>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label for="pool_user" class="form-label text-white">Worker / Benutzer</label>
<input type="text" class="form-control bg-black text-white border-secondary" id="pool_user" name="pool_user" value="{{ pool.get('user', '') }}" required>
</div>
<div class="col-md-6">
<label for="pool_pass" class="form-label text-white">Passwort</label>
<input type="text" class="form-control bg-black text-white border-secondary" id="pool_pass" name="pool_pass" value="{{ pool.get('pass', '') }}">
</div>
</div>
<hr class="border-secondary">
<h5 class="card-title text-info mb-3">Hardware (Gridseed)</h5>
<div class="mb-3">
<label for="freq" class="form-label text-white">Frequenz (MHz)</label>
<select class="form-select bg-black text-white border-secondary" id="freq" name="freq">
{% set current_freq = config.get('freq', '850')|string %}
<option value="600" {% if current_freq == '600' %}selected{% endif %}>600 MHz (Low Power)</option>
<option value="750" {% if current_freq == '750' %}selected{% endif %}>750 MHz (Balanced)</option>
<option value="850" {% if current_freq == '850' %}selected{% endif %}>850 MHz (Stock)</option>
<option value="900" {% if current_freq == '900' %}selected{% endif %}>900 MHz (Overclock)</option>
<option value="950" {% if current_freq == '950' %}selected{% endif %}>950 MHz (High OC)</option>
</select>
<div class="form-text text-muted">Höhere Frequenzen benötigen möglicherweise mehr Spannung oder bessere Kühlung.</div>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-save me-2"></i>Speichern
</button>
<a href="{{ url_for('settings') }}" class="btn btn-outline-secondary ms-2">Abbrechen</a>
</div>
</form>
</div>
</div>
</div>
<div class="col-lg-4 mt-4 mt-lg-0">
<div class="card bg-dark border-secondary">
<div class="card-header border-secondary">Info</div>
<div class="card-body text-white">
<p>Nach dem Speichern der Einstellungen muss der Miner neu gestartet werden, damit die Änderungen wirksam werden.</p>
<p>Die <strong>cgminer.conf</strong> Datei wird automatisch aktualisiert.</p>
</div>
</div>
</div>
</div>
</div>
<script>
function restartMiner() {
if(confirm("Möchten Sie den Miner wirklich neu starten?")) {
fetch('/control/restart')
.then(response => response.json())
.then(data => {
if(data.status === 'success') {
alert('Neustart Befehl gesendet.');
} else {
alert('Fehler: ' + data.message);
}
})
.catch(error => console.error('Error:', error));
}
}
</script>
{% endblock %}