Fixes agent config

main
Yasen Pramatarov 2024-09-22 12:26:19 +03:00
parent 72b1442b77
commit 6d07744ab7
2 changed files with 30 additions and 15 deletions

View File

@ -33,21 +33,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// } // }
// an update to an existing agent // an update to an existing agent
} else { // } else {
$updatedAgent = [ // $updatedAgent = [
'id' => $agent, // 'id' => $agent,
'type_id' => 1, // 'type_id' => 1,
'url' => $_POST['url'], // 'url' => $_POST['url'],
'secret_key' => $_POST['secret_key'], // 'secret_key' => $_POST['secret_key'],
]; // ];
$result = $agentObject->editAgent($platform_id, $updatedAgent); // $result = $agentObject->editAgent($platform_id, $updatedAgent);
if ($result === true) { // if ($result === true) {
$_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited."; // $_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited.";
} else { // } else {
$_SESSION['error'] = "Editing the agent failed. Error: $result"; // $_SESSION['error'] = "Editing the agent failed. Error: $result";
} // }
//
} // }
header("Location: $app_root?platform=$platform_id&page=agents"); header("Location: $app_root?platform=$platform_id&page=agents");
exit(); exit();

View File

@ -54,6 +54,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$platform = $_POST['platform']; $platform = $_POST['platform'];
$platformObject->deletePlatform($platform); $platformObject->deletePlatform($platform);
// an update to an existing agent
} elseif (isset($_POST['agent'])) {
$updatedAgent = [
'id' => $agent,
'agent_type_id' => 1,
'url' => $_POST['url'],
'secret_key' => $_POST['secret_key'],
];
$result = $agentObject->editAgent($platform_id, $updatedAgent);
if ($result === true) {
$_SESSION['notice'] = "Agent id \"{$_REQUEST['agent']}\" edited.";
} else {
$_SESSION['error'] = "Editing the agent failed. Error: $result";
}
// an update to an existing platform // an update to an existing platform
} else { } else {
$platform = $_POST['platform']; $platform = $_POST['platform'];