Files
Web-Infra-Reports-IT/Hyper-V/Legacy-VMList.php
e025532 20e3d5a1b0 .
2025-04-22 09:08:30 +02:00

154 lines
6.6 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Page Title -->
<title>Web Infra Reports IT</title>
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
<!-- JQuery -->
<script src="/js/jquery-3.6.1.min.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
<link rel="stylesheet" href="/css/preloader.css">
<script src="/js/bootstrap.bundle.min.js"></script>
<!-- Bootstrap-tables -->
<link rel="stylesheet" href="/css/bootstrap-table.min.css">
<script src="/js/bootstrap-table.min.js"></script>
<script src="/js/bootstrap-table-fr-FR.min.js"></script>
<script src="/js/tableExport.min.js"></script>
<script src="/js/bootstrap-table-export.min.js"></script>
<script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php $answers = Invoke_Infra("select * from cmdb_vms where cluster not like 'DMV-VMH-SYN%' and decomtime is null order by name"); ?>
<!-- HTML -->
<div class="container-fluid" id="content">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h2><span class="badge text-bg-secondary " style="width:100%;" >Legacy Hyper-V VM List - <?php echo count($answers); ?> VMs</span></h2>
<!-- Main content -->
<div class="container-fluid">
<!-- TABLE -->
<div>
<table class='table table-bordered table-hover table-sm' id='t1' data-height="820" data-toggle="table" data-search="true" data-show-columns="true" data-export-types="['xlsx','csv','json']" data-show-export="true" data-sortable="true" data-sort-name="vm">
<thead> <!-- Header -->
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='owner' data-sortable='true'>Owner</th>
<th data-field='infos' data-sortable='true'>Infos</th>
<th data-field='PreferedOwner' data-sortable='true'>Prefered Owner</th>
<th data-field='gen-ver' data-sortable='true'>Gen & Version</th>
<th data-field='LastInventory' data-sortable='true'>Last Seen</th>
</thead>
<tbody> <!-- Body -->
<?php
foreach ($answers as $row) {
echo "<tr>";
# Name
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($row['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($row['State'] == "Off" || $row['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($row['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
echo "<td>".$state." <b>".$row['Name']."</td>";
# Owner
echo "<td>".$row['Owner']."</td>";
# Infos
echo '<td><span class="badge rounded-pill bg-secondary text-light">'.$row['Memory'].'GB / '.$row['CPU'].' CPU</span> ';
echo '<span class="badge rounded-pill bg-secondary text-light">VHDx(s) : '.$row['TotalDiskSize'].' GB</span> ';
if($row['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
if($row['DynamicVHD'] == "Y"){
echo '<span class="badge rounded-pill bg-secondary text-warning">Dyn. VHDX</span> ';
}
echo "</td>";
# Prefered Owner
if($row['Owner'] == $row['PreferredOwner']){
echo '<td><span class="badge rounded-pill bg-success text-light">'.$row['Owner'].'</span></td> ';
}else{
if($row['IsClustered'] == 'True'){
echo '<td><span class="badge rounded-pill bg-warning text-dark">'.$row['PreferredOwner'].'</span></td> ';
}else{
echo '<td><span class="badge rounded-pill bg-danger text-dark">NOT CLUSTERED</span></td> ';
}
}
# Gen & Ver
echo "<td>";
if($row['Generation'] == "2"){
echo '<span class="badge rounded-pill bg-success text-light">Gen '.$row['Generation'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Gen '.$row['Generation'].'</span> ';
}
if($row['Version'] == "10.0"){
echo '<span class="badge rounded-pill bg-success text-light">Ver '.$row['Version'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Ver '.$row['Version'].'</span> ';
}
echo "</td>";
# TS
echo "<td>".$row['LastInventory']."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br>
</div>
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>
<SCRIPT>
$(function() {
// Exécution initiale pour définir la hauteur
adjustTableHeight();
// Événement de redimensionnement
$(window).on('resize', function() {
adjustTableHeight();
});
function adjustTableHeight() {
var windowHeight = $(window).height();
var tableTop = $('#t1').offset().top;
var footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
var availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
$('#t1').bootstrapTable('refreshOptions', {
height: availableHeight
});
}
});
</script>