mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 18:28:55 +00:00
Merge pull request #146 from wazuh/3.0-dev-agents-prev-fix
Fixes on agents preview tab
This commit is contained in:
commit
4007c0db80
@ -21,9 +21,24 @@ app.controller('agentsPreviewController', function ($scope,$rootScope, Notifier,
|
|||||||
tmpUrl2 = `/api/wazuh-elastic/top/manager/${appState.getClusterInfo().manager}/agent.id`;
|
tmpUrl2 = `/api/wazuh-elastic/top/manager/${appState.getClusterInfo().manager}/agent.id`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.applyFilters = filter => {
|
||||||
|
$scope.agents.filters = [];
|
||||||
|
if(filter.includes('Unknown')){
|
||||||
|
$scope.agents.addFilter('status','Never connected');
|
||||||
|
} else {
|
||||||
|
const platform = filter.split(' - ')[0];
|
||||||
|
const version = filter.split(' - ')[1];
|
||||||
|
$scope.agents.addMultipleFilters([
|
||||||
|
{ name: 'os.platform', value: platform },
|
||||||
|
{ name: 'os.version', value: version }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve os list
|
// Retrieve os list
|
||||||
const retrieveList = () => {
|
const retrieveList = agents => {
|
||||||
for(let agent of $scope.agents.items){
|
for(let agent of agents){
|
||||||
|
|
||||||
if('os' in agent && 'name' in agent.os){
|
if('os' in agent && 'name' in agent.os){
|
||||||
let exists = $scope.osPlatforms.filter((e) => e.name === agent.os.name && e.platform === agent.os.platform && e.version === agent.os.version);
|
let exists = $scope.osPlatforms.filter((e) => e.name === agent.os.name && e.platform === agent.os.platform && e.version === agent.os.version);
|
||||||
if(!exists.length){
|
if(!exists.length){
|
||||||
@ -42,19 +57,18 @@ app.controller('agentsPreviewController', function ($scope,$rootScope, Notifier,
|
|||||||
$scope.agents.nextPage(''),
|
$scope.agents.nextPage(''),
|
||||||
apiReq.request('GET', '/agents/summary', { }),
|
apiReq.request('GET', '/agents/summary', { }),
|
||||||
genericReq.request('GET', tmpUrl),
|
genericReq.request('GET', tmpUrl),
|
||||||
apiReq.request('GET', '/agents', { sort:'-date_add', limit:1 })
|
apiReq.request('GET', '/agents', { sort:'-date_add', limit:9999999 })
|
||||||
])
|
])
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
||||||
// Next page
|
|
||||||
retrieveList();
|
|
||||||
|
|
||||||
// Agents summary
|
// Agents summary
|
||||||
if(parseInt(data[1].data.data['Never connected']) > 0){
|
if(parseInt(data[1].data.data['Never connected']) > 0){
|
||||||
$scope.osPlatforms.push({
|
$scope.osPlatforms.push({
|
||||||
name: 'Unknown',
|
name: 'Unknown',
|
||||||
platform: 'Unknown',
|
platform: 'Unknown',
|
||||||
version: 'Unknown'
|
version: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$scope.agentsCountActive = data[1].data.data.Active;
|
$scope.agentsCountActive = data[1].data.data.Active;
|
||||||
@ -82,7 +96,9 @@ app.controller('agentsPreviewController', function ($scope,$rootScope, Notifier,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Last agent
|
// Last agent
|
||||||
$scope.lastAgent = data[3].data.data.items[0]
|
$scope.lastAgent = data[3].data.data.items[0];
|
||||||
|
|
||||||
|
retrieveList(data[3].data.data.items);
|
||||||
|
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
|
@ -311,6 +311,12 @@ let app = require('ui/modules').get('app/wazuh', []).controller('settingsControl
|
|||||||
case 'wrong_credentials':
|
case 'wrong_credentials':
|
||||||
text = 'Wrong Wazuh API credentials, please check them and try again';
|
text = 'Wrong Wazuh API credentials, please check them and try again';
|
||||||
break;
|
break;
|
||||||
|
case 'invalid_url':
|
||||||
|
text = 'Wrong Wazuh API url, please check it and try again';
|
||||||
|
break;
|
||||||
|
case 'invalid_port':
|
||||||
|
text = 'Wrong Wazuh API port, please check it and try again';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
text = `Unexpected error. ${error.message}`;
|
text = `Unexpected error. ${error.message}`;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,14 @@ app.factory('DataHandler', function ($q, apiReq) {
|
|||||||
return this.search();
|
return this.search();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Only used by agents preview, don't use for any thing more //
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
addMultipleFilters (arrayOfFilters) {
|
||||||
|
this.filters = [...arrayOfFilters];
|
||||||
|
return this.search();
|
||||||
|
}
|
||||||
|
|
||||||
removeFilter (filterName, search) {
|
removeFilter (filterName, search) {
|
||||||
if(search) this.filters = this.filters.filter(filter => filterName !== filter.name && filter.value !== search);
|
if(search) this.filters = this.filters.filter(filter => filterName !== filter.name && filter.value !== search);
|
||||||
else this.filters = this.filters.filter(filter => filterName !== filter.name);
|
else this.filters = this.filters.filter(filter => filterName !== filter.name);
|
||||||
|
@ -32,11 +32,15 @@ require('ui/modules').get('app/wazuh', [])
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if(error.status && error.status === -1){
|
if(error.data && error.data.message && error.data.message.includes('ENOTFOUND')) {
|
||||||
|
defered.reject({data: 'invalid_url'});
|
||||||
|
} else if(error.data && error.data.message && error.data.message.includes('ECONNREFUSED')) {
|
||||||
|
defered.reject({data: 'invalid_port'});
|
||||||
|
} else if(error.status && error.status === -1){
|
||||||
defered.reject({data: 'request_timeout_checkapi'});
|
defered.reject({data: 'request_timeout_checkapi'});
|
||||||
} else if (error.data && error.data.message && error.data.message === 'wrong_credentials') {
|
} else if (error.data && error.data.message && error.data.message === 'wrong_credentials') {
|
||||||
defered.reject({data: 'wrong_credentials'});
|
defered.reject({data: 'wrong_credentials'});
|
||||||
}else if (error.error) {
|
} else if (error.error) {
|
||||||
defered.reject(error);
|
defered.reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -53,10 +53,10 @@
|
|||||||
</md-input-container>
|
</md-input-container>
|
||||||
|
|
||||||
<md-input-container flex="20" class="md-block md-whiteframe-z1">
|
<md-input-container flex="20" class="md-block md-whiteframe-z1">
|
||||||
<md-select id="eventBox" ng-model="osPlatform" ng-change="agents.addFilter('os.platform', osPlatform)" aria-label="Filter by operative system">
|
<md-select id="eventBox" ng-model="osPlatform" ng-change="applyFilters(osPlatform)" aria-label="Filter by operative system">
|
||||||
<md-option value="all">All OS platforms</md-option>
|
<md-option value="all">All OS platforms</md-option>
|
||||||
<md-option ng-repeat='platform in osPlatforms' value="{{platform.platform}}">
|
<md-option ng-repeat='platform in osPlatforms' value="{{platform.platform}} - {{platform.version}}">
|
||||||
{{platform.name}}
|
{{platform.name}} {{platform.version}}
|
||||||
</md-option>
|
</md-option>
|
||||||
</md-select>
|
</md-select>
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<span flex="25">{{agent.name || 'Unknown'}}</span>
|
<span flex="25">{{agent.name || 'Unknown'}}</span>
|
||||||
<span flex="10">{{agent.ip || 'Unknown'}}</span>
|
<span flex="10">{{agent.ip || 'Unknown'}}</span>
|
||||||
<span flex="15">{{agent.status || 'Unknown'}}</span>
|
<span flex="15">{{agent.status || 'Unknown'}}</span>
|
||||||
<span flex="15">{{agent.os.platform || 'Unknown'}}</span>
|
<span flex="15">{{agent.os.name || 'Unknown'}}</span>
|
||||||
<span flex="15">{{agent.os.version || 'Unknown'}}</span>
|
<span flex="15">{{agent.os.version || 'Unknown'}}</span>
|
||||||
<span flex="15">{{agent.version || 'Unknown'}}</span>
|
<span flex="15">{{agent.version || 'Unknown'}}</span>
|
||||||
</md-list-item>
|
</md-list-item>
|
||||||
|
Loading…
Reference in New Issue
Block a user