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); $base64Url_payload = $this->base64UrlEncode($payload);
// signature // 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); $base64Url_signature = $this->base64UrlEncode($signature);
// build the JWT // build the JWT

View File

@ -13,7 +13,9 @@ include '../app/includes/messages.php';
include '../app/includes/messages-show.php'; include '../app/includes/messages-show.php';
require '../app/classes/agent.php'; require '../app/classes/agent.php';
require '../app/classes/host.php';
$agentObject = new Agent($dbWeb); $agentObject = new Agent($dbWeb);
$hostObject = new Host($dbWeb);
include '../app/templates/status-server.php'; include '../app/templates/status-server.php';
@ -25,49 +27,58 @@ foreach ($platformsAll as $platform) {
if ($response['error'] !== null) { if ($response['error'] !== null) {
$jilo_database_status = $response['error']; $jilo_database_status = $response['error'];
} else { } else {
$jilo_database_status = 'OK'; $jilo_database_status = 'Connected';
} }
include '../app/templates/status-platform.php'; include '../app/templates/status-platform.php';
// fetch agent details for the current platform // fetch hosts for the current platform
$agentDetails = $agentObject->getAgentDetails($platform['id']); $hostDetails = $hostObject->getHostDetails($platform['id']);
foreach ($agentDetails as $agent) { foreach ($hostDetails as $host) {
$agent_url = parse_url($agent['url']); // fetch agent details for the current host
$agent_protocol = isset($agent_url['scheme']) ? $agent_url['scheme']: ''; $agentDetails = $agentObject->getAgentDetails($host['id']);
$agent_host = isset($agent_url['host']) ? $agent_url['host']: ''; foreach ($agentDetails as $agent) {
$agent_port = isset($agent_url['port']) ? $agent_url['port']: ''; // 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 // we get agent data to check availability
$agent_response = $agentObject->fetchAgent($agent['id'], true); $agent_response = $agentObject->fetchAgent($agent['id'], true);
$agent_data = json_decode($agent_response); $agent_data = json_decode($agent_response);
// determine agent availability based on response data // determine agent availability based on response data
if (json_last_error() === JSON_ERROR_NONE) { if (json_last_error() === JSON_ERROR_NONE) {
$agent_availability = 'unknown'; $agent_availability = 'unknown';
foreach ($agent_data as $key => $value) { foreach ($agent_data as $key => $value) {
if ($key === 'error') { if ($key === 'error') {
$agent_availability = $value; $agent_availability = $value;
break;
}
if (preg_match('/_state$/', $key)) {
if ($value === 'error') {
$agent_availability = 'not running';
break; break;
} }
if ($value === 'running') { if (preg_match('/_state$/', $key)) {
$agent_availability = 'running'; if ($value === 'error') {
break; $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 "\n\t\t\t\t\t\t\t</div>\n";
echo '</div>';
} }
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> </div>
<script src="static/sidebar.js"></script> <script src="static/sidebar.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
}); });
</script> </script>
<script> <script>
// dismissible messages // dismissible messages
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
@ -39,7 +38,6 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
</script> </script>
</body> </body>
</html> </html>

View File

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

View File

@ -10,7 +10,7 @@
</div> </div>
</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']) ) { ?> <?php if ( isset($_SESSION['username']) ) { ?>

View File

@ -1,19 +1,19 @@
<!-- jilo agent status --> <!-- jilo agent status -->
<div class="d-flex align-items-center flex-wrap border-top p-3"> <div class="d-flex align-items-center flex-wrap border-top p-3">
<div class="d-flex align-items-center me-4"> <div class="d-flex align-items-center me-4">
<span class="me-2">Jilo agent <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"> <a href="<?= htmlspecialchars($app_root) ?>?page=settings#platform-<?= htmlspecialchars($platform['id']) ?>agent-<?= htmlspecialchars($agent['id']) ?>" class="text-decoration-none">
<?= htmlspecialchars($agent['agent_description']) ?> <?= htmlspecialchars($agent['agent_description']) ?>
</a>: </a>:
</span> </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"> <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' ?> <?= $agent_availability === 'running' ? 'Running' : 'Error' ?>
</span> </span>
</div> </div>
<div class="d-flex align-items-center me-4"> <div class="d-flex align-items-center me-4">
<span class="me-4">Host: <strong><?= htmlspecialchars($agent_host) ?></strong></span> <span class="me-4">Host: <strong><?= htmlspecialchars($agent_host) ?></strong></span>
<span class="me-4">Port: <strong><?= htmlspecialchars($agent_port) ?></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> <span>Endpoint: <strong><?= htmlspecialchars($agent['agent_endpoint']) ?></strong></span>
</div> </div>
</div> </div>

View File

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

View File

@ -1,29 +1,29 @@
<!-- jilo status --> <!-- jilo status -->
<div class="container-fluid mt-2"> <div class="container-fluid mt-2">
<div class="row mb-4"> <div class="row mb-4">
<div class="col-md-6 mb-5"> <div class="col-md-6 mb-5">
<h2>Jilo status</h2> <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>
</div> </div>
<span class="me-4">Host: <strong><?= htmlspecialchars($server_host) ?></strong></span> <div class="row mb-4">
<span class="me-4">Port: <strong><?= htmlspecialchars($server_port) ?></strong></span>
<span>Endpoint: <strong><?= htmlspecialchars($server_endpoint) ?></strong></span> <!-- jilo server status -->
</div> <div class="card mt-3">
</div> <div class="card-header">
</div> <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>