Semaine 11
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Gestion du parc{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/equipments.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<nav><a href="{{ url_for('index') }}">Accueil</a> | <a href="{{ url_for('equipments_page') }}">Équipements</a></nav>
|
||||
<main>
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="flash flash-{{ category }}" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Équipements{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Inventaire des équipements</h1>
|
||||
|
||||
<section>
|
||||
<h2>Ajouter un équipement</h2>
|
||||
<form method="post" action="{{ url_for('create_equipment_form') }}">
|
||||
<label>Hostname <input type="text" name="hostname" required></label>
|
||||
<label>Type
|
||||
<select name="type" required>
|
||||
{% for t in types %}
|
||||
<option value="{{ t }}">{{ t }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>Adresse IP <input type="text" name="ip_address" required></label>
|
||||
<label>Latence (ms) <input type="number" name="latency" step="0.1" min="0"></label>
|
||||
<label><input type="checkbox" name="is_active" checked> Actif</label>
|
||||
|
||||
<fieldset>
|
||||
<legend>Interfaces</legend>
|
||||
<div class="interface-row">
|
||||
<input type="number" name="ports[]" placeholder="Port" min="0" max="65535">
|
||||
<input type="text" name="services[]" placeholder="Service">
|
||||
</div>
|
||||
<div class="interface-row">
|
||||
<input type="number" name="ports[]" placeholder="Port" min="0" max="65535">
|
||||
<input type="text" name="services[]" placeholder="Service">
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit">Créer</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Équipements enregistrés ({{ equipments|length }})</h2>
|
||||
{% if equipments %}
|
||||
<table class="equipments-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Hostname</th>
|
||||
<th>Type</th>
|
||||
<th>Adresse IP</th>
|
||||
<th>Latence</th>
|
||||
<th>État</th>
|
||||
<th>Interfaces</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for eq in equipments %}
|
||||
<tr class="{% if not eq.is_active %}row-inactive{% else %}row-active{% endif %}">
|
||||
<td>{{ eq.id }}</td>
|
||||
<td>{{ eq.hostname }}</td>
|
||||
<td><span class="badge">{{ eq.type }}</span></td>
|
||||
<td>{{ eq.ip_address }}</td>
|
||||
<td>{{ eq.latency if eq.latency is not none else '-' }} ms</td>
|
||||
<td>
|
||||
{% if eq.is_active %}
|
||||
<span class="status status-active">Actif</span>
|
||||
{% else %}
|
||||
<span class="status status-inactive">Inactif</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if eq.interfaces %}
|
||||
<ul class="interfaces-list">
|
||||
{% for i in eq.interfaces %}
|
||||
<li>{{ i.service }} : {{ i.port }}/tcp</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<form method="post" action="{{ url_for('toggle_equipment', equipment_id=eq.id) }}">
|
||||
<button type="submit" class="btn-toggle">
|
||||
{% if eq.is_active %}Désactiver{% else %}Activer{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="{{ url_for('delete_equipment_form', equipment_id=eq.id) }}"
|
||||
onsubmit="return confirm('Confirmer la suppression de {{ eq.hostname }} ?');">
|
||||
<button type="submit" class="btn-delete">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="empty">Aucun équipement enregistré.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Accueil{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Bienvenue</h1>
|
||||
<p><a href="{{ url_for('equipments_page') }}">Accéder à l'inventaire</a></p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user