Adds component events search page
parent
5c9756b696
commit
195d1c5069
|
@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Added front page widgets
|
||||
- Added demo installation on https://work.lindeas.com/jilo-web-demo/
|
||||
- Added participant search page
|
||||
- Added component events search page
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
class Component {
|
||||
private $db;
|
||||
private $queries;
|
||||
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
$this->queries = include('queries.php');
|
||||
}
|
||||
|
||||
|
||||
// list of component events
|
||||
public function jitsiComponents($jitsi_component, $component_id, $from_time, $until_time) {
|
||||
|
||||
// time period drill-down
|
||||
// FIXME make it similar to the bash version
|
||||
if (empty($from_time)) {
|
||||
$from_time = '0000-01-01';
|
||||
}
|
||||
if (empty($until_time)) {
|
||||
$until_time = '9999-12-31';
|
||||
}
|
||||
|
||||
// this is needed for compatibility with the bash version, so we use '%s' placeholders
|
||||
$from_time = htmlspecialchars(strip_tags($from_time));
|
||||
$until_time = htmlspecialchars(strip_tags($until_time));
|
||||
$sql = $this->queries['jitsi_components'];
|
||||
$sql = sprintf($sql, $jitsi_component, $component_id, $from_time, $until_time);
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->execute();
|
||||
|
||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -4,14 +4,14 @@ class Conference {
|
|||
private $db;
|
||||
private $queries;
|
||||
|
||||
public $jitsi_component;
|
||||
public $start;
|
||||
public $end;
|
||||
public $conference_id;
|
||||
public $conference_name;
|
||||
public $participants;
|
||||
public $name_count;
|
||||
public $conference_host;
|
||||
// public $jitsi_component;
|
||||
// public $start;
|
||||
// public $end;
|
||||
// public $conference_id;
|
||||
// public $conference_name;
|
||||
// public $participants;
|
||||
// public $name_count;
|
||||
// public $conference_host;
|
||||
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
|
|
|
@ -4,14 +4,14 @@ class Participant {
|
|||
private $db;
|
||||
private $queries;
|
||||
|
||||
public $jitsi_component;
|
||||
public $start;
|
||||
public $end;
|
||||
public $participant_id;
|
||||
public $conference_name;
|
||||
public $participants;
|
||||
public $name_count;
|
||||
public $conference_host;
|
||||
// public $jitsi_component;
|
||||
// public $start;
|
||||
// public $end;
|
||||
// public $participant_id;
|
||||
// public $conference_name;
|
||||
// public $participants;
|
||||
// public $name_count;
|
||||
// public $conference_host;
|
||||
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
|
|
|
@ -294,6 +294,21 @@ ORDER BY
|
|||
pe.time;",
|
||||
|
||||
|
||||
// list of jitsi component events
|
||||
'jitsi_components' => "
|
||||
SELECT jitsi_component, loglevel, time, component_id, event_type, event_param
|
||||
FROM
|
||||
jitsi_components
|
||||
WHERE
|
||||
jitsi_component = %s
|
||||
AND
|
||||
component_id = %s
|
||||
AND
|
||||
(time >= '%s 00:00:00' AND time <= '%s 23:59:59')
|
||||
ORDER BY
|
||||
time;",
|
||||
|
||||
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
|
@ -27,6 +27,7 @@ $allowed_urls = [
|
|||
'config',
|
||||
'conferences',
|
||||
'participants',
|
||||
'components',
|
||||
];
|
||||
|
||||
// cnfig file
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
require_once 'classes/database.php';
|
||||
require 'classes/component.php';
|
||||
|
||||
// FIXME move thi sto a special function
|
||||
$time_range_specified = false;
|
||||
if (!isset($_REQUEST['from_time']) || (isset($_REQUEST['from_time']) && $_REQUEST['from_time'] == '')) {
|
||||
$from_time = '0000-01-01';
|
||||
} else {
|
||||
$from_time = $_REQUEST['from_time'];
|
||||
$time_range_specified = true;
|
||||
}
|
||||
if (!isset($_REQUEST['until_time']) || (isset($_REQUEST['until_time']) && $_REQUEST['until_time'] == '')) {
|
||||
$until_time = '9999-12-31';
|
||||
} else {
|
||||
$until_time = $_REQUEST['until_time'];
|
||||
$time_range_specified = true;
|
||||
}
|
||||
|
||||
// jitsi component events list
|
||||
// we use $_REQUEST, so that both links and forms work
|
||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||
$jitsi_component = "'" . $_REQUEST['name'] . "'";
|
||||
$component_id = 'component_id';
|
||||
} elseif (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
|
||||
$component_id = "'" . $_REQUEST['id'] . "'";
|
||||
$jitsi_component = 'jitsi_component';
|
||||
} else {
|
||||
// we need the variables to use them later in sql for columnname = columnname
|
||||
$jitsi_component = 'jitsi_component';
|
||||
$component_id = 'component_id';
|
||||
}
|
||||
|
||||
// connect to database
|
||||
try {
|
||||
$db = new Database($config['jilo_database']);
|
||||
} catch (Exception $e) {
|
||||
$error = 'Error: ' . $e->getMessage();
|
||||
include 'templates/message.php';
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Component events listings
|
||||
//
|
||||
|
||||
|
||||
// list of all component events (default)
|
||||
//if ($jitsi_component) {
|
||||
try {
|
||||
$component = new Component($db);
|
||||
|
||||
// prepare the result
|
||||
$search = $component->jitsiComponents($jitsi_component, $component_id, $from_time, $until_time);
|
||||
|
||||
if (!empty($search)) {
|
||||
$components = array();
|
||||
$components['records'] = array();
|
||||
|
||||
foreach ($search as $item) {
|
||||
extract($item);
|
||||
$component_record = array(
|
||||
// assign title to the field in the array record
|
||||
'component' => $jitsi_component,
|
||||
'loglevel' => $loglevel,
|
||||
'time' => $time,
|
||||
'component ID' => $component_id,
|
||||
'event' => $event_type,
|
||||
'param' => $event_param,
|
||||
);
|
||||
// populate the result array
|
||||
array_push($components['records'], $component_record);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = 'Error: ' . $e->getMessage();
|
||||
include 'templates/message.php';
|
||||
exit();
|
||||
}
|
||||
|
||||
// display the result
|
||||
|
||||
// format the header message
|
||||
echo "<div class=\"results-header\">\n";
|
||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||
echo "<div class=\"results-message\">Jitsi events for component <strong>" . $_REQUEST['name'] . "</strong>";
|
||||
} elseif (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
|
||||
echo "<div class=\"results-message\">Jitsi events for component ID <br /><strong>" . $_REQUEST['id'] . "</strong>";
|
||||
} else {
|
||||
echo "<div class=\"results-message\">Jitsi events for <strong>all components</strong>";
|
||||
}
|
||||
if ($time_range_specified) {
|
||||
echo "<br />for the time period <strong>$from_time - $until_time</strong>";
|
||||
}
|
||||
echo "</div>\n\n";
|
||||
|
||||
// filters - time selection and sorting dropdowns
|
||||
include 'templates/results-filter.php';
|
||||
|
||||
echo "</div>\n\n";
|
||||
|
||||
// results table
|
||||
echo "<div class=\"results\">\n";
|
||||
|
||||
if (!empty($components['records'])) {
|
||||
|
||||
echo "\t<table>\n";
|
||||
echo "\t\t<tr>\n";
|
||||
|
||||
// table headers
|
||||
foreach (array_keys($components['records'][0]) as $header) {
|
||||
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
|
||||
}
|
||||
echo "\t\t</tr>\n";
|
||||
|
||||
//table rows
|
||||
foreach ($components['records'] as $row) {
|
||||
echo "\t\t<tr>\n";
|
||||
// sometimes $column is empty, we make it '' then
|
||||
foreach ($row as $key => $column) {
|
||||
if ($key === 'component ID') {
|
||||
echo "\t\t\t<td><a href=\"$app_root?page=components&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
|
||||
} elseif ($key === 'component') {
|
||||
echo "\t\t\t<td><a href=\"$app_root?page=components&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
|
||||
} else {
|
||||
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
|
||||
}
|
||||
}
|
||||
echo "\t\t</tr>\n";
|
||||
}
|
||||
|
||||
echo "\t</table>\n";
|
||||
|
||||
} else {
|
||||
echo '<p>No matching Jitsi component events found.</p>';
|
||||
}
|
||||
echo "\n</div>\n";
|
||||
|
||||
//}
|
||||
|
||||
?>
|
|
@ -6,6 +6,7 @@
|
|||
<li><a href="?page=config">config</a></li>
|
||||
<li><a href="?page=conferences">conferences</a></li>
|
||||
<li><a href="?page=participants">participants</a></li>
|
||||
<li><a href="?page=components">components</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Reference in New Issue