trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewr...@apache.org
Subject [incubator-trafficcontrol] 03/33: adds the ability to assign a ds request to yourself or unassign it
Date Wed, 21 Feb 2018 18:27:19 GMT
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit a0ab4bf2ede2527f4a0662ca48ce3f4bb71533dc
Author: Jeremy Mitchell <mitchell852@gmail.com>
AuthorDate: Fri Dec 29 09:36:39 2017 -0700

    adds the ability to assign a ds request to yourself or unassign it
---
 .../common/api/DeliveryServiceRequestService.js    |   4 +-
 .../FormDeliveryServiceController.js               |   3 +-
 .../app/src/common/modules/table/_table.scss       |   4 +
 .../TableDeliveryServiceRequestsController.js      | 112 ++++++++++++++++++++-
 .../table.deliveryServiceRequests.tpl.html         |  10 +-
 .../FormEditDeliveryServiceRequestController.js    |   8 +-
 6 files changed, 131 insertions(+), 10 deletions(-)

diff --git a/traffic_portal/app/src/common/api/DeliveryServiceRequestService.js b/traffic_portal/app/src/common/api/DeliveryServiceRequestService.js
index 7801d02..4d79152 100644
--- a/traffic_portal/app/src/common/api/DeliveryServiceRequestService.js
+++ b/traffic_portal/app/src/common/api/DeliveryServiceRequestService.js
@@ -55,11 +55,11 @@ var DeliveryServiceRequestService = function(Restangular, $http, $q, locationUti
 	};
 
 
