Fixes status page design

main
Yasen Pramatarov 2025-01-24 11:48:37 +02:00
parent e59920cfd0
commit fc71cdd7f8
8 changed files with 119 additions and 110 deletions

View File

@ -286,7 +286,7 @@ class Agent {
$base64Url_payload = $this->base64UrlEncode($payload);
// signature
$signature = hash_hmac('sha256', $base64Url_header . "." . $base64Url_payload, $secret_key, true);
$signature = hash_hmac('sha256', $base64Url_header . "." . $base64Url_payload, $secret_key ?? '', true);
$base64Url_signature = $this->base64UrlEncode($signature);
// build the JWT

View File

@ -13,7 +13,9 @@ include '../app/includes/messages.php';
include '../app/includes/messages-show.php';
require '../app/classes/agent.php';
require '../app/classes/host.php';
$agentObject = new Agent($dbWeb);
$hostObject = new Host($dbWeb);
include '../app/templates/status-server.php';
@ -25,49 +27,58 @@ foreach ($platformsAll as $platform) {
if ($response['error'] !== null) {
$jilo_database_status = $response['error'];
} else {
$jilo_database_status = 'OK';
$jilo_database_status = 'Connected';
}
include '../app/templates/status-platform.php';
// fetch agent details for the current platform
$agentDetails = $agentObject->getAgentDetails($platform['id']);
foreach ($agentDetails as $agent) {
$agent_url = parse_url($agent['url']);
$agent_protocol = isset($agent_url['scheme']) ? $agent_url['scheme']: '';
$agent_host = isset($agent_url['host']) ? $agent_url['host']: '';
$agent_port = isset($agent_url['port']) ? $agent_url['port']: '';
// fetch hosts for the current platform
$hostDetails = $hostObject->getHostDetails($platform['id']);
foreach ($hostDetails as $host) {
// fetch agent details for the current host
$agentDetails = $agentObject->getAgentDetails($host['id']);
foreach ($agentDetails as $agent) {
// we try to parse the URL to scheme:/host:port
$agent_url = parse_url($agent['url']);
$agent_protocol = isset($agent_url['scheme']) ? $agent_url['scheme']: '';
// on failure we keep the full value for displaying purpose
$agent_host = isset($agent_url['host']) ? $agent_url['host']: $agent['url'];
$agent_port = isset($agent_url['port']) ? $agent_url['port']: '';
// we get agent data to check availability
$agent_response = $agentObject->fetchAgent($agent['id'], true);
$agent_data = json_decode($agent_response);
// we get agent data to check availability
$agent_response = $agentObject->fetchAgent($agent['id'], true);
$agent_data = json_decode($agent_response);
// determine agent availability based on response data
if (json_last_error() === JSON_ERROR_NONE) {
$agent_availability = 'unknown';
foreach ($agent_data as $key => $value) {
if ($key === 'error') {
$agent_availability = $value;
break;
}
if (preg_match('/_state$/', $key)) {
if ($value === 'error') {
$agent_availability = 'not running';
// determine agent availability based on response data
if (json_last_error() === JSON_ERROR_NONE) {
$agent_availability = 'unknown';
foreach ($agent_data as $key => $value) {
if ($key === 'error') {
$agent_availability = $value;
break;
}
if ($value === 'running') {
$agent_availability = 'running';
break;
if (preg_match('/_state$/', $key)) {
if ($value === 'error') {
$agent_availability = 'not running';
break;
}
if ($value === 'running') {
$agent_availability = 'running';
break;
}
}
}
} else {
$agent_availability = 'json error';
}
} else {
$agent_availability = 'json error';
}
include '../app/templates/status-agent.php';
include '../app/templates/status-agent.php';
}
}
echo '</div>';
echo '</div>';
echo "\n\t\t\t\t\t\t\t</div>\n";
}
echo "\n\t\t\t\t\t\t</div>";
echo "\n\t\t\t\t\t</div>";
echo "\n\t\t\t\t</div>";
?>

View File

@ -12,14 +12,13 @@
</div>
<script src="static/sidebar.js"></script>
<script src="static/sidebar.js"></script>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<script>
// dismissible messages
document.addEventListener('DOMContentLoaded', function() {
@ -39,7 +38,6 @@ document.addEventListener('DOMContentLoaded', function() {
});
</script>
</body>
</html>

View File

@ -38,13 +38,14 @@
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<?php if (isset($messages) && is_array($messages)): ?>
<?php foreach ($messages as $msg): ?>
<?= Messages::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null) ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div class="container-fluid">
<div class="row">
<div class="col">
<?php if (isset($messages) && is_array($messages)): ?>
<?php foreach ($messages as $msg): ?>
<?= Messages::render($msg['category'], $msg['key'], $msg['custom_message'] ?? null) ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>

View File

@ -10,7 +10,7 @@
</div>
</div>
<li class="font-weight-light text-uppercase" style="font-size: 0.5em; color: whitesmoke; margin-right: 70px; align-content: center;">version&nbsp;<?= htmlspecialchars($config['version']) ?></li>
<li class="font-weight-light text-uppercase" style="font-size: 0.5em; color: whitesmoke; margin-right: 70px; align-content: center;">version&nbsp;<?= htmlspecialchars($config['version']) ?></li>
<?php if ( isset($_SESSION['username']) ) { ?>

View File

@ -1,19 +1,19 @@
<!-- jilo agent status -->
<div class="d-flex align-items-center flex-wrap border-top p-3">
<div class="d-flex align-items-center me-4">
<span class="me-2">Jilo agent
<a href="<?= htmlspecialchars($app_root) ?>?page=config#platform<?= htmlspecialchars($platform['id']) ?>agent<?= htmlspecialchars($agent['id']) ?>" class="text-decoration-none">
<?= htmlspecialchars($agent['agent_description']) ?>
</a>:
</span>
<span class="badge <?= $agent_availability === 'running' ? 'bg-success' : 'bg-danger' ?>" title="<?= $agent_availability !== 'running' ? htmlspecialchars($agent_availability) : '' ?>" data-toggle="tooltip" data-placement="right" data-offset="30.0">
<?= $agent_availability === 'running' ? 'Running' : 'Error' ?>
</span>
</div>
<div class="d-flex align-items-center me-4">
<span class="me-4">Host: <strong><?= htmlspecialchars($agent_host) ?></strong></span>
<span class="me-4">Port: <strong><?= htmlspecialchars($agent_port) ?></strong></span>
<span>Endpoint: <strong><?= htmlspecialchars($agent['agent_endpoint']) ?></strong></span>
</div>
</div>
<!-- jilo agent status -->
<div class="d-flex align-items-center flex-wrap border-top p-3">
<div class="d-flex align-items-center me-4">
<span class="me-2">Jilo agent
<a href="<?= htmlspecialchars($app_root) ?>?page=settings#platform-<?= htmlspecialchars($platform['id']) ?>agent-<?= htmlspecialchars($agent['id']) ?>" class="text-decoration-none">
<?= htmlspecialchars($agent['agent_description']) ?>
</a>:
</span>
<span class="badge <?= $agent_availability === 'running' ? 'bg-success' : 'bg-danger' ?>" title="<?= $agent_availability !== 'running' ? htmlspecialchars($agent_availability) : '' ?>" data-toggle="tooltip" data-placement="right" data-offset="30.0">
<?= $agent_availability === 'running' ? 'Running' : 'Error' ?>
</span>
</div>
<div class="d-flex align-items-center me-4">
<span class="me-4">Host: <strong><?= htmlspecialchars($agent_host) ?></strong></span>
<span class="me-4">Port: <?= isset($agent_port) && $agent_port !== '' ? '<strong>' . htmlspecialchars($agent_port) . '</strong>' : '<em class="small text-muted">not set</em>' ?></span>
<span>Endpoint: <strong><?= htmlspecialchars($agent['agent_endpoint']) ?></strong></span>
</div>
</div>

View File

@ -1,21 +1,20 @@
<!-- jitsi platform status -->
<div class="card mt-3 mb-3">
<div class="card-header">
<h4>
<a href="<?= htmlspecialchars($app_root) ?>?page=config#platform<?= htmlspecialchars($platform['id']) ?>" class="text-decoration-none">
Jitsi platform "<?= htmlspecialchars($platform['name']) ?>"
</a>
</h4>
<small class="text-muted">Remote Jitsi Meet installation with its database and agents here.</small>
</div>
<div class="card-body p-0">
<div class="card-body">
<div class="d-flex align-items-center flex-wrap">
<span class="me-4">Jilo database: <strong><?= htmlspecialchars($platform['jilo_database']) ?></strong></span>
<div class="d-flex align-items-center">
<span class="me-2">Status:</span>
<span class="badge <?= $jilo_database_status === 'OK' ? 'bg-success' : 'bg-danger' ?>"><?= htmlspecialchars($jilo_database_status) ?></span>
</div>
</div>
</div>
<!-- jitsi platform status -->
<div class="card mt-3 mb-3">
<div class="card-header">
<h4>
<a href="<?= htmlspecialchars($app_root) ?>?page=settings#platform-<?= htmlspecialchars($platform['id']) ?>" class="text-decoration-none">
Jitsi platform "<?= htmlspecialchars($platform['name']) ?>"
</a>
</h4>
<small class="text-muted">Remote Jitsi Meet installation with its database and agents here.</small>
</div>
<div class="card-body">
<div class="d-flex align-items-center flex-wrap">
<span class="me-4">Jilo database: <strong><?= htmlspecialchars($platform['jilo_database']) ?></strong></span>
<div class="d-flex align-items-center">
<span class="me-2">Status:</span>
<span class="badge <?= $jilo_database_status === 'Connected' ? 'bg-success' : 'bg-danger' ?>"><?= htmlspecialchars($jilo_database_status) ?></span>
</div>
</div>
</div>

View File

@ -1,29 +1,29 @@
<!-- jilo status -->
<div class="container-fluid mt-2">
<div class="row mb-4">
<div class="col-md-6 mb-5">
<h2>Jilo status</h2>
</div>
<div class="row mb-4">
<!-- jilo status -->
<div class="card mt-3">
<div class="card-header">
<h4>Jilo server</h4>
<small class="text-muted">Responsible for periodic checks of remote agents and storing received data.</small>
</div>
<div class="card-body">
<div class="d-flex align-items-center flex-wrap">
<div class="d-flex align-items-center me-4">
<span class="me-2">Jilo server:</span>
<span class="badge <?= $server_status ? 'bg-success' : 'bg-danger' ?>">
<?= $server_status ? 'Running' : 'Not running' ?>
</span>
<!-- jilo status -->
<div class="container-fluid mt-2">
<div class="row mb-4">
<div class="col-md-6 mb-5">
<h2>Jilo status</h2>
</div>
<span class="me-4">Host: <strong><?= htmlspecialchars($server_host) ?></strong></span>
<span class="me-4">Port: <strong><?= htmlspecialchars($server_port) ?></strong></span>
<span>Endpoint: <strong><?= htmlspecialchars($server_endpoint) ?></strong></span>
</div>
</div>
</div>
<div class="row mb-4">
<!-- jilo server status -->
<div class="card mt-3">
<div class="card-header">
<h4>Jilo server</h4>
<small class="text-muted">Responsible for periodic checks of remote agents and storing received data.</small>
</div>
<div class="card-body">
<div class="d-flex align-items-center flex-wrap">
<div class="d-flex align-items-center me-4">
<span class="me-2">Jilo server:</span>
<span class="badge <?= $server_status ? 'bg-success' : 'bg-danger' ?>">
<?= $server_status ? 'Running' : 'Not running' ?>
</span>
</div>
<span class="me-4">Host: <strong><?= htmlspecialchars($server_host) ?></strong></span>
<span class="me-4">Port: <strong><?= htmlspecialchars($server_port) ?></strong></span>
<span>Endpoint: <strong><?= htmlspecialchars($server_endpoint) ?></strong></span>
</div>
</div>
</div>