Semaine 11

This commit is contained in:
gauvainboiche
2026-07-11 21:38:00 +02:00
parent d3d2416dea
commit 0d071d2843
281 changed files with 54412 additions and 0 deletions
@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block title %}Active devices - Network Inventory{% endblock %}
{% block content %}
<h1>Active devices</h1>
<p>Signed-in as <strong>{{ username }}</strong>.</p>
<ul>
{% for equipment in equipments %}
<li>{{ equipment.hostname }}</li>
{% else %}
<li><em>No active device.</em></li>
{% endfor %}
</ul>
{% endblock %}
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}NETWORK INVENTORY{% endblock %}</title>
<style>
body { font-family: sans-serif; margin: 2rem; }
header, footer { background: #f4f4f4; padding: 1rem; }
nav a { margin-right: 1rem; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ccc; padding: 0.5rem; text-align: left; }
th { background: #eee; }
.up { color: green; font-weight: bold; }
.down { color: red; font-weight: bold; }
</style>
</head>
<body>
<header>
<nav>
<strong>- MENU -</strong>
<a href="{{ url_for('index') }}">Home</a>
<a href="{{ url_for('actives') }}">Active devices</a>
<a href="{{ url_for('details') }}">Details</a>
<a href="{{ url_for('stats') }}">Stats</a>
</nav>
</header>
<main>
{% block content %}{% endblock %}
</main>
<footer>Gauvain B. - Flask Jinja2 app</footer>
</body>
</html>
@@ -0,0 +1,43 @@
{% extends "base.html" %}
{% block title %}Equipment - Network Inventory{% endblock %}
{% block content %}
<p>Signed-in as <strong>{{ username }}</strong>.</p>
{% if equipment %}
<h1>{{ equipment.hostname }}</h1>
<table>
<tbody>
<tr>
<th>ID</th>
<td>{{ equipment.id }}</td>
</tr>
<tr>
<th>Hostname</th>
<td>{{ equipment.hostname }}</td>
</tr>
<tr>
<th>Type</th>
<td>{{ equipment.type }}</td>
</tr>
<tr>
<th>State</th>
<td>
{% if equipment.active %}
<span class="up">UP</span>
{% else %}
<span class="down">DOWN</span>
{% endif %}
</td>
</tr>
</tbody>
</table>
{% else %}
<h1>There's no device with this ID</h1>
<p>The requested equipment (ID {{ equipment_id }}) does not exist.</p>
{% endif %}
<p><a href="{{ url_for('details') }}">← Back to all devices</a></p>
{% endblock %}
@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}Home - Network Inventory{% endblock %}
{% block content %}
<h1>Welcome, {{ username }}.</h1>
{% if username == "administratort" %}
<p>You signed-in with ADMIN rights.</p>
{% else %}
<p>You signed-in with USER rights.</p>
{% endif %}
<h2>Devices list:</h2>
<ul>
{% for equipment in equipments %}
<li>{{ equipment.hostname }}</li>
{% endfor %}
</ul>
{% endblock %}
@@ -0,0 +1,39 @@
{% extends "base.html" %}
{% block title %}Details - Network Inventory{% endblock %}
{% block content %}
<h1>Device details</h1>
<p>Signed-in as <strong>{{ username }}</strong>.</p>
<table>
<thead>
<tr>
<th>ID</th>
<th>Hostname</th>
<th>Type</th>
<th>State</th>
</tr>
</thead>
<tbody>
{% for equipment in equipments %}
<tr>
<td>{{ equipment.id }}</td>
<td>
<a href="{{ url_for('equipment_detail', equipment_id=equipment.id) }}">
{{ equipment.hostname }}
</a>
</td>
<td>{{ equipment.type }}</td>
<td>
{% if equipment.active %}
<span class="up">UP</span>
{% else %}
<span class="down">DOWN</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
@@ -0,0 +1,35 @@
{% extends "base.html" %}
{% block title %}Statistics - Network Inventory{% endblock %}
{% block content %}
<h1>Inventory statistics</h1>
<p>Signed-in as <strong>{{ username }}</strong>.</p>
{% if total > 0 %}
<table>
<thead>
<tr>
<th>Metric</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>Total equipments</td>
<td>{{ total }}</td>
</tr>
<tr>
<td>Active</td>
<td><span class="up">{{ active }}</span></td>
</tr>
<tr>
<td>Inactive</td>
<td><span class="down">{{ inactive }}</span></td>
</tr>
</tbody>
</table>
{% else %}
<p><em>There's no equipment in the inventory.</em></p>
{% endif %}
{% endblock %}