Correction API Flask + PostgreSQL + dashboard admin EcoCharge
This commit is contained in:
@@ -1,78 +1,299 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<title>Admin EcoCharge</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>EcoCharge — Dashboard Admin</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: Arial;
|
||||
background:#f5f7fb;
|
||||
padding:40px;
|
||||
/* ── Variables de couleur ── */
|
||||
:root {
|
||||
--vert: #2ecc71;
|
||||
--bleu: #1a1a2e;
|
||||
--gris: #16213e;
|
||||
--blanc: #f0f4f8;
|
||||
--muted: #7f8c8d;
|
||||
}
|
||||
|
||||
.card{
|
||||
background:white;
|
||||
padding:30px;
|
||||
border-radius:10px;
|
||||
box-shadow:0 4px 12px rgba(0,0,0,0.1);
|
||||
max-width:500px;
|
||||
/* ── Reset simple ── */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
h2{
|
||||
margin-top:0;
|
||||
body {
|
||||
background-color: var(--bleu);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
color: var(--blanc);
|
||||
min-height: 100vh;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
label{
|
||||
display:block;
|
||||
margin-top:15px;
|
||||
/* ── Conteneur principal centré ── */
|
||||
.conteneur {
|
||||
max-width: 640px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
input{
|
||||
width:100%;
|
||||
padding:8px;
|
||||
margin-top:5px;
|
||||
/* ── En-tête de la page ── */
|
||||
.entete {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
|
||||
button{
|
||||
margin-top:20px;
|
||||
padding:10px;
|
||||
background:#2563eb;
|
||||
color:white;
|
||||
border:none;
|
||||
border-radius:6px;
|
||||
cursor:pointer;
|
||||
.entete-titre {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
a{
|
||||
display:block;
|
||||
margin-top:20px;
|
||||
.entete-titre span {
|
||||
font-size: 36px;
|
||||
}
|
||||
|
||||
.entete-titre h1 {
|
||||
font-size: 24px;
|
||||
color: var(--vert);
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.entete-titre p {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* ── Lien de déconnexion ── */
|
||||
.deconnexion {
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
border: 1px solid #2c3e50;
|
||||
padding: 8px 14px;
|
||||
border-radius: 8px;
|
||||
transition: color 0.2s, border-color 0.2s;
|
||||
}
|
||||
|
||||
.deconnexion:hover {
|
||||
color: #e74c3c;
|
||||
border-color: #e74c3c;
|
||||
}
|
||||
|
||||
/* ── Carte blanche contenant le formulaire ── */
|
||||
.carte {
|
||||
background-color: var(--gris);
|
||||
border-radius: 16px;
|
||||
padding: 36px 32px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.carte h2 {
|
||||
font-size: 17px;
|
||||
color: var(--blanc);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.carte > p {
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
/* ── Séparateur entre les champs ── */
|
||||
.separateur {
|
||||
border: none;
|
||||
border-top: 1px solid #2c3e50;
|
||||
margin: 28px 0;
|
||||
}
|
||||
|
||||
/* ── Chaque groupe label + input + description ── */
|
||||
.champ {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.champ-entete {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.champ label {
|
||||
color: var(--blanc);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
/* Petite description sous le label */
|
||||
.champ-info {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Ligne input + unité */
|
||||
.input-ligne {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.champ input {
|
||||
flex: 1;
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #2c3e50;
|
||||
background-color: #0f3460;
|
||||
color: var(--blanc);
|
||||
font-size: 16px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.champ input:focus {
|
||||
border-color: var(--vert);
|
||||
}
|
||||
|
||||
/* Unité affichée à droite (%, °C, W) */
|
||||
.unite {
|
||||
color: var(--muted);
|
||||
font-size: 15px;
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
/* ── Bouton Sauvegarder ── */
|
||||
.bouton {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background-color: var(--vert);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
letter-spacing: 1px;
|
||||
margin-top: 8px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.bouton:hover {
|
||||
background-color: #27ae60;
|
||||
}
|
||||
|
||||
/* ── Message de confirmation Flask/Jinja ── */
|
||||
.succes {
|
||||
background-color: rgba(46, 204, 113, 0.15);
|
||||
border: 1px solid var(--vert);
|
||||
color: var(--vert);
|
||||
padding: 10px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
margin-bottom: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="card">
|
||||
<div class="conteneur">
|
||||
|
||||
<h2>Administration EcoCharge</h2>
|
||||
<!-- ── En-tête avec titre et bouton déconnexion ── -->
|
||||
<div class="entete">
|
||||
<div class="entete-titre">
|
||||
<span>⚡</span>
|
||||
<div>
|
||||
<h1>ECOCHARGE</h1>
|
||||
<p>Panneau d'administration</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Lien vers la route Flask /admin/logout -->
|
||||
<a class="deconnexion" href="/admin/logout">🚪 Déconnexion</a>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<!-- ── Carte principale ── -->
|
||||
<div class="carte">
|
||||
|
||||
<label>Seuil batterie minimum</label>
|
||||
<input type="number" step="0.1" name="min_battery" value="{{ settings.min_battery }}">
|
||||
<h2>Seuils d'alerte</h2>
|
||||
<p>Modifiez les valeurs puis cliquez sur "Sauvegarder".</p>
|
||||
|
||||
<label>Température max batterie</label>
|
||||
<input type="number" step="0.1" name="max_temp" value="{{ settings.max_temp }}">
|
||||
<!-- Formulaire — action vers la route Flask /admin/dashboard -->
|
||||
<form method="POST" action="/admin/dashboard">
|
||||
|
||||
<label>Puissance solaire minimum</label>
|
||||
<input type="number" step="0.1" name="min_power" value="{{ settings.min_power }}">
|
||||
<!-- ── Champ 1 : batterie minimum ── -->
|
||||
<div class="champ">
|
||||
<div class="champ-entete">
|
||||
<label for="min_battery">🔋 Tension batterie minimum</label>
|
||||
</div>
|
||||
<p class="champ-info">Alerte si la tension de la batterie descend sous ce seuil.</p>
|
||||
<br>
|
||||
<div class="input-ligne">
|
||||
<input
|
||||
type="number"
|
||||
id="min_battery"
|
||||
name="min_battery"
|
||||
value="{{ settings.min_battery }}"
|
||||
min="0"
|
||||
required
|
||||
>
|
||||
<span class="unite">V</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit">Sauvegarder</button>
|
||||
<hr class="separateur">
|
||||
|
||||
</form>
|
||||
<!-- ── Champ 2 : température maximum ── -->
|
||||
<div class="champ">
|
||||
<div class="champ-entete">
|
||||
<label for="max_temp">🌡️ Température maximum</label>
|
||||
</div>
|
||||
<p class="champ-info">Alerte si la température dépasse cette valeur.</p>
|
||||
<br>
|
||||
<div class="input-ligne">
|
||||
<input
|
||||
type="number"
|
||||
id="max_temp"
|
||||
name="max_temp"
|
||||
value="{{ settings.max_temp }}"
|
||||
min="0"
|
||||
max="100"
|
||||
required
|
||||
>
|
||||
<span class="unite">°C</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="/admin/logout">Se déconnecter</a>
|
||||
<hr class="separateur">
|
||||
|
||||
</div>
|
||||
<!-- ── Champ 3 : puissance minimum ── -->
|
||||
<div class="champ">
|
||||
<div class="champ-entete">
|
||||
<label for="min_power">☀️ Puissance minimum</label>
|
||||
</div>
|
||||
<p class="champ-info">Alerte si la production solaire descend sous ce seuil.</p>
|
||||
<br>
|
||||
<div class="input-ligne">
|
||||
<input
|
||||
type="number"
|
||||
id="min_power"
|
||||
name="min_power"
|
||||
value="{{ settings.min_power }}"
|
||||
min="0"
|
||||
required
|
||||
>
|
||||
<span class="unite">W</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="bouton" type="submit">💾 Sauvegarder</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -3,85 +3,182 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Connexion Admin - EcoCharge</title>
|
||||
<title>EcoCharge — Connexion</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f4f7fb;
|
||||
/* ── Variables de couleur ── */
|
||||
:root {
|
||||
--vert: #2ecc71;
|
||||
--bleu: #1a1a2e;
|
||||
--gris: #16213e;
|
||||
--blanc: #f0f4f8;
|
||||
--rouge: #e74c3c;
|
||||
}
|
||||
|
||||
/* ── Reset simple ── */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
width: 360px;
|
||||
margin: 100px auto;
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 18px rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 25px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
margin-top: 15px;
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button {
|
||||
/* ── Fond de page ── */
|
||||
body {
|
||||
background-color: var(--bleu);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* ── Carte de connexion ── */
|
||||
.carte {
|
||||
background-color: var(--gris);
|
||||
padding: 48px 40px;
|
||||
border-radius: 16px;
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 12px;
|
||||
max-width: 400px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
/* ── Logo / en-tête ── */
|
||||
.logo {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.logo-icone {
|
||||
font-size: 48px;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
color: var(--vert);
|
||||
font-size: 26px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.logo p {
|
||||
color: #7f8c8d;
|
||||
font-size: 13px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* ── Champs du formulaire ── */
|
||||
.champ {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.champ label {
|
||||
display: block;
|
||||
color: var(--blanc);
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.champ input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #2c3e50;
|
||||
background-color: #0f3460;
|
||||
color: var(--blanc);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
/* Met en valeur le champ actif */
|
||||
.champ input:focus {
|
||||
border-color: var(--vert);
|
||||
}
|
||||
|
||||
/* ── Message d'erreur Flask/Jinja ── */
|
||||
.erreur {
|
||||
background-color: rgba(231, 76, 60, 0.15);
|
||||
border: 1px solid var(--rouge);
|
||||
color: var(--rouge);
|
||||
padding: 10px 14px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ── Bouton de connexion ── */
|
||||
.bouton {
|
||||
width: 100%;
|
||||
padding: 13px;
|
||||
background-color: var(--vert);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
letter-spacing: 1px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
margin-top: 15px;
|
||||
text-align: center;
|
||||
.bouton:hover {
|
||||
background-color: #27ae60;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<h2>Connexion Admin</h2>
|
||||
|
||||
<div class="carte">
|
||||
|
||||
<!-- En-tête avec icône et nom du projet -->
|
||||
<div class="logo">
|
||||
<span class="logo-icone">⚡</span>
|
||||
<h1>ECOCHARGE</h1>
|
||||
<p>Interface d'administration</p>
|
||||
</div>
|
||||
|
||||
<!-- Message d'erreur affiché si Flask envoie une erreur -->
|
||||
{% if error %}
|
||||
<div class="erreur">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Formulaire de connexion — action vers la route Flask /admin/login -->
|
||||
<form method="POST" action="/admin/login">
|
||||
<label for="username">Nom d'utilisateur</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
|
||||
<label for="password">Mot de passe</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<div class="champ">
|
||||
<label for="username">Identifiant</label>
|
||||
<input
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
placeholder="admin"
|
||||
required
|
||||
autocomplete="username"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="champ">
|
||||
<label for="password">Mot de passe</label>
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
placeholder="••••••••"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
>
|
||||
</div>
|
||||
|
||||
<button class="bouton" type="submit">Se connecter</button>
|
||||
|
||||
<button type="submit">Se connecter</button>
|
||||
</form>
|
||||
|
||||
{% if error %}
|
||||
<p class="error">{{ error }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user