mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 18:05:20 +00:00
Autocomplete bars now are working as search bars too
This commit is contained in:
parent
1497d81cfa
commit
67b7e62284
@ -7,6 +7,8 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
$scope.load = true;
|
||||
$scope.$parent.state.setRulesetState('rules');
|
||||
|
||||
$scope.search = undefined;
|
||||
|
||||
$scope.rules = [];
|
||||
|
||||
$scope.statusFilter = 'enabled';
|
||||
@ -18,6 +20,7 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
var _file;
|
||||
var _group;
|
||||
var _pci;
|
||||
var _search;
|
||||
var objectsArray = [];
|
||||
|
||||
//Print Error
|
||||
@ -47,18 +50,10 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
} else {
|
||||
$scope._sortOrder = false;
|
||||
$scope._sort = field;
|
||||
DataFactory.filters.set(objectsArray['/rules'], 'filter-sort', '-'+field);
|
||||
DataFactory.filters.set(objectsArray['/rules'], 'filter-sort', '-' + field);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.fileSearchFilter = function (search) {
|
||||
if (search) {
|
||||
DataFactory.filters.set(objectsArray['/rules'], 'search', search);
|
||||
} else {
|
||||
DataFactory.filters.unset(objectsArray['/rules'], 'search');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.rulesApplyFilter = function (filterObj) {
|
||||
if (!filterObj) {
|
||||
return null;
|
||||
@ -72,6 +67,9 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
} else if (filterObj.type == 'pci') {
|
||||
_pci = filterObj.value;
|
||||
DataFactory.filters.set(objectsArray['/rules'], 'pci', filterObj.value);
|
||||
} else if (filterObj.type == 'search') {
|
||||
_search = filterObj.value;
|
||||
DataFactory.filters.set(objectsArray['/rules'], 'search', filterObj.value);
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,6 +80,8 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
return _group && _group != null;
|
||||
} else if (type == 'pci') {
|
||||
return _pci && _pci != null;
|
||||
} else if (type == 'search') {
|
||||
return _search && _search != null;
|
||||
}
|
||||
};
|
||||
|
||||
@ -101,6 +101,11 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
$scope._filter = undefined;
|
||||
$scope.search = undefined;
|
||||
DataFactory.filters.unset(objectsArray['/rules'], 'pci');
|
||||
} else if (type == 'search') {
|
||||
_search = null;
|
||||
$scope._filter = undefined;
|
||||
$scope.search = undefined;
|
||||
DataFactory.filters.unset(objectsArray['/rules'], 'search');
|
||||
}
|
||||
};
|
||||
|
||||
@ -111,17 +116,20 @@ app.controller('rulesController', function ($scope, $q, DataFactory, $mdToast) {
|
||||
return _group;
|
||||
} else if (type == 'pci') {
|
||||
return _pci;
|
||||
} else if (type == 'search') {
|
||||
return _search;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.filtersSearch = function (search) {
|
||||
var defered = $q.defer();
|
||||
var promise = defered.promise;
|
||||
//$scope.load = true;
|
||||
var result = [];
|
||||
|
||||
if (!search) {
|
||||
search = undefined;
|
||||
} else {
|
||||
result.push({ 'type': 'search', 'value': search });
|
||||
}
|
||||
|
||||
DataFactory.getAndClean('get', '/rules/files', { 'offset': 0, 'limit': 5, 'search': search })
|
||||
@ -244,8 +252,9 @@ app.controller('decodersController', function ($scope, $q, $sce, DataFactory, $m
|
||||
$scope.decoders = [];
|
||||
|
||||
$scope.typeFilter = 'all';
|
||||
var _file;
|
||||
var _search;
|
||||
|
||||
var _lastFile = undefined;
|
||||
var objectsArray = [];
|
||||
|
||||
//Print Error
|
||||
@ -298,26 +307,10 @@ app.controller('decodersController', function ($scope, $q, $sce, DataFactory, $m
|
||||
return $sce.trustAsHtml(coloredString);
|
||||
};
|
||||
|
||||
$scope.decoderSearchFilter = function (search) {
|
||||
if (!search) {
|
||||
DataFactory.filters.unset(objectsArray['/decoders'], 'search');
|
||||
} else {
|
||||
DataFactory.filters.set(objectsArray['/decoders'], 'search', search);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.decoderFileFilter = function (file) {
|
||||
if (!file) {
|
||||
DataFactory.filters.unset(objectsArray['/decoders'], 'file');
|
||||
$scope._filter = undefined;
|
||||
$scope.search = undefined;
|
||||
} else {
|
||||
_lastFile = file;
|
||||
DataFactory.filters.set(objectsArray['/decoders'], 'file', file);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.decoderTypeFilter = function (type) {
|
||||
$scope.typeFilter = type;
|
||||
$scope.decodersUnset('file');
|
||||
$scope.decodersUnset('search');
|
||||
DataFactory.clean(objectsArray['/decoders']);
|
||||
DataFactory.initialize('get', (type == 'parents') ? '/decoders/parents' : '/decoders', {}, 100, 0)
|
||||
.then(function (data) {
|
||||
@ -327,23 +320,71 @@ app.controller('decodersController', function ($scope, $q, $sce, DataFactory, $m
|
||||
$scope.decoders = data.data.items;
|
||||
DataFactory.filters.register(objectsArray['/decoders'], 'search', 'string');
|
||||
(type != 'parents') ? DataFactory.filters.register(objectsArray['/decoders'], 'file', 'string') : null;
|
||||
$scope.decoderSearchFilter($scope.decoderSearch);
|
||||
(type != 'parents') ? $scope.decoderFileFilter(_lastFile) : null;
|
||||
}, printError);
|
||||
}, printError);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fileSearch = function (search) {
|
||||
$scope.decodersApplyFilter = function (filterObj) {
|
||||
if (!filterObj) {
|
||||
return null;
|
||||
}
|
||||
if (filterObj.type == 'file') {
|
||||
_file = filterObj.value.split('/').slice(-1)[0];
|
||||
DataFactory.filters.set(objectsArray['/decoders'], 'file', filterObj.value.split('/').slice(-1)[0]);
|
||||
} else if (filterObj.type == 'search') {
|
||||
_search = filterObj.value;
|
||||
DataFactory.filters.set(objectsArray['/decoders'], 'search', filterObj.value);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.decodersHasFilter = function (type) {
|
||||
if (type == 'file') {
|
||||
return _file && _file != null;
|
||||
} else if (type == 'search') {
|
||||
return _search && _search != null;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.decodersUnset = function (type) {
|
||||
if (type == 'file') {
|
||||
_file = null;
|
||||
DataFactory.filters.unset(objectsArray['/decoders'], 'file');
|
||||
$scope._filter = undefined;
|
||||
$scope.search = undefined;
|
||||
} else if (type == 'search') {
|
||||
_search = null;
|
||||
$scope._search = undefined;
|
||||
DataFactory.filters.unset(objectsArray['/decoders'], 'search');
|
||||
$scope._filter = undefined;
|
||||
$scope.search = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.decodersGetFilter = function (type) {
|
||||
if (type == 'file') {
|
||||
return _file;
|
||||
} else if (type == 'search') {
|
||||
return _search;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.filtersSearch = function (search) {
|
||||
var defered = $q.defer();
|
||||
var promise = defered.promise;
|
||||
var result = [];
|
||||
|
||||
if (!search) {
|
||||
search = undefined;
|
||||
} else {
|
||||
result.push({ 'type': 'search', 'value': search });
|
||||
}
|
||||
|
||||
DataFactory.getAndClean('get', '/decoders/files', { 'offset': 0, 'limit': 100, 'search': search })
|
||||
DataFactory.getAndClean('get', '/decoders/files', { 'offset': 0, 'limit': 14, 'search': search })
|
||||
.then(function (data) {
|
||||
defered.resolve(data.data.items);
|
||||
angular.forEach(data.data.items, function (value) {
|
||||
result.push({ 'type': 'file', 'value': value });
|
||||
});
|
||||
defered.resolve(result);
|
||||
}, function (data) {
|
||||
printError(data);
|
||||
defered.reject();
|
||||
|
@ -4,12 +4,15 @@
|
||||
<div flex id="content" layout="row" layout-align="space-between center">
|
||||
|
||||
<span layout="row" style="padding-left: 0px;" flex layout-align="space-between center">
|
||||
<md-autocomplete ng-disabled="typeFilter != 'all'" flex md-no-cache="true" md-selected-item="_file" md-selected-item-change="decoderFileFilter(_file.split('/').slice(-1)[0])" md-search-text="$parent.search"
|
||||
md-items="item in fileSearch($parent.search)" md-item-text="item" md-min-length="0" md-no-asterisk="true" md-menu-class="autocomplete-custom-agents-bar"
|
||||
<md-autocomplete ng-hide="$parent.typeFilter != 'all'" flex md-no-cache="true" md-selected-item="_filter" md-selected-item-change="decodersApplyFilter(_filter)" md-search-text="$parent.search"
|
||||
md-items="item in filtersSearch($parent.search)" md-item-text="item.value" md-min-length="0" md-no-asterisk="true" md-menu-class="autocomplete-custom-agents-bar"
|
||||
placeholder="Search file">
|
||||
<md-item-template>
|
||||
<span class="item-title">
|
||||
<span><strong md-highlight-text="search" md-highlight-flags="i"> {{item}} </strong></span>
|
||||
<span><strong md-highlight-text="search" md-highlight-flags="i"> {{item.value}} </strong></span>
|
||||
</span>
|
||||
<span class="item-metadata">
|
||||
<span class="item-metastat"> {{item.type}} </span>
|
||||
</span>
|
||||
</md-item-template>
|
||||
<md-not-found>
|
||||
@ -26,6 +29,15 @@
|
||||
</md-input-container>
|
||||
</div>
|
||||
|
||||
<md-chips readonly="true" ng-show="decodersHasFilter('search') || decodersHasFilter('file')">
|
||||
<md-chip md-colors="::{background: 'primary-100', color: 'background-900'}" ng-click="decodersUnset('search')" ng-if="decodersHasFilter('search')">
|
||||
<span class="bold">Search: {{decodersGetFilter('search')}} <i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</md-chip>
|
||||
<md-chip md-colors="::{background: 'primary-100', color: 'background-900'}" ng-click="decodersUnset('file')" ng-if="decodersHasFilter('file');">
|
||||
<span class="bold">File: {{decodersGetFilter('file')}} <i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</md-chip>
|
||||
</md-chips>
|
||||
|
||||
<md-toolbar layout="row">
|
||||
<div class="md-toolbar-tools">
|
||||
<span flex="70">Name</span>
|
||||
|
@ -33,7 +33,10 @@
|
||||
|
||||
</div>
|
||||
|
||||
<md-chips readonly="true" ng-show="rulesHasFilter('file') || rulesHasFilter('group') || rulesHasFilter('pci')">
|
||||
<md-chips readonly="true" ng-show="rulesHasFilter('search') || rulesHasFilter('file') || rulesHasFilter('group') || rulesHasFilter('pci')">
|
||||
<md-chip md-colors="::{background: 'primary-100', color: 'background-900'}" ng-click="rulesUnset('search')" ng-if="rulesHasFilter('search')">
|
||||
<span class="bold">Search: {{rulesGetFilter('search')}} <i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</md-chip>
|
||||
<md-chip md-colors="::{background: 'primary-100', color: 'background-900'}" ng-click="rulesUnset('file')" ng-if="rulesHasFilter('file');">
|
||||
<span class="bold">File: {{rulesGetFilter('file')}} <i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</md-chip>
|
||||
|
Loading…
Reference in New Issue
Block a user