Fixes agent types selection on add/edit
parent
d0ef53a176
commit
1468843cac
|
@ -40,6 +40,17 @@ class Agent {
|
|||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// get agent types
|
||||
public function getAgentTypes() {
|
||||
$sql = 'SELECT *
|
||||
FROM jilo_agent_types
|
||||
ORDER BY id';
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->execute();
|
||||
|
||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// add new agent
|
||||
public function addAgent($platform_id, $newAgent) {
|
||||
try {
|
||||
|
|
|
@ -20,7 +20,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
// new agent adding
|
||||
if (isset($_POST['new']) && isset($_POST['item']) && $_POST['new'] === 'true' && $_POST['item'] === 'agent') {
|
||||
$newAgent = [
|
||||
'type_id' => 1,
|
||||
'type_id' => $_POST['type'],
|
||||
'url' => $_POST['url'],
|
||||
'secret_key' => $_POST['secret_key'],
|
||||
];
|
||||
|
@ -58,7 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
} elseif (isset($_POST['agent'])) {
|
||||
$updatedAgent = [
|
||||
'id' => $agent,
|
||||
'agent_type_id' => 1,
|
||||
'agent_type_id' => $_POST['type'],
|
||||
'url' => $_POST['url'],
|
||||
'secret_key' => $_POST['secret_key'],
|
||||
];
|
||||
|
@ -126,6 +126,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
default:
|
||||
switch ($action) {
|
||||
case 'add-agent':
|
||||
$jilo_agent_types = $agentObject->getAgentTypes();
|
||||
include '../app/templates/config-add-agent.php';
|
||||
break;
|
||||
case 'add':
|
||||
|
@ -134,6 +135,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
case 'edit':
|
||||
if (isset($_GET['agent'])) {
|
||||
$agentDetails = $agentObject->getAgentDetails($platform_id, $agent);
|
||||
$jilo_agent_types = $agentObject->getAgentTypes();
|
||||
include '../app/templates/config-edit-agent.php';
|
||||
} else {
|
||||
include '../app/templates/config-edit-platform.php';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="card text-center w-50 mx-auto">
|
||||
<p class="h4 card-header">Add new Jilo Agent to Jitsi platform "<strong><?= htmlspecialchars($platformDetails[0]['name']) ?></strong>"</p>
|
||||
<div class="card-body">
|
||||
<!--p class="card-text">add new platform:</p-->
|
||||
<!--p class="card-text">add new agent:</p-->
|
||||
<form method="POST" action="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config">
|
||||
|
||||
<div class="row mb-3">
|
||||
|
@ -12,7 +12,14 @@
|
|||
<span class="text-danger" style="margin-right: -12px;">*</span>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" type="text" name="type" value="" required autofocus />
|
||||
<select class="form-control" type="text" name="type" id="agent_type_id" required>
|
||||
<option></option>
|
||||
<?php foreach ($jilo_agent_types as $agent_type) { ?>
|
||||
<option value="<?= $agent_type['id']?>">
|
||||
<?= $agent_type['description'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p class="text-start"><small>type of agent (meet, jvb, jibri, all)</small></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,14 @@
|
|||
<span class="text-danger" style="margin-right: -12px;">*</span>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" type="text" name="type_id" value="<?= htmlspecialchars($agentDetails[0]['agent_type_id'])?>" required autofocus />
|
||||
<select class="form-control" type="text" name="type" id="agent_type_id" required>
|
||||
<option></option>
|
||||
<?php foreach ($jilo_agent_types as $agent_type) { ?>
|
||||
<option value="<?= $agent_type['id']?>" <?php if ($agentDetails[0]['agent_type_id'] === $agent_type['id']) echo 'selected'; ?>>
|
||||
<?= $agent_type['description'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p class="text-start"><small>type of agent (meet, jvb, jibri, all)</small></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue