Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,30 @@ var FormCacheGroupController = function(cacheGroup, types, cacheGroups, $scope,
$location.path($location.path() + '/static-dns-entries');
};

$scope.hasLocalizationMethod = function(method) {
return $scope.cacheGroup.localizationMethods.includes(method);
};

$scope.toggleLocalizationMethod = function toggleSelection(method) {
$scope.cacheGroupForm.$setDirty(); // required to enable the update button
const index = $scope.cacheGroup.localizationMethods.indexOf(method);
if (index > -1) {
$scope.cacheGroup.localizationMethods.splice(index, 1);
} else {
$scope.cacheGroup.localizationMethods.push(method);
}
};

$scope.navigateToPath = locationUtils.navigateToPath;

$scope.hasError = formUtils.hasError;

$scope.hasPropertyError = formUtils.hasPropertyError;

$scope.localizationMethods = {
DEEP_CZ: false,
CZ: false,
GEO: false
};

$scope.cacheGroupFallbackOptions = [];

$scope.selectedCacheGroupFallbackOptions = [];

$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 initCacheGroupFallbackGeo = function() {
if (cacheGroup.fallbackToClosest == null || cacheGroup.fallbackToClosest === '') {
cacheGroup.fallbackToClosest = true;
Expand Down Expand Up @@ -157,7 +138,6 @@ var FormCacheGroupController = function(cacheGroup, types, cacheGroups, $scope,
};

$scope.save = function(cacheGroup) {
$scope.setLocalizationMethods(cacheGroup);
cacheGroupService.createCacheGroup(cacheGroup);
$scope.cacheGroupFallbackUpdated = false;
};
Expand Down Expand Up @@ -217,7 +197,6 @@ var FormCacheGroupController = function(cacheGroup, types, cacheGroups, $scope,
};

var init = function () {
initLocalizationMethods();
$scope.getFallbackOptions();
initCacheGroupFallbackGeo();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var FormEditCacheGroupController = function(cacheGroup, types, cacheGroups, $sco
};

$scope.save = function(cacheGroup) {
$scope.setLocalizationMethods(cacheGroup);
cacheGroupService.updateCacheGroup(cacheGroup).
then(function() {
$scope.cacheGroupName = angular.copy(cacheGroup.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@
<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>
<input type="checkbox" name="CZEnabled" ng-checked="hasLocalizationMethod('CZ')" ng-click="toggleLocalizationMethod('CZ')"> Coverage Zone File</input><br>
<input type="checkbox" name="GeoEnabled" ng-checked="hasLocalizationMethod('GEO')" ng-click="toggleLocalizationMethod('GEO')"> Geo-IP Database</input>
</div>
</div>
<div class="form-group" ng-class="{'has-error': hasError(cacheGroupForm.fallbacks), 'has-feedback': hasError(cacheGroupForm.fallbacks)}" ng-hide="!isEdgeLoc(cacheGroup.typeId)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var FormNewCacheGroupController = function(cacheGroup, types, cacheGroups, $scop
};

$scope.save = function(cacheGroup) {
$scope.setLocalizationMethods(cacheGroup);
cacheGroupService.createCacheGroup(cacheGroup);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ module.exports = angular.module('trafficPortal.private.cacheGroups.new', [])
controller: 'FormNewCacheGroupController',
resolve: {
cacheGroup: function() {
return {};
return {
localizationMethods: [ 'CZ', 'GEO' ]
};
},
types: function(typeService) {
return typeService.getTypes({ useInTable: 'cachegroup' });
Expand Down