Fixed PCI labels between tabs

This commit is contained in:
Pedro Sanchez 2017-01-26 12:28:01 -08:00
parent c523f9d51d
commit e89e1df170
2 changed files with 29 additions and 21 deletions

View File

@ -45,27 +45,24 @@ require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', functio
function injectPciIcon(){ function injectPciIcon(){
// Get all filters on filter bar // Get all filters on filter bar
var filters = document.querySelectorAll(".filter-bar .filter"); var filters = document.querySelectorAll(".mainSearchBar .filter-bar .filter");
// Analyze each filter // Analyze each filter
filters.forEach(function(item) { filters.forEach(function(item) {
if(angular.element(item).data('pci') != "1"){ if(angular.element(item).data('pci') != "1"){
var filterLabel = item.querySelectorAll(".filter-description"); var filter = item.querySelector(".filter-description");
filterLabel.forEach(function(item) { if(filter.children[0].innerText == "rule.pci_dss:"){
if(item.children[0].innerText == "rule.pci_dss:"){ // Preparing and adding new element to filter actions icons
// Preparing and adding new element to filter actions icons var pciLink = angular.element('<a class="action" ng-click=\'displayPCI('+filter.children[1].innerText+')\'><img src="/plugins/wazuh/img/icon_pci.png"></a>');
var pciLink = angular.element('<a class="action" ng-click=\'displayPCI('+item.children[1].innerText+')\'><img src="/plugins/wazuh/img/icon_pci.png"></a>'); // Append the new element
// Append the new element angular.element(pciLink).appendTo(filter.nextElementSibling);
angular.element(pciLink).appendTo(item.nextElementSibling); // Compile element to enable ng click
// Compile element to enable ng click $compile(angular.element(filter.nextElementSibling).contents())($scope);
$compile(angular.element(item.nextElementSibling).contents())($scope); // Setup min width when adding new icon
// Setup min width when adding new icon angular.element(filter.parentNode).css("min-width","calc(6*(1.414em + 13px))");
angular.element(item.parentNode).css("min-width","calc(6*(1.414em + 13px))"); angular.element(filter.parentNode).attr('data-pci','1');
angular.element(item.parentNode).attr('data-pci','1'); var cleanRequirement = filter.children[1].innerText.replace(/^"(.*)"$/, '$1');
var cleanRequirement = item.children[1].innerText.replace(/^"(.*)"$/, '$1'); $scope.displayPCI(cleanRequirement);
//console.log(cleanRequirement); }
$scope.displayPCI(cleanRequirement);
}
});
} }
}); });
return; return;
@ -89,6 +86,7 @@ require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', functio
{ {
$rootScope.$broadcast('updateQuery',$scope.stateQuery); $rootScope.$broadcast('updateQuery',$scope.stateQuery);
}; };
$scope.queryFilter = Private(FilterBarQueryFilterProvider); $scope.queryFilter = Private(FilterBarQueryFilterProvider);
// Listen for filter changes // Listen for filter changes
@ -104,14 +102,24 @@ require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', functio
if($rootScope.visCounter == 0){ if($rootScope.visCounter == 0){
$timeout( $timeout(
function() { function() {
$rootScope.$broadcast('fetchVisualization');
injectPciIcon(); injectPciIcon();
var watchFilterBar = document.querySelectorAll(".filter-bar")[0];
$rootScope.$broadcast('fetchVisualization');
}, 0); }, 0);
} }
}); });
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
injectPciIcon();
});
});
var config = { childList: true };
// Listen for destroy // Listen for destroy
$scope.$on('$destroy', visCounterWatch); $scope.$on('$destroy', visCounterWatch);

View File

@ -29,7 +29,7 @@
<div class="button-group" role="toolbar"></div> <div class="button-group" role="toolbar"></div>
</navbar> </navbar>
<filter-bar state="$state"></filter-bar> <filter-bar state="$state" class="mainSearchBar"></filter-bar>
<div layout="row" layout-align="center stretch" id="pciRequirementBox" style="display: none;"> <div layout="row" layout-align="center stretch" id="pciRequirementBox" style="display: none;">
<md-card flex> <md-card flex>
<md-card-content> <md-card-content>