Adds check period to creating a new agent

main
Yasen Pramatarov 2024-10-25 12:19:54 +03:00
parent 2bf3a423f4
commit b3e3a78ed9
4 changed files with 16 additions and 3 deletions

View File

@ -81,9 +81,9 @@ class Agent {
public function addAgent($platform_id, $newAgent) {
try {
$sql = 'INSERT INTO jilo_agents
(platform_id, agent_type_id, url, secret_key)
(platform_id, agent_type_id, url, secret_key, check_period)
VALUES
(:platform_id, :agent_type_id, :url, :secret_key)';
(:platform_id, :agent_type_id, :url, :secret_key, :check_period)';
$query = $this->db->prepare($sql);
$query->execute([
@ -91,6 +91,7 @@ class Agent {
':agent_type_id' => $newAgent['type_id'],
':url' => $newAgent['url'],
':secret_key' => $newAgent['secret_key'],
':check_period' => $newAgent['check_period'],
]);
return true;

View File

@ -23,6 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
'type_id' => $type,
'url' => $url,
'secret_key' => $secret_key,
'check_period' => $check_period,
];
$result = $agentObject->addAgent($platform_id, $newAgent);
if ($result === true) {

View File

@ -46,6 +46,17 @@
</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="0" required />
<p class="text-start"><small>period in minutes for the automatic agent check (0 disables it)</small></p>
</div>
</div>
<input type="hidden" name="new" value="true" />
<input type="hidden" name="item" value="agent" />

View File

@ -103,7 +103,7 @@ echo "\n";
check period:
</div>
<div class="border col-md-8 text-start">
<?= htmlspecialchars($agent_array['check_period']) ?>
<?= htmlspecialchars($agent_array['check_period']) ?> minutes
</div>
</div>
<?php } ?>