Skip to content

Commit

Permalink
Merge pull request #155 from wazuh/check-manager-fix
Browse files Browse the repository at this point in the history
Fixing check manager button
  • Loading branch information
havidarou authored Dec 22, 2017
2 parents 9aa9980 + 2595d4d commit bcb19c1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions public/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ let app = require('ui/modules').get('app/wazuh', []).controller('settingsControl

$scope.getCurrentAPIIndex();

console.log($scope.apiEntries[index]);

$scope.extensions.oscap = $scope.apiEntries[index]._source.extensions.oscap;
$scope.extensions.audit = $scope.apiEntries[index]._source.extensions.audit;
$scope.extensions.pci = $scope.apiEntries[index]._source.extensions.pci;
Expand Down Expand Up @@ -225,21 +223,29 @@ let app = require('ui/modules').get('app/wazuh', []).controller('settingsControl
$scope.checkManager = (item) => {
let index = $scope.apiEntries.indexOf(item);

let tmpData = {
'user': $scope.apiEntries[index]._source.api_user,
'password': $scope.apiEntries[index]._source.api_password,
'url': $scope.apiEntries[index]._source.url,
'port': $scope.apiEntries[index]._source.api_port,
'cluster_info': {},
'insecure': 'true',
'id': $scope.apiEntries[index]._id
};

testAPI.check_stored(item._id)
testAPI.check(tmpData)
.then(data => {

let tmpData = {};

tmpData.cluster_info = data.data.data.cluster_info;
tmpData.cluster_info = data.data;

let tmpUrl = `/api/wazuh-api/updateApiHostname/${$scope.apiEntries[index]._id}`;
genericReq.request('PUT', tmpUrl , { "cluster_info": tmpData.cluster_info })
.then(() => {
$scope.apiEntries[index]._source.cluster_info = tmpData.cluster_info;
});

if (tmpData.cluster_info.status == 'disabled')
if (tmpData.cluster_info.status === 'disabled')
appState.setCurrentAPI(JSON.stringify({name: tmpData.cluster_info.manager, id: $scope.apiEntries[index]._id }));
else
appState.setCurrentAPI(JSON.stringify({name: tmpData.cluster_info.cluster, id: $scope.apiEntries[index]._id }));
Expand Down

0 comments on commit bcb19c1

Please sign in to comment.