You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/06/18 15:13:10 UTC
[trafficcontrol] 02/04: Make the Origin UI more user-friendly
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 2269e0eb56f688def0adfa6c1d44fc5f4c00ecd9
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Mon Jun 11 12:59:23 2018 -0600
Make the Origin UI more user-friendly
---
traffic_portal/app/src/common/api/CoordinateService.js | 2 +-
traffic_portal/app/src/common/api/OriginService.js | 2 +-
.../common/modules/form/origin/FormOriginController.js | 15 +++++++++++----
.../modules/form/origin/edit/FormEditOriginController.js | 2 --
.../src/common/modules/form/origin/form.origin.tpl.html | 16 ++++++++++------
.../modules/form/origin/new/FormNewOriginController.js | 2 --
6 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/traffic_portal/app/src/common/api/CoordinateService.js b/traffic_portal/app/src/common/api/CoordinateService.js
index 5aa7146..3a412bf 100644
--- a/traffic_portal/app/src/common/api/CoordinateService.js
+++ b/traffic_portal/app/src/common/api/CoordinateService.js
@@ -31,7 +31,7 @@ var CoordinateService = function($http, $q, Restangular, locationUtils, messageM
function(response) {
messageModel.setMessages(response.data.alerts, true);
locationUtils.navigateToPath('/coordinates');
- request.resolve(result);
+ request.resolve(response);
},
function(fault) {
messageModel.setMessages(fault.data.alerts, false)
diff --git a/traffic_portal/app/src/common/api/OriginService.js b/traffic_portal/app/src/common/api/OriginService.js
index a2d2552..d7d4747 100644
--- a/traffic_portal/app/src/common/api/OriginService.js
+++ b/traffic_portal/app/src/common/api/OriginService.js
@@ -31,7 +31,7 @@ var OriginService = function($http, $q, Restangular, locationUtils, messageModel
function(response) {
messageModel.setMessages(response.data.alerts, true);
locationUtils.navigateToPath('/origins');
- request.resolve(result);
+ request.resolve(response);
},
function(fault) {
messageModel.setMessages(fault.data.alerts, false)
diff --git a/traffic_portal/app/src/common/modules/form/origin/FormOriginController.js b/traffic_portal/app/src/common/modules/form/origin/FormOriginController.js
index 65db5e1..24f6668 100644
--- a/traffic_portal/app/src/common/modules/form/origin/FormOriginController.js
+++ b/traffic_portal/app/src/common/modules/form/origin/FormOriginController.js
@@ -37,14 +37,16 @@ var FormOriginController = function(origin, $scope, $location, formUtils, locati
};
var getCacheGroups = function() {
- cacheGroupService.getCacheGroups()
+ cacheGroupService.getCacheGroups({ orderby: 'name' })
.then(function(result) {
- $scope.cacheGroups = result;
+ $scope.cacheGroups = _.filter(result, function(cachegroup) {
+ return cachegroup.typeName == 'ORG_LOC';
+ });
});
};
var getCoordinates = function() {
- coordinateService.getCoordinates()
+ coordinateService.getCoordinates({ orderby: 'name' })
.then(function(result) {
$scope.coordinates = result;
});
@@ -53,7 +55,7 @@ var FormOriginController = function(origin, $scope, $location, formUtils, locati
var getDeliveryServices = function() {
deliveryServiceService.getDeliveryServices()
.then(function(result) {
- $scope.deliveryServices = result;
+ $scope.deliveryServices = _.sortBy(result, 'xmlId');
});
};
@@ -68,6 +70,11 @@ var FormOriginController = function(origin, $scope, $location, formUtils, locati
return '-'.repeat(tenant.level) + ' ' + tenant.name;
};
+ $scope.nullifyIfEmptyIP = function(origin) {
+ origin.ipAddress = origin.ipAddress == '' ? null : origin.ipAddress;
+ origin.ip6Address = origin.ip6Address == '' ? null : origin.ip6Address;
+ }
+
$scope.navigateToPath = locationUtils.navigateToPath;
$scope.hasError = formUtils.hasError;
diff --git a/traffic_portal/app/src/common/modules/form/origin/edit/FormEditOriginController.js b/traffic_portal/app/src/common/modules/form/origin/edit/FormEditOriginController.js
index f28b506..e56213b 100644
--- a/traffic_portal/app/src/common/modules/form/origin/edit/FormEditOriginController.js
+++ b/traffic_portal/app/src/common/modules/form/origin/edit/FormEditOriginController.js
@@ -26,8 +26,6 @@ var FormEditOriginController = function(origin, $scope, $state, $controller, $ui
$scope.originName = angular.copy($scope.origin.name);
- $scope.isPrimary = angular.copy($scope.origin.isPrimary);
-
$scope.settings = {
isNew: false,
saveLabel: 'Update',
diff --git a/traffic_portal/app/src/common/modules/form/origin/form.origin.tpl.html b/traffic_portal/app/src/common/modules/form/origin/form.origin.tpl.html
index 800164a..c53f937 100644
--- a/traffic_portal/app/src/common/modules/form/origin/form.origin.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/origin/form.origin.tpl.html
@@ -28,8 +28,11 @@ under the License.
<div class="x_content">
<br>
<form name="originForm" class="form-horizontal form-label-left" novalidate>
- <div class="form-group" ng-class="{'has-error': hasError(originForm.isPrimary), 'has-feedback': hasError(originForm.isPrimary)}">
- <label ng-show="!settings.isNew" class="control-label col-md-2 col-sm-2 col-xs-12">Primary: {{isPrimary}}</label>
+ <div ng-show='!settings.isNew' class="form-group">
+ <label class="control-label col-md-2 col-sm-2 col-xs-12">Primary:</label>
+ <div class="col-md-10 col-sm-10 col-xs-12">
+ <input name="isPrimary" type="text" class="form-control" ng-value="origin.isPrimary" readonly autofocus>
+ </div>
</div>
<div class="form-group" ng-class="{'has-error': hasError(originForm.name), 'has-feedback': hasError(originForm.name)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">Name *</label>
@@ -63,7 +66,7 @@ under the License.
<div class="form-group" ng-class="{'has-error': hasError(originForm.ipAddress), 'has-feedback': hasError(originForm.ipAddress)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">IPv4 Address</label>
<div class="col-md-10 col-sm-10 col-xs-12">
- <input name="ipAddress" type="text" class="form-control" ng-model="origin.ipAddress" ng-maxlength="45" ng-pattern="ipRegex()" autofocus>
+ <input name="ipAddress" type="text" class="form-control" ng-model="origin.ipAddress" ng-change="nullifyIfEmptyIP(origin)" ng-maxlength="15" ng-pattern="/^\d{1,3}(\.\d{1,3}){3}$/" autofocus>
<small class="input-error" ng-show="hasPropertyError(originForm.ipAddress, 'maxlength')">Too Long</small>
<small class="input-error" ng-show="hasPropertyError(originForm.ipAddress, 'pattern')">Invalid</small>
<span ng-show="hasError(originForm.ipAddress)" class="form-control-feedback"><i class="fa fa-times"></i></span>
@@ -72,8 +75,9 @@ under the License.
<div class="form-group" ng-class="{'has-error': hasError(originForm.ip6Address), 'has-feedback': hasError(originForm.ip6Address)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">IPv6 Address</label>
<div class="col-md-10 col-sm-10 col-xs-12">
- <input name="ip6Address" type="text" class="form-control" ng-model="origin.ip6Address" ng-maxlength="50" autofocus>
+ <input name="ip6Address" type="text" class="form-control" ng-model="origin.ip6Address" ng-change="nullifyIfEmptyIP(origin)" ng-maxlength="39" ng-pattern="/^[0-9a-fA-F:]+$/" autofocus>
<small class="input-error" ng-show="hasPropertyError(originForm.ip6Address, 'maxlength')">Too Long</small>
+ <small class="input-error" ng-show="hasPropertyError(originForm.ip6Address, 'pattern')">Invalid</small>
<span ng-show="hasError(originForm.ip6Address)" class="form-control-feedback"><i class="fa fa-times"></i></span>
</div>
</div>
@@ -99,7 +103,7 @@ under the License.
<div class="form-group" ng-class="{'has-error': hasError(originForm.deliveryServiceId), 'has-feedback': hasError(originForm.deliveryServiceId)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">Delivery Service *</label>
<div class="col-md-10 col-sm-10 col-xs-12">
- <select name="deliveryServiceId" class="form-control" ng-model="origin.deliveryServiceId" ng-options="deliveryService.id as deliveryService.xmlId for deliveryService in deliveryServices" required>
+ <select name="deliveryServiceId" class="form-control" ng-model="origin.deliveryServiceId" ng-options="deliveryService.id as deliveryService.xmlId for deliveryService in deliveryServices" ng-disabled="origin.isPrimary" required>
<option value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(originForm.deliveryServiceId, 'required')">Required</small>
@@ -133,7 +137,7 @@ under the License.
</div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(origin)">Delete</button>
+ <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-disabled="origin.isPrimary" ng-click="confirmDelete(origin)">Delete</button>
<button type="button" class="btn btn-success" ng-disabled="originForm.$pristine || originForm.$invalid" ng-click="save(origin)">{{settings.saveLabel}}</button>
</div>
</form>
diff --git a/traffic_portal/app/src/common/modules/form/origin/new/FormNewOriginController.js b/traffic_portal/app/src/common/modules/form/origin/new/FormNewOriginController.js
index befcd04..7cbec6a 100644
--- a/traffic_portal/app/src/common/modules/form/origin/new/FormNewOriginController.js
+++ b/traffic_portal/app/src/common/modules/form/origin/new/FormNewOriginController.js
@@ -24,8 +24,6 @@ var FormNewOriginController = function(origin, $scope, $controller, $anchorScrol
$scope.originName = 'New';
- $scope.isPrimary = "false";
-
$scope.settings = {
isNew: true,
saveLabel: 'Create'
--
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.