-	this.deleteDeliveryServiceRequest = function(id) {
+	this.deleteDeliveryServiceRequest = function(id, delay) {
 		return Restangular.one("deliveryservice_requests", id).remove()
 			.then(
 				function() {
-					messageModel.setMessages([ { level: 'success', text: 'Delivery service request deleted'
} ], true);
+					messageModel.setMessages([ { level: 'success', text: 'Delivery service request deleted'
} ], delay);
 					locationUtils.navigateToPath('/delivery-service-requests');
 				},
 				function(fault) {
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
index 980d8c4..1ea226c 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
@@ -64,8 +64,9 @@ var FormDeliveryServiceController = function(deliveryService, type, types,
$scop
     };
 
     $scope.DRAFT = 0;
-
     $scope.SUBMITTED = 1;
+    $scope.REJECTED = 2;
+    $scope.COMPLETE = 3;
 
     $scope.types = _.filter(types, function(currentType) {
         var category;
diff --git a/traffic_portal/app/src/common/modules/table/_table.scss b/traffic_portal/app/src/common/modules/table/_table.scss
index a64e1fe..7449d60 100644
--- a/traffic_portal/app/src/common/modules/table/_table.scss
+++ b/traffic_portal/app/src/common/modules/table/_table.scss
@@ -20,4 +20,8 @@
   .fa-flag {
     font-weight: bold;
   }
+}
+
+.action-link {
+  padding: 5px;
 }
\ No newline at end of file
diff --git a/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/TableDeliveryServiceRequestsController.js
b/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/TableDeliveryServiceRequestsController.js
index 13ad1c4..ec6749d 100644
--- a/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/TableDeliveryServiceRequestsController.js
+++ b/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/TableDeliveryServiceRequestsController.js
@@ -17,7 +17,12 @@
  * under the License.
  */
 
-var TableDeliveryServicesRequestsController = function(dsRequests, $scope, $state, dateUtils,
locationUtils, typeService) {
+var TableDeliveryServicesRequestsController = function(dsRequests, $scope, $state, $uibModal,
dateUtils, locationUtils, typeService, deliveryServiceRequestService, userModel) {
+
+	$scope.DRAFT = 0;
+	$scope.SUBMITTED = 1;
+	$scope.REJECTED = 2;
+	$scope.COMPLETE = 3;
 
 	$scope.dsRequests = dsRequests;
 
@@ -27,6 +32,106 @@ var TableDeliveryServicesRequestsController = function(dsRequests, $scope,
$stat
 		$state.reload(); // reloads all the resolves for the view
 	};
 
+	$scope.assignRequest = function(request, assign, $event) {
+		$event.stopPropagation(); // this kills the click event so it doesn't trigger anything
else
+		var params = {
+			title: 'Assign Delivery Service Request',
+			message: (assign) ? 'Are you sure you want to assign this delivery service request to
yourself?' : 'Are you sure you want to unassign this delivery service request?'
+		};
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/dialog/confirm/dialog.confirm.tpl.html',
+			controller: 'DialogConfirmController',
+			size: 'md',
+			resolve: {
+				params: function () {
+					return params;
+				}
+			}
+		});
+		modalInstance.result.then(function() {
+			request.assigneeId = (assign) ? userModel.user.id : null;
+			deliveryServiceRequestService.updateDeliveryServiceRequest(request.id, request).
+				then(function() {
+					$scope.refresh();
+				});
+		}, function () {
+			// do nothing
+		});
+	};
+
+	$scope.editStatus = function(request, $event) {
+		$event.stopPropagation(); // this kills the click event so it doesn't trigger anything
else
+		var params = {
+			title: "Edit Delivery Service Request Status",
+			message: 'Please select the appropriate status for this request.'
+		};
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/dialog/select/dialog.select.tpl.html',
+			controller: 'DialogSelectController',
+			size: 'md',
+			resolve: {
+				params: function () {
+					return params;
+				},
+				collection: function() {
+					return [
+						{ id: $scope.DRAFT, name: 'Draft' },
+						{ id: $scope.SUBMITTED, name: 'Submitted' },
+						{ id: $scope.REJECTED, name: 'Rejected' },
+						{ id: $scope.COMPLETE, name: 'Complete' }
+					];
+				}
+			}
+		});
+		modalInstance.result.then(function(action) {
+			switch (action.id) {
+				case $scope.DRAFT:
+					request.status = 'draft';
+					break;
+				case $scope.SUBMITTED:
+					request.status = 'submitted';
+					break;
+				case $scope.REJECTED:
+					request.status = 'rejected';
+					break;
+				case $scope.COMPLETE:
+					request.status = 'complete';
+			}
+			deliveryServiceRequestService.updateDeliveryServiceRequest(request.id, request).
+				then(function() {
+					$scope.refresh();
+				});
+		}, function () {
+			// do nothing
+		});
+	};
+
+	$scope.deleteRequest = function(request, $event) {
+		$event.stopPropagation(); // this kills the click event so it doesn't trigger anything
else
+		var params = {
+			title: 'Delete ' + request.request.xmlId + ' ' + request.changeType + ' request?',
+			key: request.request.xmlId + ' request'
+		};
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/dialog/delete/dialog.delete.tpl.html',
+			controller: 'DialogDeleteController',
+			size: 'md',
+			resolve: {
+				params: function () {
+					return params;
+				}
+			}
+		});
+		modalInstance.result.then(function() {
+			deliveryServiceRequestService.deleteDeliveryServiceRequest(request.id, false).
+				then(function() {
+					$scope.refresh();
+				});
+		}, function () {
+			// do nothing
+		});
+	};
+
 	$scope.editDeliveryServiceRequest = function(request) {
 		var path = '/delivery-service-requests/' + request.id + '?type=';
 		typeService.getType(request.request.typeId)
@@ -40,11 +145,14 @@ var TableDeliveryServicesRequestsController = function(dsRequests, $scope,
$stat
 		$('#dsRequestsTable').dataTable({
 			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
 			"iDisplayLength": 25,
+			"columnDefs": [
+				{ 'orderable': false, 'targets': 6 }
+			],
 			"aaSorting": []
 		});
 	});
 
 };
 
-TableDeliveryServicesRequestsController.$inject = ['dsRequests', '$scope', '$state', 'dateUtils',
'locationUtils', 'typeService'];
+TableDeliveryServicesRequestsController.$inject = ['dsRequests', '$scope', '$state', '$uibModal',
'dateUtils', 'locationUtils', 'typeService', 'deliveryServiceRequestService', 'userModel'];
 module.exports = TableDeliveryServicesRequestsController;
