diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-07-03 01:29:55 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-07-03 01:29:55 +0300 |
commit | 1f2753aa2af2ae98b7bb5dfc6b15546c705b7bbc (patch) | |
tree | f049950445dc8b39834140574442444e72d7c340 /plugins/SegmentEditor | |
parent | 072e46d6cafc26d3c39eb7c965bf37bddb914039 (diff) |
Only show segments based on log_visit table in GDPR search (#13123)
* Only show segments based on log_visit table in GDPR search
* fix typo
* cs
Diffstat (limited to 'plugins/SegmentEditor')
3 files changed, 24 insertions, 13 deletions
diff --git a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator-model.js b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator-model.js index 113352c9d3..b9e5bfe2a9 100644 --- a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator-model.js +++ b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator-model.js @@ -23,7 +23,7 @@ return model; - function loadSegments(siteId) { + function loadSegments(siteId, visitSegmentsOnly) { if (model.isLoading) { if (limitPromise) { limitPromise.abort(); @@ -40,7 +40,7 @@ } if (!limitPromise) { - var params = {method: 'API.getSegmentsMetadata',filter_limit: '-1'}; + var params = {method: 'API.getSegmentsMetadata',filter_limit: '-1', '_hideImplementationData': 0}; if (siteId === 'all' || !siteId) { params.idSites = 'all'; @@ -57,10 +57,19 @@ model.isLoading = false; if (angular.isDefined(response)) { - model.segments = response; + if (visitSegmentsOnly) { + model.segments = []; + angular.forEach(response, function (segment) { + if (segment.sqlSegment && segment.sqlSegment.match(/log_visit\./)) { + model.segments.push(segment); + } + }); + } else { + model.segments = response; + } } - return response; + return model.segments; }).finally(function () { model.isLoading = false; }); diff --git a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.controller.js b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.controller.js index 21eed81367..73a594197c 100644 --- a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.controller.js +++ b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.controller.js @@ -151,7 +151,7 @@ format: 'json', method: 'API.getSuggestedValuesForSegment', segmentName: orCondition.segment - }, {createErrorNotification: false}) + }, {createErrorNotification: false}); promise.then(function(response) { orCondition.isLoading = false; @@ -196,7 +196,7 @@ promise.abort(); } }, 20000); - } + }; this.removeOrCondition = function (condition, orCondition) { var index = condition.orConditions.indexOf(orCondition); @@ -229,7 +229,7 @@ } subSegmentStr += orCondition.segment + orCondition.matches + encodeURIComponent(orCondition.value); - }) + }); if (segmentStr !== '') { segmentStr += ";"; // add AND operator between segment blocks @@ -253,7 +253,7 @@ var blocks = segmentStr.split(';'); for (var key = 0; key < blocks.length; key++) { - var condition = {orConditions: []}; + condition = {orConditions: []}; this.addAndCondition(condition); blocks[key] = blocks[key].split(','); @@ -266,7 +266,7 @@ this.updateSegmentDefinition = function () { $scope.segmentDefinition = this.getSegmentString(); - } + }; if ($scope.segmentDefinition) { this.setSegmentString($scope.segmentDefinition); @@ -274,14 +274,14 @@ $scope.$watch('idsite', function (newValue, oldValue) { if (newValue != oldValue) { - reloadSegments(newValue); + reloadSegments(newValue, $scope.visitSegmentsOnly); } }); - reloadSegments($scope.idsite); + reloadSegments($scope.idsite, $scope.visitSegmentsOnly); - function reloadSegments(idsite) { - segmentGeneratorModel.loadSegments(idsite).then(function (segments) { + function reloadSegments(idsite, visitSegmentsOnly) { + segmentGeneratorModel.loadSegments(idsite, visitSegmentsOnly).then(function (segments) { self.segmentList = []; diff --git a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.directive.js b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.directive.js index 25a0141f19..862e2054d8 100644 --- a/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.directive.js +++ b/plugins/SegmentEditor/angularjs/segment-generator/segmentgenerator.directive.js @@ -18,6 +18,7 @@ var defaults = { segmentDefinition: '', addInitialCondition: false, + visitSegmentsOnly: false, idsite: piwik.idSite }; @@ -26,6 +27,7 @@ scope: { segmentDefinition: '@', addInitialCondition: '=', + visitSegmentsOnly: '=', idsite: '=' }, require: "?ngModel", |