feat: Add Library Visualizer (Slots & Drives) to Web UI
This commit is contained in:
@@ -148,10 +148,16 @@ switch ($action) {
|
||||
getDeviceMapping();
|
||||
break;
|
||||
|
||||
case 'library_status':
|
||||
getLibraryStatus();
|
||||
break;
|
||||
|
||||
case 'system_health':
|
||||
getSystemHealth();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'restart_appliance':
|
||||
restartAppliance();
|
||||
break;
|
||||
@@ -938,4 +944,59 @@ function getDeviceMapping() {
|
||||
'raw_output' => $output
|
||||
]);
|
||||
}
|
||||
|
||||
function getLibraryStatus() {
|
||||
// Find library contents file
|
||||
$files = glob('/etc/mhvtl/library_contents.*');
|
||||
if (empty($files)) {
|
||||
echo json_encode(['success' => false, 'error' => 'No library config found']);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the first one found, typically library_contents.10
|
||||
$file = $files[0];
|
||||
$libId = substr(strrchr($file, '.'), 1);
|
||||
|
||||
$lines = file($file);
|
||||
$status = [
|
||||
'library_id' => $libId,
|
||||
'drives' => [],
|
||||
'slots' => [],
|
||||
'maps' => [],
|
||||
'pickers' => []
|
||||
];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if (empty($line) || $line[0] == '#') continue;
|
||||
|
||||
if (preg_match('/^Drive\s+(\d+):\s*(.*)$/i', $line, $matches)) {
|
||||
$status['drives'][] = [
|
||||
'id' => intval($matches[1]),
|
||||
'barcode' => trim($matches[2]),
|
||||
'full' => !empty(trim($matches[2]))
|
||||
];
|
||||
} elseif (preg_match('/^Slot\s+(\d+):\s*(.*)$/i', $line, $matches)) {
|
||||
$status['slots'][] = [
|
||||
'id' => intval($matches[1]),
|
||||
'barcode' => trim($matches[2]),
|
||||
'full' => !empty(trim($matches[2]))
|
||||
];
|
||||
} elseif (preg_match('/^MAP\s+(\d+):\s*(.*)$/i', $line, $matches)) {
|
||||
$status['maps'][] = [
|
||||
'id' => intval($matches[1]),
|
||||
'barcode' => trim($matches[2]),
|
||||
'full' => !empty(trim($matches[2]))
|
||||
];
|
||||
} elseif (preg_match('/^Picker\s+(\d+):\s*(.*)$/i', $line, $matches)) {
|
||||
$status['pickers'][] = [
|
||||
'id' => intval($matches[1]),
|
||||
'barcode' => trim($matches[2]),
|
||||
'full' => !empty(trim($matches[2]))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'data' => $status]);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user