mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
Added column selector for wz-table
This commit is contained in:
parent
6060287ba5
commit
caed56867a
@ -26,7 +26,7 @@ import { checkGap } from './lib/check-gap';
|
||||
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzTable', function() {
|
||||
app.directive('wzTable', function () {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@ -52,6 +52,31 @@ app.directive('wzTable', function() {
|
||||
groupHandler,
|
||||
wazuhConfig
|
||||
) {
|
||||
$scope.showColumns = false;
|
||||
$scope.originalkeys = $scope.keys.map((key, idx) => ({ key, idx }));
|
||||
$scope.updateColumns = (key) => {
|
||||
const str = key.key.value || key.key;
|
||||
const cleanArray = $scope.keys.map(item => item.value || item);
|
||||
if (cleanArray.includes(str)) {
|
||||
const idx = cleanArray.indexOf(str);
|
||||
if (idx > -1) {
|
||||
$scope.keys.splice(idx, 1);
|
||||
}
|
||||
} else {
|
||||
const originalIdx = $scope.originalkeys.findIndex(item => (item.key.value || item.key) === (key.key.value || key.key));
|
||||
if (originalIdx >= 0) {
|
||||
$scope.keys.splice(originalIdx, 0, key.key);
|
||||
} else {
|
||||
$scope.keys.push(key.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.exists = (key) => {
|
||||
const str = key.key.value || key.key;
|
||||
for (const k of $scope.keys) if ((k.value || k) === str) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init variables
|
||||
*/
|
||||
@ -237,7 +262,7 @@ app.directive('wzTable', function() {
|
||||
$scope.prevPage = () => pagination.prevPage($scope);
|
||||
$scope.nextPage = async currentPage =>
|
||||
pagination.nextPage(currentPage, $scope, errorHandler, fetch);
|
||||
$scope.setPage = function() {
|
||||
$scope.setPage = function () {
|
||||
$scope.currentPage = this.n;
|
||||
$scope.nextPage(this.n);
|
||||
};
|
||||
|
@ -3,6 +3,18 @@
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div layout="row" ng-show="!error && !wazuh_table_loading && items.length">
|
||||
<span flex></span>
|
||||
<span class="wz-text-link" ng-click="showColumns = !showColumns" tooltip="Columns"><i class="fa fa-fw fa-gear"></i></span>
|
||||
</div>
|
||||
<div layout="row" layout-wrap ng-show="!error && !wazuh_table_loading && items.length" ng-if="showColumns">
|
||||
<span flex></span>
|
||||
<md-checkbox ng-repeat="key in originalkeys" ng-click="updateColumns(key)" ng-checked="exists(key)">
|
||||
{{ keyEquivalence[key.key.value ||
|
||||
key.key] }}
|
||||
</md-checkbox>
|
||||
</div>
|
||||
|
||||
<div layout="row" ng-show="!error && !wazuh_table_loading && items.length">
|
||||
<table class="table table-striped table-condensed table-hover" style="table-layout: fixed !important" id="wz_table">
|
||||
<thead class="wz-text-bold">
|
||||
|
Loading…
Reference in New Issue
Block a user