Compare commits
No commits in common. "06bf414f41e7292cf0d55e1359451b07dd26d30b" and "9562a7d0bb9cd2107fa31466cae5ad4c9c4444e3" have entirely different histories.
06bf414f41
...
9562a7d0bb
|
@ -1,32 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Platform
|
|
||||||
*
|
|
||||||
* Handles platform management in the database, including retrieving, adding, editing, and deleting platforms.
|
|
||||||
*/
|
|
||||||
class Platform {
|
class Platform {
|
||||||
/**
|
|
||||||
* @var PDO|null $db The database connection instance.
|
|
||||||
*/
|
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
/**
|
|
||||||
* Platform constructor.
|
|
||||||
*
|
|
||||||
* @param Database $database The database connection object.
|
|
||||||
*/
|
|
||||||
public function __construct($database) {
|
public function __construct($database) {
|
||||||
$this->db = $database->getConnection();
|
$this->db = $database->getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// get details of a specified platform ID (or all)
|
||||||
* Retrieve details of a specific platform or all platforms.
|
|
||||||
*
|
|
||||||
* @param string $platform_id The ID of the platform to retrieve details for (optional).
|
|
||||||
*
|
|
||||||
* @return array An associative array containing platform details.
|
|
||||||
*/
|
|
||||||
public function getPlatformDetails($platform_id = '') {
|
public function getPlatformDetails($platform_id = '') {
|
||||||
$sql = 'SELECT * FROM platforms';
|
$sql = 'SELECT * FROM platforms';
|
||||||
if ($platform_id !== '') {
|
if ($platform_id !== '') {
|
||||||
|
@ -42,16 +23,7 @@ class Platform {
|
||||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// add new platform
|
||||||
* Add a new platform to the database.
|
|
||||||
*
|
|
||||||
* @param array $newPlatform An associative array containing the details of the new platform:
|
|
||||||
* - `name` (string): The name of the platform.
|
|
||||||
* - `jitsi_url` (string): The URL for the Jitsi integration.
|
|
||||||
* - `jilo_database` (string): The database name for Jilo integration.
|
|
||||||
*
|
|
||||||
* @return bool|string True if the platform was added successfully, or an error message on failure.
|
|
||||||
*/
|
|
||||||
public function addPlatform($newPlatform) {
|
public function addPlatform($newPlatform) {
|
||||||
try {
|
try {
|
||||||
$sql = 'INSERT INTO platforms
|
$sql = 'INSERT INTO platforms
|
||||||
|
@ -73,17 +45,7 @@ class Platform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// edit an existing platform
|
||||||
* Edit an existing platform in the database.
|
|
||||||
*
|
|
||||||
* @param int $platform_id The ID of the platform to update.
|
|
||||||
* @param array $updatedPlatform An associative array containing the updated platform details:
|
|
||||||
* - `name` (string): The updated name of the platform.
|
|
||||||
* - `jitsi_url` (string): The updated Jitsi URL.
|
|
||||||
* - `jilo_database` (string): The updated Jilo database name.
|
|
||||||
*
|
|
||||||
* @return bool|string True if the platform was updated successfully, or an error message on failure.
|
|
||||||
*/
|
|
||||||
public function editPlatform($platform_id, $updatedPlatform) {
|
public function editPlatform($platform_id, $updatedPlatform) {
|
||||||
try {
|
try {
|
||||||
$sql = 'UPDATE platforms SET
|
$sql = 'UPDATE platforms SET
|
||||||
|
@ -108,13 +70,7 @@ class Platform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// delete a platform
|
||||||
* Delete a platform from the database.
|
|
||||||
*
|
|
||||||
* @param int $platform_id The ID of the platform to delete.
|
|
||||||
*
|
|
||||||
* @return bool|string True if the platform was deleted successfully, or an error message on failure.
|
|
||||||
*/
|
|
||||||
public function deletePlatform($platform_id) {
|
public function deletePlatform($platform_id) {
|
||||||
try {
|
try {
|
||||||
$sql = 'DELETE FROM platforms
|
$sql = 'DELETE FROM platforms
|
||||||
|
|
|
@ -1,24 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
// Jilo components status checks
|
||||||
* Jilo Components Status Checks
|
//
|
||||||
*
|
|
||||||
* This page ("status") checks the status of various Jilo platform components
|
|
||||||
* by fetching data from agents and determining their availability.
|
|
||||||
* It generates output for each platform and agent.
|
|
||||||
*/
|
|
||||||
|
|
||||||
require '../app/classes/agent.php';
|
require '../app/classes/agent.php';
|
||||||
$agentObject = new Agent($dbWeb);
|
$agentObject = new Agent($dbWeb);
|
||||||
|
|
||||||
include '../app/templates/status-server.php';
|
include '../app/templates/status-server.php';
|
||||||
|
|
||||||
// loop through all platforms to check their agents
|
|
||||||
foreach ($platformsAll as $platform) {
|
foreach ($platformsAll as $platform) {
|
||||||
|
|
||||||
include '../app/templates/status-platform.php';
|
include '../app/templates/status-platform.php';
|
||||||
|
|
||||||
// fetch agent details for the current platform
|
|
||||||
$agentDetails = $agentObject->getAgentDetails($platform['id']);
|
$agentDetails = $agentObject->getAgentDetails($platform['id']);
|
||||||
foreach ($agentDetails as $agent) {
|
foreach ($agentDetails as $agent) {
|
||||||
$agent_url = parse_url($agent['url']);
|
$agent_url = parse_url($agent['url']);
|
||||||
|
@ -30,7 +23,6 @@ foreach ($platformsAll as $platform) {
|
||||||
$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
|
|
||||||
if (json_last_error() === JSON_ERROR_NONE) {
|
if (json_last_error() === JSON_ERROR_NONE) {
|
||||||
$agent_availability = '<span class="text-warning">unknown</span>';
|
$agent_availability = '<span class="text-warning">unknown</span>';
|
||||||
foreach ($agent_data as $key => $value) {
|
foreach ($agent_data as $key => $value) {
|
||||||
|
|
Loading…
Reference in New Issue