modern style

This commit is contained in:
Adrien MALINGREY 2025-03-30 21:10:30 +02:00
parent 25f0f7cd91
commit 5fc24fc45e
3 changed files with 245 additions and 112 deletions

View File

@ -2,50 +2,50 @@
<html lang='fr'>
<head>
<title>Schémas des VLANs</title>
<style>
ul {
list-style: none;
}
details {
cursor: pointer
}
</style>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<div class="container">
<h1>Schémas des VLANs</h1>
</header>
<main>
<div class="file-list">
<ul>
<?php
$basedir = __DIR__ . "/confs";
function recursive_ls($path) {
global $basedir;
$strdir = "";
foreach (scandir($path) as $filename) {
if (substr($filename, 0, 1) != '.') {
$fullpath = $path ."/". $filename;
if (is_dir($fullpath)) {
$str = "";
$cfgPaths = glob($fullpath . '/*.cfg');
if (count($cfgPaths)) {
$str .= "<ul>\n";
foreach ($cfgPaths as $conf) {
$str .= "<li><a href='vlans.php?switch=" . str_replace($basedir.'/', "", $conf) . "' target='_blank'>" . basename($conf) . "</a></li>\n";
}
$str .= "</ul>\n";
}
$str = recursive_ls($fullpath) . $str;
if ($str != "") $strdir .= "<li>\n<details>\n<summary>" . $filename . "</summary>\n" . $str . "</details>\n</li>\n";;
if (substr(basename($path), 0, 1) == '.') {
return "";
}
if (is_dir($path)) {
$str = "";
foreach (scandir($path) as $filename) {
$str .= recursive_ls("$path/$filename");
}
if ($str == "") {
return "";
} else {
if ($path == $basedir) {
return "<ul>\n$str\n</ul>\n";
} else {
return "<li>\n<details>\n<summary>" . basename($path) . "</summary>\n<ul>\n" . $str . "</ul>\n</details>\n</li>\n";
}
}
}
if ($strdir != "") $strdir = "<ul>\n" . $strdir . "</ul>\n";
return $strdir;
if (substr($path, -4) == ".cfg") {
return "<li><a href='vlans.php?switch=".str_replace("$basedir/", "", $path)."' target='_blank'>" . basename($path) . "</a></li>\n";
}
return "";
}
echo recursive_ls($basedir);
?>
</main>
</ul>
</div>
</div>
</body>
</html>

135
style.css
View File

@ -1,31 +1,139 @@
:root {
--k: 1353651.53435435;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f5f5f5;
color: #333;
}
.container {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
}
h1 {
color: #2c3e50;
margin-bottom: 1rem;
text-align: center;
}
h2 {
color: #34495e;
margin-bottom: 0.5rem;
}
.file-list summary {
padding: 0.5rem 1rem;
background-color: white;
border-radius: 4px;
color: #2c3e50;
transition: background-color 0.3s;
margin-bottom: 0.5em;
font-weight: bold;
}
.file-list summary:hover {
background-color: #e0e0e0;
}
.file-list summary::marker {
content: "📁 ";
}
.file-list details[open] summary::marker {
content: "📂 ";
}
.file-list ul {
list-style: none;
}
.file-list li {
margin-left: 0.5rem;
}
.file-list a::before {
content: "📄 "
}
.file-list a {
display: block;
padding: 0.5rem 1rem;
background-color: white;
border-radius: 4px;
text-decoration: none;
color: #2c3e50;
transition: background-color 0.3s;
margin-bottom: 0.5em;
}
.file-list a:hover {
background-color: #e0e0e0;
}
.link {
display: inline-block;
margin-bottom: 1rem;
color: #3498db;
text-decoration: none;
}
.link:hover {
text-decoration: underline;
}
main {
display: flex;
flex-flow: wrap;
gap: 1rem;
}
ul {
list-style: none;
}
details {
cursor: pointer;
}
main > table {
margin: auto;
}
td {
text-align: left;
}
.member {
border-spacing: 0;
margin: 0;
border: 4px solid #335;
border: 8px solid #34495e;
border-radius: 6px;
}
.legend {
border-spacing: 0;
}
.legend tbody {
border: 2px solid black;
}
.member td,
.legend td {
border: 2px inset;
border: 2px inset #2c3e50;
}
.interface {
position: relative;
text-align: center;
@ -34,10 +142,24 @@ td {
mix-blend-mode: darken;
padding: 2px;
print-color-adjust: exact;
cursor: help;
text-shadow: 0 1px 2px rgba(0,0,0,0.2);
transition: 0.2s background-color;
}
.interface:hover {
background-color: #ddd;
}
.vlan {
background-color: hsl(calc(var(--k) * var(--pvid)) 100% 60%);
color: #ecf0f1;
background-color: hsl(calc(var(--k) * var(--pvid)) 65% 60%);
}
.vlan:hover {
background-color: hsl(calc(var(--k) * var(--pvid)) 65% 70%);
}
.trunk {
font-weight: bold;
border: 4px solid !important;
@ -53,6 +175,7 @@ td {
) !important;
padding: 0;
}
.hybrid {
background-image: linear-gradient(
135deg,
@ -60,11 +183,13 @@ td {
hsl(calc(var(--k) * var(--untagged)) 100% 60%) 50%
);
}
.shutdown:not([class*="loopback-detection action shutdown"]) {
background-color: lightgray !important;
background-image: none !important;
color: gray !important;
}
.poe::before {
content: "⚡";
font-size: 0.7em;
@ -72,6 +197,7 @@ td {
top: 0;
left: 0;
}
.voice_vlan::after {
content: "📞";
font-size: 0.7em;
@ -79,14 +205,17 @@ td {
bottom: 0;
left: 0;
}
footer {
display: flex;
flex-flow: column;
align-items: center;
}
#colorSlider {
width: 33%;
}
@media print {
#colorSliderLabel,
#colorSlider {

162
vlans.php
View File

@ -22,9 +22,9 @@ foreach ($interfaces as $interface) {
$stack[$interface["member"]][$interface["port"]] = $interface;
}
echo ("<!--");
/*echo ("<!--");
var_dump($interfaces);
echo ("-->");
echo ("-->");*/
?>
<!DOCTYPE HTML>
@ -36,85 +36,89 @@ echo ("-->");
</head>
<body>
<header>
<h1>
<div><?= $sysname[1] ?? "Switch sans nom" ?></div>
<small><a href="https://<?= $address[1] ?>" target="_blank"><?= $address[1] ?></a></small>
</h1>
</header>
<main>
<table>
<caption>
<h2>Interfaces</h2>
</caption>
<tbody>
<?php
function display_interface($interface, $odd)
{
if ($interface["port"] % 2 == $odd) {
echo "<td class='{$interface[0]}" . (isset($interface["voice_vlan"]) ? " voice_vlan" : "") . "' title='{$interface[0]}' style='{$interface["style"]}'>{$interface["port"]}</td>\n";
}
}
<div class="container">
<header>
<h1>
<div><?= $sysname[1] ?? "Switch sans nom" ?></div>
<small><a href="https://<?= $address[1] ?>" target="_blank" class="link"><?= $address[1] ?></a></small>
</h1>
</header>
foreach ($stack as $member => $interfaces) {
echo "<tr>\n<th>$member</th>\n<td>\n<table class='member'>\n<tbody>\n<tr>\n";
foreach ($interfaces as $interface) display_interface($interface, 1);
echo "</tr>\n<tr>\n";
foreach ($interfaces as $interface) display_interface($interface, 0);
echo "</tr>\n</tbody>\n</table>\n</td>\n</tr>\n";
}
?>
</tbody>
</table>
<table class='legend'>
<caption>
<h2>Légende</h2>
</caption>
<thead>
<tr>
<th>PVID</th>
<th>Nom</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
foreach ($vlans as $vlan) {
if (isset($vlan["pvid"]) and $vlan["pvid"] != 1) {
$name = $vlan["name"] ?? "";
$description = $vlan["description"] ?? "";
echo "<tr title='{$vlan[0]}'><td class='interface vlan' style='--pvid: {$vlan["pvid"]}'>{$vlan["pvid"]}</td><td>$name</td><td>$description</td></tr>";
<main>
<table>
<caption>
<h2>Interfaces</h2>
</caption>
<tbody>
<?php
function display_interface($interface, $odd)
{
if ($interface["port"] % 2 == $odd) {
echo "<td class='{$interface[0]}" . (isset($interface["voice_vlan"]) ? " voice_vlan" : "") . "' title='{$interface[0]}' style='{$interface["style"]}'>{$interface["port"]}</td>\n";
}
}
}
?>
<tr>
<td class='interface trunk'></td>
<td colspan='2'>Trunk</td>
</tr>
<tr>
<td class='interface hybrid' style='--tagged:60; --untagged:0'></td>
<td colspan='2'>Hybride (tagged/untagged)</td>
</tr>
<tr>
<td class='interface poe'></td>
<td colspan='2'>Power on Ethernet</td>
</tr>
<tr>
<td class='interface voice_vlan'></td>
<td colspan='2'>ToIP (voice-vlan)</td>
</tr>
<tr>
<td class='interface shutdown'></td>
<td colspan='2'>Interface désactivée</td>
</tr>
</tbody>
</table>
</main>
<footer>
<label id="colorSliderLabel" for="colorSlider">Changer les couleurs</label>
<input id="colorSlider" type="range" min="0" max="2000000" step="0.000000001" value="1353651.53435435"
oninput="document.documentElement.style.setProperty('--k', this.value);">
</footer>
foreach ($stack as $member => $interfaces) {
echo "<tr>\n<th>$member</th>\n<td>\n<table class='member'>\n<tbody>\n<tr>\n";
foreach ($interfaces as $interface) display_interface($interface, 1);
echo "</tr>\n<tr>\n";
foreach ($interfaces as $interface) display_interface($interface, 0);
echo "</tr>\n</tbody>\n</table>\n</td>\n</tr>\n";
}
?>
</tbody>
</table>
<table class='legend'>
<caption>
<h2>Légende</h2>
</caption>
<thead>
<tr>
<th>PVID</th>
<th>Nom</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
foreach ($vlans as $vlan) {
if (isset($vlan["pvid"]) and $vlan["pvid"] != 1) {
$name = $vlan["name"] ?? "";
$description = $vlan["description"] ?? "";
echo "<tr title='{$vlan[0]}'><td class='interface vlan' style='--pvid: {$vlan["pvid"]}'>{$vlan["pvid"]}</td><td>$name</td><td>$description</td></tr>";
}
}
?>
<tr>
<td class='interface trunk'></td>
<td colspan='2'>Trunk</td>
</tr>
<tr>
<td class='interface hybrid' style='--tagged:60; --untagged:0'></td>
<td colspan='2'>Hybride (tagged/untagged)</td>
</tr>
<tr>
<td class='interface poe'></td>
<td colspan='2'>Power on Ethernet</td>
</tr>
<tr>
<td class='interface voice_vlan'></td>
<td colspan='2'>ToIP (voice-vlan)</td>
</tr>
<tr>
<td class='interface shutdown'></td>
<td colspan='2'>Interface désactivée</td>
</tr>
</tbody>
</table>
</main>
<footer>
<label id="colorSliderLabel" for="colorSlider">Changer les couleurs</label>
<input id="colorSlider" type="range" min="0" max="2000000" step="0.000000001" value="1353651.53435435"
oninput="document.documentElement.style.setProperty('--k', this.value);">
<a href="index.php" class="link"> Retour à la liste</a>
</footer>
</div>
</body>
</html>