mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Reloading the API hostname when it has changed.
This commit is contained in:
parent
05808fb803
commit
fe46172d09
@ -152,7 +152,12 @@ app.controller('settingsController', function ($scope, $http, testConnection, ap
|
||||
};
|
||||
|
||||
testConnection.check(tmpData).then(function (data) {
|
||||
notify.info("Connection success");
|
||||
tmpData.manager = data;
|
||||
var index = $scope.apiEntries.indexOf(item);
|
||||
$http.put("/api/wazuh-api/updateApiHostname/" + $scope.apiEntries[index]._id, tmpData).success(function (data) {
|
||||
$scope.apiEntries[index]._source.manager = tmpData.manager;
|
||||
});
|
||||
notify.info("Connection success");
|
||||
}, printError);
|
||||
};
|
||||
|
||||
|
@ -344,6 +344,17 @@ module.exports = function (server, options) {
|
||||
reply({ 'statusCode': 500, 'error': 8, 'message': 'Could not save data in elasticsearch' }).code(500);
|
||||
});
|
||||
};
|
||||
|
||||
//Handlers - Update API Hostname
|
||||
|
||||
var updateApiHostname = function (req,reply) {
|
||||
elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id:req.params.id, body: {doc: {"manager": req.payload.manager}} }).then(
|
||||
function () {
|
||||
reply({ 'statusCode': 200, 'message': 'ok' });
|
||||
}, function (error) {
|
||||
reply({ 'statusCode': 500, 'error': 8, 'message': 'Could not save data in elasticsearch' }).code(500);
|
||||
});
|
||||
};
|
||||
|
||||
//Handlers - Get API Settings
|
||||
|
||||
@ -535,4 +546,15 @@ module.exports = function (server, options) {
|
||||
handler: fetchAgents
|
||||
});
|
||||
|
||||
/*
|
||||
* PUT /api/wazuh-api/updateApiHostname/apiId
|
||||
* Update the API hostname
|
||||
*
|
||||
**/
|
||||
server.route({
|
||||
method: 'PUT',
|
||||
path: '/api/wazuh-api/updateApiHostname/{id}',
|
||||
handler: updateApiHostname
|
||||
});
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user