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

View File

@ -29,7 +29,7 @@
<div class="button-group" role="toolbar"></div>
</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;">
<md-card flex>
<md-card-content>