mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
New functionality to add agents
This commit is contained in:
parent
d2b50eb09e
commit
e96c156531
@ -29,8 +29,7 @@ app.factory('Agents', function($http, DataFactory) {
|
||||
return Agents;
|
||||
});
|
||||
|
||||
app.controller('agentsPreviewController', function ($scope, DataFactory, Notifier, errlog, genericReq, Agents) {
|
||||
|
||||
app.controller('agentsPreviewController', function ($scope, DataFactory, Notifier, errlog, genericReq, Agents, apiReq) {
|
||||
$scope.load = true;
|
||||
$scope.agents = [];
|
||||
$scope._status = 'all';
|
||||
@ -39,6 +38,12 @@ app.controller('agentsPreviewController', function ($scope, DataFactory, Notifie
|
||||
$scope.mostActiveAgent = {"name" : "", "id" : ""};
|
||||
$scope.osPlatforms = [];
|
||||
$scope.osVersions = new Set();
|
||||
$scope.isAddingAgent = false;
|
||||
$scope.newAgent = {
|
||||
'name': '', 'ip': ''
|
||||
};
|
||||
|
||||
|
||||
const notify = new Notifier({location: 'Agents - Preview'});
|
||||
|
||||
var objectsArray = [];
|
||||
@ -115,7 +120,44 @@ app.controller('agentsPreviewController', function ($scope, DataFactory, Notifie
|
||||
|
||||
};
|
||||
|
||||
$scope.addNewAgent = function (){
|
||||
$scope.isAddingAgent = !$scope.isAddingAgent;
|
||||
}
|
||||
|
||||
$scope.saveNewAgent = function (){
|
||||
if($scope.newAgent.name != '') {
|
||||
if(confirm("Do you want to add the agent?")){
|
||||
var requestData = {
|
||||
'name': $scope.newAgent.name,
|
||||
'ip': $scope.newAgent.ip == '' ? 'any' : $scope.newAgent.ip
|
||||
}
|
||||
apiReq.request('POST', '/agents', requestData)
|
||||
.then(function (data) {
|
||||
if(data.error=='0'){
|
||||
notify.info('The agent was added successfully.');
|
||||
apiReq.request('GET', '/agents/' + data.data + '/key', {})
|
||||
.then(function(data) {
|
||||
prompt('',data.data);
|
||||
load();
|
||||
});
|
||||
}
|
||||
else{
|
||||
notify.error('There was an error adding the new agent.');
|
||||
}
|
||||
}, printError);
|
||||
}
|
||||
}
|
||||
else{
|
||||
notify.error('The agent name is mandatory.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var load = function () {
|
||||
$scope.isAddingAgent = false;
|
||||
$scope.newAgent = {
|
||||
'name': '', 'ip': ''
|
||||
};
|
||||
DataFactory.initialize('get', '/agents', {}, 30, 0)
|
||||
.then(function (data) {
|
||||
objectsArray['/agents'] = data;
|
||||
|
@ -153,7 +153,7 @@ app.controller('settingsController', function ($scope, $http, testConnection, ap
|
||||
testConnection.check(tmpData).then(function (data) {
|
||||
tmpData.manager = data;
|
||||
var index = $scope.apiEntries.indexOf(item);
|
||||
genericReq.request('PUT', '/api/wazuh-api/updateApiHostname/' + $scope.apiEntries[index]._id).then(function (data) {
|
||||
genericReq.request('PUT', '/api/wazuh-api/updateApiHostname/' + $scope.apiEntries[index]._id, {"manager":tmpData.manager}).then(function (data) {
|
||||
$scope.apiEntries[index]._source.manager = tmpData.manager;
|
||||
});
|
||||
notify.info("Connection success");
|
||||
|
@ -3,8 +3,50 @@ body{
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.done-icon {
|
||||
color: #3CD26D
|
||||
}
|
||||
|
||||
.new-agent-data {
|
||||
width:80%
|
||||
}
|
||||
|
||||
.rotate,
|
||||
.rotateCounterwise {
|
||||
-webkit-transition: 300ms ease all;
|
||||
-moz-transition: 300ms ease all;
|
||||
-o-transition: 300ms ease all;
|
||||
transition: 300ms ease all;
|
||||
}
|
||||
|
||||
.rotate {
|
||||
-moz-transform: rotate(45deg); /* FF3.5/3.6 */
|
||||
-o-transform: rotate(45deg); /* Opera 10.5 */
|
||||
-webkit-transform: rotate(45deg); /* Saf3.1+ */
|
||||
transform: rotate(45deg); /* Newer browsers (incl IE9) */
|
||||
}
|
||||
|
||||
.rotateCounterwise {
|
||||
-moz-transform: rotate(0deg); /* FF3.5/3.6 */
|
||||
-o-transform: rotate(0deg); /* Opera 10.5 */
|
||||
-webkit-transform: rotate(0deg); /* Saf3.1+ */
|
||||
transform: rotate(0deg); /* Newer browsers (incl IE9) */
|
||||
}
|
||||
|
||||
.new-agent-button{
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.rotate md-icon{
|
||||
color: #D2453C;
|
||||
}
|
||||
|
||||
.rotateCounterwise md-icon{
|
||||
color: #3CD26D;
|
||||
}
|
||||
|
||||
.md-input-margin {
|
||||
margin:18px 20px 0 0
|
||||
margin: 18px 20px 0 0
|
||||
}
|
||||
|
||||
.no-legend visualize-legend{
|
||||
|
@ -16,7 +16,7 @@ require('ui/modules').get('app/wazuh', [])
|
||||
'details': details
|
||||
}
|
||||
|
||||
$http.post('/api/wazuh-api/errlog', requestData)
|
||||
$http.post(chrome.addBasePath('/api/wazuh-api/errlog'), requestData)
|
||||
.success(function () {
|
||||
defered.resolve();
|
||||
}).error(function (data) {
|
||||
|
@ -5,8 +5,7 @@ require('ui/modules').get('app/wazuh', [])
|
||||
check_stored: function () {
|
||||
var defered = $q.defer();
|
||||
var promise = defered.promise;
|
||||
|
||||
$http.get("/api/wazuh-api/check")
|
||||
$http.get(chrome.addBasePath("/api/wazuh-api/check"))
|
||||
.success(function (data) {
|
||||
if (data.error) {
|
||||
defered.reject(data);
|
||||
@ -22,7 +21,7 @@ require('ui/modules').get('app/wazuh', [])
|
||||
check: function (data) {
|
||||
var defered = $q.defer();
|
||||
var promise = defered.promise;
|
||||
$http.post("/api/wazuh-api/check", data)
|
||||
$http.post(chrome.addBasePath("/api/wazuh-api/check"), data)
|
||||
.success(function (data) {
|
||||
if (data.error) {
|
||||
defered.reject(data);
|
||||
|
@ -85,7 +85,18 @@
|
||||
</md-input-container>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="start stretch">
|
||||
<div layout="row" class="top-bulk-action" layout-align="center center">
|
||||
<md-card ng-click="addNewAgent()" class="md-input-margin new-agent-button" layout="column">
|
||||
<div ng-animate="{enter: 'rotate', leave: 'rotateCounterwise'}" ng-class="{true: 'rotate', false: 'rotateCounterwise'}[isAddingAgent]"><md-icon md-font-library="material-icons">add</md-icon></div>
|
||||
</md-card>
|
||||
</div>
|
||||
<div ng-show="isAddingAgent" layout="row" class="top-bulk-action" layout-align="center center">
|
||||
<md-card ng-click="saveNewAgent()" class="md-input-margin new-agent-button" layout="column">
|
||||
<md-icon class="done-icon" md-font-library="material-icons">done</md-icon>
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<md-toolbar layout="row">
|
||||
<div class="md-toolbar-tools">
|
||||
@ -105,18 +116,32 @@
|
||||
</md-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
<md-list ng-repeat='agent in agents.items' class="agents-preview-table" ng-click="applyAgent(agent)">
|
||||
<md-list ng-show="isAddingAgent" ng-animate="{enter: 'show-new-agent', leave: 'hide-new-agent'}" ng-class="{true: 'show-new-agent', false: 'hide-new-agent'}[isAddingAgent]" class="agents-preview-table">
|
||||
<md-list-item>
|
||||
<span flex="10">{{agent.id}}</span>
|
||||
<span flex="25">{{agent.name}}</span>
|
||||
<span flex="20">{{agent.ip}}</span>
|
||||
<span flex="10">{{agent.status}}</span>
|
||||
<span flex="10"> <span ng-class="getAgentStatusClass(agent.status)" class="round status"></span></span>
|
||||
<span flex="15">{{agent.os.platform}}</span>
|
||||
<span flex="10">{{agent.os.version}}</span>
|
||||
<span flex="10"></span>
|
||||
<span flex="25"><input ng-model="newAgent.name" class="new-agent-data"></input></span>
|
||||
<span flex="20"><input ng-model="newAgent.ip" class="new-agent-data"></input></span>
|
||||
<span flex="10"></span>
|
||||
<span flex="10"></span>
|
||||
<span flex="15"></span>
|
||||
<span flex="10"></span>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
<md-divider></md-divider>
|
||||
<div flex layout="column" layout-align="space-between stretch">
|
||||
<div layout="row" layout-align="start stretch">
|
||||
<div layout="row" class="sideNavBox" layout-align="center center">
|
||||
<md-card ng-click="addNewAgent()" class="md-input-margin new-agent-button" layout="column">
|
||||
<div ng-animate="{enter: 'rotate', leave: 'rotateCounterwise'}" ng-class="{true: 'rotate', false: 'rotateCounterwise'}[isAddingAgent]"><md-icon md-font-library="material-icons">add</md-icon></div>
|
||||
</md-card>
|
||||
</div>
|
||||
<div ng-show="isAddingAgent" layout="row" class="sideNavBox" layout-align="center center">
|
||||
<md-card ng-click="saveNewAgent()" class="md-input-margin new-agent-button" layout="column">
|
||||
<md-icon class="done-icon" md-font-library="material-icons">done</md-icon>
|
||||
</md-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<md-content><md-progress-linear class="md-accent" md-mode="indeterminate" ng-show="agents.busy"></md-progress-linear></md-content>
|
||||
</md-content>
|
||||
|
Loading…
Reference in New Issue
Block a user