mitchell852 closed pull request #2601: TP: Provide way to enable or disable 
cachegroup localization methods
URL: https://github.com/apache/trafficcontrol/pull/2601
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/traffic_portal/app/src/common/modules/form/cacheGroup/FormCacheGroupController.js
 
b/traffic_portal/app/src/common/modules/form/cacheGroup/FormCacheGroupController.js
index f53c28a27..47537d6f2 100644
--- 
a/traffic_portal/app/src/common/modules/form/cacheGroup/FormCacheGroupController.js
+++ 
b/traffic_portal/app/src/common/modules/form/cacheGroup/FormCacheGroupController.js
@@ -57,7 +57,41 @@ var FormCacheGroupController = function(cacheGroup, $scope, 
$location, formUtils
 
     $scope.hasPropertyError = formUtils.hasPropertyError;
 
+    $scope.localizationMethods = {
+        DEEP_CZ: false,
+        CZ: false,
+        GEO: false
+    };
+
+    $scope.setLocalizationMethods = function(cacheGroup) {
+        var methods = [];
+        var keys = Object.keys($scope.localizationMethods);
+        for (var i = 0; i < keys.length; i++) {
+            if ($scope.localizationMethods[keys[i]]) {
+                methods.push(keys[i]);
+            }
+        }
+        cacheGroup.localizationMethods = methods;
+    };
+
+    var initLocalizationMethods = function() {
+        // by default, no explicitly enabled methods means ALL are enabled
+        if (!cacheGroup.localizationMethods) {
+            var keys = Object.keys($scope.localizationMethods);
+            for (var i = 0; i < keys.length; i++) {
+                $scope.localizationMethods[keys[i]] = true;
+            }
+            return;
+        }
+        for (var i = 0; i < cacheGroup.localizationMethods.length; i++) {
+            if 
($scope.localizationMethods.hasOwnProperty(cacheGroup.localizationMethods[i])) {
+                $scope.localizationMethods[cacheGroup.localizationMethods[i]] 
= true;
+            }
+        }
+    };
+
     var init = function () {
+        initLocalizationMethods();
         getCacheGroups();
         getTypes();
     };
diff --git 
a/traffic_portal/app/src/common/modules/form/cacheGroup/edit/FormEditCacheGroupController.js
 
b/traffic_portal/app/src/common/modules/form/cacheGroup/edit/FormEditCacheGroupController.js
index e9ce0057c..d458b3c4c 100644
--- 
a/traffic_portal/app/src/common/modules/form/cacheGroup/edit/FormEditCacheGroupController.js
+++ 
b/traffic_portal/app/src/common/modules/form/cacheGroup/edit/FormEditCacheGroupController.js
@@ -45,6 +45,7 @@ var FormEditCacheGroupController = function(cacheGroup, 
$scope, $controller, $ui
     };
 
     $scope.save = function(cacheGroup) {
+        $scope.setLocalizationMethods(cacheGroup);
         cacheGroupService.updateCacheGroup(cacheGroup).
             then(function() {
                 $scope.cacheGroupName = angular.copy(cacheGroup.name);
diff --git 
a/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
 
b/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
index dba9c619f..39e46879a 100644
--- 
a/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
+++ 
b/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
@@ -120,6 +120,14 @@
                     <small ng-show="cacheGroup.secondaryParentCachegroupId"><a 
href="/#!/cache-groups/{{cacheGroup.secondaryParentCachegroupId}}" 
target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs 
fa-external-link"></i></a></small>
                 </div>
             </div>
+            <div class="form-group">
+                <label class="control-label col-md-2 col-sm-2 
col-xs-12">Enabled Localization Methods</label>
+                <div class="col-md-10 col-sm-10 col-xs-12">
+                    <input type="checkbox" name="CZEnabled" 
ng-model="localizationMethods.CZ"> Coverage Zone File</input><br>
+                    <input type="checkbox" name="DeepCZEnabled" 
ng-model="localizationMethods.DEEP_CZ"> Deep Coverage Zone File</input><br>
+                    <input type="checkbox" name="GeoEnabled" 
ng-model="localizationMethods.GEO"> Geo-IP Database</input>
+                </div>
+            </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" 
ng-show="!settings.isNew" ng-click="confirmDelete(cacheGroup)">Delete</button>
                 <button type="button" class="btn btn-success" 
ng-disabled="cacheGroupForm.$pristine || cacheGroupForm.$invalid" 
ng-click="save(cacheGroup)">{{settings.saveLabel}}</button>
diff --git 
a/traffic_portal/app/src/common/modules/form/cacheGroup/new/FormNewCacheGroupController.js
 
b/traffic_portal/app/src/common/modules/form/cacheGroup/new/FormNewCacheGroupController.js
index 6f5896f72..98bf56472 100644
--- 
a/traffic_portal/app/src/common/modules/form/cacheGroup/new/FormNewCacheGroupController.js
+++ 
b/traffic_portal/app/src/common/modules/form/cacheGroup/new/FormNewCacheGroupController.js
@@ -30,6 +30,7 @@ var FormNewCacheGroupController = function(cacheGroup, 
$scope, $controller, cach
     };
 
     $scope.save = function(cacheGroup) {
+        $scope.setLocalizationMethods(cacheGroup);
         cacheGroupService.createCacheGroup(cacheGroup);
     };
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to