Adds initial "latest data" code

main
Yasen Pramatarov 2024-10-11 10:58:08 +03:00
parent 1d706803b1
commit 6b4f344bfd
4 changed files with 84 additions and 9 deletions

View File

@ -210,6 +210,12 @@ class Agent {
$_SESSION["agent{$agent_id}_cache_time"] = ''; $_SESSION["agent{$agent_id}_cache_time"] = '';
} }
// get latest stored jilo agents data
public function getLatestData($platform_id, $agent_type, $metric_type) {
// retrieves data already stored in db from another function (or the jilo-server to-be)
}
} }
?> ?>

View File

@ -4,15 +4,15 @@
$graph[0]['data0'] = [ $graph[0]['data0'] = [
['date' => '2024-10-06', 'value' => 10], ['date' => '2024-10-06', 'value' => 10],
['date' => '2024-10-07', 'value' => 20], ['date' => '2024-10-07', 'value' => 20],
['date' => '2024-10-08', 'value' => 15], ['date' => '2024-10-10', 'value' => 15],
['date' => '2024-10-09', 'value' => 25], ['date' => '2024-10-11', 'value' => 25],
]; ];
$graph[0]['data1'] = [ $graph[0]['data1'] = [
['date' => '2024-10-06', 'value' => 12], ['date' => '2024-10-06', 'value' => 12],
['date' => '2024-10-07', 'value' => 23], ['date' => '2024-10-07', 'value' => 23],
['date' => '2024-10-08', 'value' => 11], ['date' => '2024-10-10', 'value' => 11],
['date' => '2024-10-09', 'value' => 27], ['date' => '2024-10-11', 'value' => 27],
]; ];
$graph[0]['graph_name'] = 'conferences'; $graph[0]['graph_name'] = 'conferences';
@ -23,15 +23,15 @@ $graph[0]['graph_data1_label'] = 'Conferences from Jitsi API (Jilo Agents)';
$graph[1]['data0'] = [ $graph[1]['data0'] = [
['date' => '2024-10-06', 'value' => 20], ['date' => '2024-10-06', 'value' => 20],
['date' => '2024-10-07', 'value' => 30], ['date' => '2024-10-07', 'value' => 30],
['date' => '2024-10-08', 'value' => 15], ['date' => '2024-10-10', 'value' => 15],
['date' => '2024-10-09', 'value' => 55], ['date' => '2024-10-11', 'value' => 55],
]; ];
$graph[1]['data1'] = [ $graph[1]['data1'] = [
['date' => '2024-10-06', 'value' => 22], ['date' => '2024-10-06', 'value' => 22],
['date' => '2024-10-07', 'value' => 33], ['date' => '2024-10-07', 'value' => 33],
['date' => '2024-10-08', 'value' => 11], ['date' => '2024-10-10', 'value' => 11],
['date' => '2024-10-09', 'value' => 57], ['date' => '2024-10-11', 'value' => 57],
]; ];
$graph[1]['graph_name'] = 'participants'; $graph[1]['graph_name'] = 'participants';

View File

@ -1,5 +1,29 @@
<?php <?php
include '../app/templates/latest.php'; require '../app/classes/agent.php';
$agentObject = new Agent($dbWeb);
$latestJvbConferences = $agentObject->getLatestData($platform_id, 'jvb', 'conferences');
$latestJvbParticipants = $agentObject->getLatestData($platform_id, 'jvb', 'participants');
$latestJicofoConferences = $agentObject->getLatestData($platform_id, 'jicofo', 'conferences');
$latestJicofoParticipants = $agentObject->getLatestData($platform_id, 'jicofo', 'participants');
$widget['records'] = array();
// prepare the widget
$widget['full'] = false;
$widget['name'] = 'LatestData';
$widget['title'] = 'Latest data from Jilo Agents';
$widget['collapsible'] = false;
$widget['collapsed'] = false;
$widget['filter'] = false;
if (!empty($latestJvbConferences) && !empty($latestJvbParticipants) && !empty($latestJicofoConferences) && !empty($latestJicofoParticipants)) {
$widget['full'] = true;
}
$widget['pagination'] = true;
include '../app/templates/latest-data.php';
?> ?>

View File

@ -0,0 +1,45 @@
<div class="row">
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
</div>
<div class="collapse show" id="collapse<?= htmlspecialchars($widget['name']) ?>">
<div class="mb-5">
<?php if ($widget['full'] === true) { ?>
<table class="table table-results table-striped table-hover table-bordered">
<thead class="thead-dark">
<tr>
<th scope="col"></th>
<?php foreach ($widget['records'] as $record) { ?>
<th scope="col"><?= htmlspecialchars($record['table_headers']) ?></th>
<?php } ?>
</tr>
</thead>
<tbody>
<tr>
<td>conferences</td>
<?php foreach ($widget['records'] as $record) { ?>
<td><?php if (!empty($record['conferences'])) { ?>
<a href="<?= htmlspecialchars($app_root) ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=conferences&from_time=<?= htmlspecialchars($record['from_time']) ?>&until_time=<?= htmlspecialchars($record['until_time']) ?>"><?= htmlspecialchars($record['conferences']) ?></a> <?php } else { ?>
0<?php } ?>
</td>
<?php } ?>
</tr>
<tr>
<td>participants</td>
<?php foreach ($widget['records'] as $record) { ?>
<td><?php if (!empty($record['participants'])) { ?>
<a href="<?= htmlspecialchars($app_root) ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=participants&from_time=<?= htmlspecialchars($record['from_time']) ?>&until_time=<?= htmlspecialchars($record['until_time']) ?>"><?= htmlspecialchars($record['participants']) ?></a> <?php } else { ?>
0<?php } ?>
</td>
<?php } ?>
</tr>
</tbody>
</table>
<?php } else { ?>
<p class="m-3">No records found.</p>
<?php } ?>
<hr /><p class="m-3">NB: This functionality is still under development.</p>
</div>
</div>
<!-- /widget "<?= htmlspecialchars($widget['name']) ?>" -->