Fixes the agents configuration.

main
Yasen Pramatarov 2024-09-18 11:32:24 +03:00
parent be0cd48c01
commit 4786b0d1f7
4 changed files with 83 additions and 27 deletions

View File

@ -94,6 +94,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
break; break;
default: default:
if ($userObject->hasRight($user_id, 'view config file')) { if ($userObject->hasRight($user_id, 'view config file')) {
require '../app/classes/agent.php';
$agentObject = new Agent($dbWeb);
include '../app/templates/config-list.php'; include '../app/templates/config-list.php';
} else { } else {
include '../app/templates/unauthorized.php'; include '../app/templates/unauthorized.php';

View File

@ -11,24 +11,37 @@ echo "\n";
?> ?>
<hr /> <hr />
<p class="card-text">platforms configuration &nbsp;<a class="btn btn-secondary" style="padding: 0px;" href="<?= $app_root ?>?page=config&action=add">add</a></p> <p class="card-text">platforms configuration &nbsp;<a class="btn btn-secondary" style="padding: 0px;" href="<?= $app_root ?>?page=config&action=add">add new</a></p>
<?php foreach ($platformsAll as $platform_array) { ?> <?php foreach ($platformsAll as $platform_array) {
$agents = $agentObject->getAgentDetails($platform_array['id']);
?>
<div class="row mb-3" style="padding-left: 0px;"> <div class="row mb-3" style="padding-left: 0px;">
<div class="border bg-light" style="padding-left: 50px; padding-bottom: 20px; padding-top: 20px;"> <div class="border bg-light" style="padding-left: 50px; padding-bottom: 0px; padding-top: 0px;">
<div class="row mb-1" style="padding-left: 0px;"> <a style="text-decoration: none;" data-toggle="collapse" href="#collapsePlatform<?= $platform_array['id'] ?>" role="button" aria-expanded="true" aria-controls="collapsePlatform<?= $platform_array['id'] ?>">
<div class="col-md-4 text-end"> <div class="border bg-white text-start mb-3 rounded mt-3" data-toggle="tooltip" data-placement="bottom" title="configuration for platform <?= $platform_array['id'] ?>">
platform id <?= $platform_array['id'] ?>: <i class="fas fa-wrench"></i>
<small>platform <?= $platform_array['id'] ?> (<?= $platform_array['name'] ?>)</small>
</div> </div>
</a>
<div class="collapse show" id="collapsePlatform<?= $platform_array['id'] ?>">
<div class="row mb-1" style="padding-left: 0px;">
<div class="col-md-8 text-start"> <div class="col-md-8 text-start">
<a class="btn btn-secondary" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_array['id']) ?>&page=config&action=edit">edit</a>
<div class="row mb-1">
<div class="col-md-8 text-start">
<a class="btn btn-secondary" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_array['id']) ?>&page=config&action=edit">edit platform</a>
<?php if (count($platformsAll) <= 1) { ?> <?php if (count($platformsAll) <= 1) { ?>
<span class="btn btn-light" style="padding: 2px;" href="#" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="can't delete the last platform">delete</span> <span class="btn btn-light" style="padding: 2px;" href="#" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="can't delete the last platform">delete platform</span>
<?php } else { ?> <?php } else { ?>
<a class="btn btn-danger" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_array['id'])?>&page=config&action=delete">delete</a> <a class="btn btn-danger" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_array['id'])?>&page=config&action=delete">delete platform</a>
<?php } ?> <?php } ?>
</div> </div>
</div>
</div>
<div style="padding-left: 100px; padding-bottom: 20px;"> <div style="padding-left: 100px; padding-bottom: 20px;">
<?php foreach ($platform_array as $key => $value) { <?php foreach ($platform_array as $key => $value) {
if ($key === 'id') continue; if ($key === 'id') continue;
@ -42,16 +55,51 @@ echo "\n";
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
</div>
</div>
<hr />
<p class="card-text">jilo agents on platform <?= $platform_array['id'] ?> (<?= $platform_array['name'] ?>)
<br />
total <?= count($agents) ?> <?= count($agents) === 1 ? 'jilo agent' : 'jilo agents' ?>&nbsp;
<a class="btn btn-secondary" style="padding: 0px;" href="<?= $app_root ?>?page=config&platform=action=add">
add new
</a>
</p>
<?php foreach ($agents as $agent_array) { ?>
<div class="row mb-3" style="padding-left: 0px;">
<div class="border rounded bg-light" style="padding-left: 50px; padding-bottom: 20px; padding-top: 20px;">
<div class="row mb-1" style="padding-left: 0px;">
<div class="col-md-4 text-end"> <div class="col-md-4 text-end">
configured jilo agents: agent id <?= $agent_array['id'] ?>:
</div> </div>
<div class="col-md-8 text-start"> <div class="col-md-8 text-start">
0 <a class="btn btn-secondary" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($agent_array['platform_id']) ?>&page=agents&agent=<?= htmlspecialchars($agent_array['id']) ?>&action=edit">edit agent</a>
<a class="btn btn-secondary" style="padding: 2px; margin-left: 10px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_array['id']) ?>&page=agents">configure</a> <a class="btn btn-danger" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($agent_array['platform_id'])?>&page=agents&agent=<?= htmlspecialchars($agent_array['id']) ?>&action=delete">delete agent</a>
</div> </div>
<div style="padding-left: 100px; padding-bottom: 20px;">
<?php foreach ($agent_array as $key => $value) {
if ($key === 'id') continue;
?>
<div class="row mb-1" style="padding-left: 100px;">
<div class="col-md-4 text-end">
<?= $key ?>:
</div>
<div class="border col-md-8 text-start">
<?= $value ?>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,5 @@
INSERT INTO jilo_agent_types VALUES(1,'jvb','/jvb');
INSERT INTO jilo_agent_types VALUES(2,'jicofo','/jicofo');
INSERT INTO jilo_agent_types VALUES(3,'prosody','/prosody');
INSERT INTO jilo_agent_types VALUES(4,'nginx','/nginx');
INSERT INTO jilo_agent_types VALUES(5,'jibri','/jibri');

View File

@ -34,10 +34,11 @@ CREATE TABLE platforms (
CREATE TABLE jilo_agents ( CREATE TABLE jilo_agents (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
platform_id INTEGER NOT NULL, platform_id INTEGER NOT NULL,
type_id INTEGER NOT NULL, agent_type_id INTEGER NOT NULL,
url TEXT NOT NULL, url TEXT NOT NULL,
secret_key TEXT, secret_key TEXT,
FOREIGN KEY (platform_id) REFERENCES platforms(id) FOREIGN KEY (platform_id) REFERENCES platforms(id),
FOREIGN KEY (agent_type_id) REFERENCES jilo_agent_types(id)
); );
CREATE TABLE jilo_agent_types ( CREATE TABLE jilo_agent_types (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,