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
} else {
$updatedAgent = [
'id' => $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";
}
}
// } else {
// $updatedAgent = [
// 'id' => $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";
// }
//
// }
header("Location: $app_root?platform=$platform_id&page=agents");
exit();

View File

@ -54,6 +54,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$platform = $_POST['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
} else {
$platform = $_POST['platform'];