Adds check period to agents config

main
Yasen Pramatarov 2024-10-24 12:11:35 +03:00
parent 8840efebdb
commit 2bf3a423f4
5 changed files with 30 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class Agent {
ja.agent_type_id, ja.agent_type_id,
ja.url, ja.url,
ja.secret_key, ja.secret_key,
ja.check_period,
jat.description AS agent_description, jat.description AS agent_description,
jat.endpoint AS agent_endpoint jat.endpoint AS agent_endpoint
FROM FROM
@ -48,6 +49,7 @@ class Agent {
ja.agent_type_id, ja.agent_type_id,
ja.url, ja.url,
ja.secret_key, ja.secret_key,
ja.check_period,
jat.description AS agent_description, jat.description AS agent_description,
jat.endpoint AS agent_endpoint jat.endpoint AS agent_endpoint
FROM FROM
@ -104,7 +106,8 @@ class Agent {
$sql = 'UPDATE jilo_agents SET $sql = 'UPDATE jilo_agents SET
agent_type_id = :agent_type_id, agent_type_id = :agent_type_id,
url = :url, url = :url,
secret_key = :secret_key secret_key = :secret_key,
check_period = :check_period
WHERE WHERE
id = :agent_id id = :agent_id
AND AND
@ -115,6 +118,7 @@ class Agent {
':agent_type_id' => $updatedAgent['agent_type_id'], ':agent_type_id' => $updatedAgent['agent_type_id'],
':url' => $updatedAgent['url'], ':url' => $updatedAgent['url'],
':secret_key' => $updatedAgent['secret_key'], ':secret_key' => $updatedAgent['secret_key'],
':check_period' => $updatedAgent['check_period'],
':agent_id' => $updatedAgent['id'], ':agent_id' => $updatedAgent['id'],
':platform_id' => $platform_id, ':platform_id' => $platform_id,
]); ]);

View File

@ -38,6 +38,9 @@ if (isset($_POST['url'])) {
if (isset($_POST['secret_key'])) { if (isset($_POST['secret_key'])) {
$secret_key = htmlspecialchars($_POST['secret_key']); $secret_key = htmlspecialchars($_POST['secret_key']);
} }
if (isset($_POST['check_period'])) {
$check_period = htmlspecialchars($_POST['check_period']);
}
// platforms // platforms
if (isset($_POST['name'])) { if (isset($_POST['name'])) {

View File

@ -61,6 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
'agent_type_id' => $type, 'agent_type_id' => $type,
'url' => $url, 'url' => $url,
'secret_key' => $secret_key, 'secret_key' => $secret_key,
'check_period' => $check_period,
]; ];
$result = $agentObject->editAgent($platform_id, $updatedAgent); $result = $agentObject->editAgent($platform_id, $updatedAgent);
if ($result === true) { if ($result === true) {

View File

@ -46,6 +46,17 @@
</div> </div>
</div> </div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="check_period" class="form-label">check period</label>
<span class="text-danger" style="margin-right: -12px;">*</span>
</div>
<div class="col-md-8">
<input class="form-control" type="text" name="check_period" value="<?= htmlspecialchars($agentDetails[0]['check_period']) ?>" required />
<p class="text-start"><small>period in minutes for the automatic agent check (0 disables it)</small></p>
</div>
</div>
<br /> <br />
<input type="hidden" name="agent" value="<?= htmlspecialchars($agentDetails[0]['id']) ?>" /> <input type="hidden" name="agent" value="<?= htmlspecialchars($agentDetails[0]['id']) ?>" />

View File

@ -97,6 +97,16 @@ echo "\n";
<?= htmlspecialchars($agent_array['url'].$agent_array['agent_endpoint']) ?> <?= htmlspecialchars($agent_array['url'].$agent_array['agent_endpoint']) ?>
</div> </div>
</div> </div>
<?php if (isset($agent_array['check_period']) && $agent_array['check_period'] !== 0) { ?>
<div class="row mb-1" style="padding-left: 100px;">
<div class="col-md-4 text-end">
check period:
</div>
<div class="border col-md-8 text-start">
<?= htmlspecialchars($agent_array['check_period']) ?>
</div>
</div>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>