diff --git a/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/table.deliveryServiceRequests.tpl.html
b/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/table.deliveryServiceRequests.tpl.html
index a05e0aa..ade84a9 100644
--- a/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/table.deliveryServiceRequests.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/deliveryServiceRequests/table.deliveryServiceRequests.tpl.html
@@ -38,6 +38,7 @@ under the License.
                 <th>Author</th>
                 <th>Assignee</th>
                 <th>Last Updated</th>
+                <th></th>
             </tr>
             </thead>
             <tbody>
@@ -46,8 +47,15 @@ under the License.
                 <td data-search="^{{::request.changeType}}$">{{::request.changeType}}</td>
                 <td data-search="^{{::request.status}}$">{{::request.status}}</td>
                 <td data-search="^{{::request.author}}$">{{::request.author}}</td>
-                <td data-search="^{{::request.assignee}}$">{{::request.assignee}}</td>
+                <td data-search="^{{::request.assignee}}$">
+                    <a ng-show="!request.assignee" class="link" title="Assign Yourself"
ng-click="assignRequest(request, true, $event)">No one - assign yourself</a>
+                    <a ng-show="request.assignee" class="link" title="Clear Assignee"
ng-click="assignRequest(request, false, $event)">{{::request.assignee}} - clear</a>
+                </td>
                 <td data-search="^{{::getRelativeTime(request.lastUpdated)}}$" data-order="{{::request.lastUpdated}}">{{::getRelativeTime(request.lastUpdated)}}</td>
+                <td style="text-align: right;">
+                    <a class="link action-link" title="Edit Status" ng-click="editStatus(request,
$event)">edit status</a>|
+                    <a class="link action-link" title="Delete Request" ng-click="deleteRequest(request,
$event)">delete</a>
+                </td>
             </tr>
             </tbody>
         </table>
diff --git a/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
b/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
index b0eaa6a..2d9cfbb 100644
--- a/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
+++ b/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
@@ -39,8 +39,8 @@ var FormEditDeliveryServiceRequestController = function(deliveryServiceRequest,
 
 	$scope.fulfill = function(deliveryService) {
 		var params = {
-			title: $scope.changeType + ' Delivery Service: ' + deliveryService.xmlId,
-			message: 'Are you sure you want to fulfill this delivery service request and ' + $scope.changeType
+ ' ' + deliveryService.xmlId + '?'
+			title: 'Delivery Service ' + $scope.changeType + ': ' + deliveryService.xmlId,
+			message: 'Are you sure you want to fulfill this delivery service request and ' + $scope.changeType
+ ' the ' + deliveryService.xmlId + ' delivery service?'
 		};
 		var modalInstance = $uibModal.open({
 			templateUrl: 'common/modules/dialog/confirm/dialog.confirm.tpl.html',
@@ -101,7 +101,7 @@ var FormEditDeliveryServiceRequestController = function(deliveryServiceRequest,
 	$scope.confirmDelete = function(deliveryService) {
 		var params = {
 			title: 'Delete ' + deliveryService.xmlId + ' ' + dsRequest.changeType + ' request?',
-			key: deliveryService.xmlId + ' ' + dsRequest.changeType + ' request'
+			key: deliveryService.xmlId + ' request'
 		};
 		var modalInstance = $uibModal.open({
 			templateUrl: 'common/modules/dialog/delete/dialog.delete.tpl.html',
@@ -114,7 +114,7 @@ var FormEditDeliveryServiceRequestController = function(deliveryServiceRequest,
 			}
 		});
 		modalInstance.result.then(function() {
-			deliveryServiceRequestService.deleteDeliveryServiceRequest($stateParams.deliveryServiceRequestId);
+			deliveryServiceRequestService.deleteDeliveryServiceRequest($stateParams.deliveryServiceRequestId,
true);
 		}, function () {
 			// do nothing
 		});

-- 
To stop receiving notification emails like this one, please contact
dewrich@apache.org.

Mime
View raw message