Fixes host editing
parent
5d715e4aac
commit
e084a04305
|
@ -65,26 +65,20 @@ class Host {
|
||||||
}
|
}
|
||||||
|
|
||||||
// edit an existing host
|
// edit an existing host
|
||||||
public function editAgent($platform_id, $updatedAgent) {
|
public function editHost($platform_id, $updatedHost) {
|
||||||
try {
|
try {
|
||||||
$sql = 'UPDATE jilo_agents SET
|
$sql = 'UPDATE hosts SET
|
||||||
agent_type_id = :agent_type_id,
|
address = :address,
|
||||||
url = :url,
|
port = :port,
|
||||||
secret_key = :secret_key,
|
name = :name,
|
||||||
check_period = :check_period
|
|
||||||
WHERE
|
WHERE
|
||||||
id = :agent_id
|
id = :id';
|
||||||
AND
|
|
||||||
platform_id = :platform_id';
|
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
$query->execute([
|
$query->execute([
|
||||||
':agent_type_id' => $updatedAgent['agent_type_id'],
|
':address' => $updatedHost['address'],
|
||||||
':url' => $updatedAgent['url'],
|
':port' => $updatedHost['port'],
|
||||||
':secret_key' => $updatedAgent['secret_key'],
|
':name' => $updatedHost['name'],
|
||||||
':check_period' => $updatedAgent['check_period'],
|
|
||||||
':agent_id' => $updatedAgent['id'],
|
|
||||||
':platform_id' => $platform_id,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -82,6 +82,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$platform = $_POST['platform'];
|
$platform = $_POST['platform'];
|
||||||
$platformObject->deletePlatform($platform);
|
$platformObject->deletePlatform($platform);
|
||||||
|
|
||||||
|
// an update to an existing host
|
||||||
|
} elseif (isset($_POST['host'])) {
|
||||||
|
$updatedHost = [
|
||||||
|
'id' => $host,
|
||||||
|
'address' => $address,
|
||||||
|
'port' => $port,
|
||||||
|
'name' => $name,
|
||||||
|
];
|
||||||
|
$result = $hostObject->editHost($platform_id, $updatedHost);
|
||||||
|
if ($result === true) {
|
||||||
|
$_SESSION['notice'] = "Host id \"{$_REQUEST['host']}\" edited.";
|
||||||
|
} else {
|
||||||
|
$_SESSION['error'] = "Editing the host failed. Error: $result";
|
||||||
|
}
|
||||||
|
|
||||||
// an update to an existing agent
|
// an update to an existing agent
|
||||||
} elseif (isset($_POST['agent'])) {
|
} elseif (isset($_POST['agent'])) {
|
||||||
$updatedAgent = [
|
$updatedAgent = [
|
||||||
|
|
Loading…
Reference in New Issue