mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
Modularized syscheck and rootcheck validations
This commit is contained in:
parent
277789c95a
commit
24312e183a
@ -152,47 +152,20 @@ app.controller('agentsController', function ($timeout, $scope, $location, $rootS
|
||||
};
|
||||
|
||||
// Agent data
|
||||
$scope.getAgentStatusClass = (agentStatus) => agentStatus === "Active" ? "teal" : "red";
|
||||
$scope.getAgentStatusClass = agentStatus => agentStatus === "Active" ? "teal" : "red";
|
||||
|
||||
$scope.formatAgentStatus = (agentStatus) => {
|
||||
$scope.formatAgentStatus = agentStatus => {
|
||||
return ['Active','Disconnected'].includes(agentStatus) ? agentStatus : 'Never connected';
|
||||
};
|
||||
|
||||
const validateRootCheck = () => {
|
||||
$scope.agent.rootcheck.duration = 'Unknown';
|
||||
if ($scope.agent.rootcheck.end && $scope.agent.rootcheck.start) {
|
||||
$scope.agent.rootcheck.duration = ((new Date($scope.agent.rootcheck.end) - new Date($scope.agent.rootcheck.start))/1000)/60;
|
||||
$scope.agent.rootcheck.duration = Math.round($scope.agent.rootcheck.duration * 100) / 100;
|
||||
|
||||
if($scope.agent.rootcheck.duration <= 0){
|
||||
$scope.agent.rootcheck.inProgress = true;
|
||||
}
|
||||
} else {
|
||||
if (!$scope.agent.rootcheck.end) {
|
||||
$scope.agent.rootcheck.end = 'Unknown';
|
||||
}
|
||||
if (!$scope.agent.rootcheck.start){
|
||||
$scope.agent.rootcheck.start = 'Unknown';
|
||||
}
|
||||
}
|
||||
const result = commonData.validateRange($scope.agent.rootcheck)
|
||||
$scope.agent.rootcheck = result;
|
||||
}
|
||||
|
||||
const validateSysCheck = () => {
|
||||
$scope.agent.syscheck.duration = 'Unknown';
|
||||
if ($scope.agent.syscheck.end && $scope.agent.syscheck.start) {
|
||||
$scope.agent.syscheck.duration = ((new Date($scope.agent.syscheck.end) - new Date($scope.agent.syscheck.start))/1000)/60;
|
||||
$scope.agent.syscheck.duration = Math.round($scope.agent.syscheck.duration * 100) / 100;
|
||||
if($scope.agent.syscheck.duration <= 0){
|
||||
$scope.agent.syscheck.inProgress = true;
|
||||
}
|
||||
} else {
|
||||
if (!$scope.agent.syscheck.end) {
|
||||
$scope.agent.syscheck.end = 'Unknown';
|
||||
}
|
||||
if (!$scope.agent.syscheck.start){
|
||||
$scope.agent.syscheck.start = 'Unknown';
|
||||
}
|
||||
}
|
||||
const result = commonData.validateRange($scope.agent.syscheck)
|
||||
$scope.agent.syscheck = result;
|
||||
}
|
||||
|
||||
$scope.getAgent = async (newAgentId,fromAutocomplete) => {
|
||||
|
@ -83,6 +83,24 @@ app.service('commonData', function ($rootScope, $timeout, genericReq, appState,
|
||||
} catch(error) {
|
||||
errorHandler.handle('An error occurred while creating custom filters for visualizations',agent ? 'Agents' : 'Overview',true);
|
||||
}
|
||||
},
|
||||
validateRange: data => {
|
||||
const result = {
|
||||
duration : 'Unknown',
|
||||
inProgress: false,
|
||||
end : data.end || 'Unknown',
|
||||
start : data.start || 'Unknown'
|
||||
}
|
||||
|
||||
if(data.end && data.start) {
|
||||
result.duration = ((new Date(data.end) - new Date(data.start))/1000)/60;
|
||||
result.duration = Math.round(result.duration * 100) / 100;
|
||||
if(result.duration <= 0){
|
||||
result.inProgress = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user