Fetching agents summary

This commit is contained in:
Jesús Ángel 2018-07-26 12:43:19 +02:00
parent 0a3fc30d61
commit becb1fe682

View File

@ -154,13 +154,8 @@ function ($scope, $location, $rootScope, appState,
}
};
const loadConfiguration = async () => {
const getSummary = async () => {
try {
const configuration = wazuhConfig.getConfig();
$scope.wzMonitoringEnabled = !!configuration['wazuh.monitoring.enabled'];
if(!$scope.wzMonitoringEnabled){
const data = await apiReq.request('GET', '/agents/summary', { });
if(data && data.data && data.data.data){
@ -172,6 +167,20 @@ function ($scope, $location, $rootScope, appState,
} else {
throw new Error('Error fetching /agents/summary from Wazuh API');
}
return;
} catch (error) {
return Promise.reject(error);
}
}
const loadConfiguration = async () => {
try {
const configuration = wazuhConfig.getConfig();
$scope.wzMonitoringEnabled = !!configuration['wazuh.monitoring.enabled'];
if(!$scope.wzMonitoringEnabled){
await getSummary();
}
return;
@ -184,6 +193,7 @@ function ($scope, $location, $rootScope, appState,
const init = async () => {
try {
await Promise.all([
loadPciAndGDPR(),
loadConfiguration()
@ -191,13 +201,19 @@ function ($scope, $location, $rootScope, appState,
$scope.switchTab($scope.tab,true);
if($scope.tab && $scope.tab === 'welcome'){
await getSummary();
}
if(!$scope.$$phase) $scope.$digest()
return;
} catch (error) {
errorHandler.handle(error, 'Overview (init)')
return;
}
}
};
init();