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/09/07 14:20:21 UTC

[trafficcontrol] branch master updated: Fixes #2687 - removes dependency on use_tenancy in traffic portal

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


The following commit(s) were added to refs/heads/master by this push:
     new 269fc96  Fixes #2687 - removes dependency on use_tenancy in traffic portal
269fc96 is described below

commit 269fc968169ff3ca581c9b8b771eb7120d7741a3
Author: cgillo000 <ch...@cable.comcast.com>
AuthorDate: Wed Aug 29 14:51:14 2018 -0600

    Fixes #2687 - removes dependency on use_tenancy in traffic portal
---
 .../TableUserDSUnassignedController.js             | 117 ---------------------
 .../TableUserDeliveryServicesController.js         |  53 +---------
 .../modules/table/userDeliveryServices/index.js    |   3 +-
 .../table.userDSUnassigned.tpl.html                |  47 ---------
 .../table.userDeliveryServices.tpl.html            |   2 -
 .../private/users/deliveryServices/index.js        |   9 +-
 6 files changed, 9 insertions(+), 222 deletions(-)

diff --git a/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDSUnassignedController.js b/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDSUnassignedController.js
deleted file mode 100644
index 2b9a163..0000000
--- a/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDSUnassignedController.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var TableUserDSUnassignedController = function(user, deliveryServices, userDeliveryServices, $scope, $uibModalInstance) {
-
-	var selectedDeliveryServiceIds = [];
-
-	var addDS = function(dsId) {
-		if (_.indexOf(selectedDeliveryServiceIds, dsId) == -1) {
-			selectedDeliveryServiceIds.push(dsId);
-		}
-	};
-
-	var removeDS = function(dsId) {
-		selectedDeliveryServiceIds = _.without(selectedDeliveryServiceIds, dsId);
-	};
-
-	var addAll = function() {
-		markDSs(true);
-		selectedDeliveryServiceIds = _.pluck(deliveryServices, 'id');
-	};
-
-	var removeAll = function() {
-		markDSs(false);
-		selectedDeliveryServiceIds = [];
-	};
-
-	var markDSs = function(selected) {
-		$scope.selectedDSs = _.map(deliveryServices, function(ds) {
-			ds['selected'] = selected;
-			return ds;
-		});
-	};
-
-	$scope.user = user;
-
-	$scope.selectedDSs = _.map(deliveryServices, function(ds) {
-		var isAssigned = _.find(userDeliveryServices, function(userDS) { return userDS.id == ds.id });
-		if (isAssigned) {
-			ds['selected'] = true; // so the checkbox will be checked
-			selectedDeliveryServiceIds.push(ds.id); // so the ds is added to selected delivery services
-		}
-		return ds;
-	});
-
-	$scope.allSelected = function() {
-		return deliveryServices.length == selectedDeliveryServiceIds.length;
-	};
-
-	$scope.selectAll = function($event) {
-		var checkbox = $event.target;
-		if (checkbox.checked) {
-			addAll();
-		} else {
-			removeAll();
-		}
-	};
-
-	$scope.updateDeliveryServices = function($event, dsId) {
-		var checkbox = $event.target;
-		if (checkbox.checked) {
-			addDS(dsId);
-		} else {
-			removeDS(dsId);
-		}
-	};
-
-	$scope.submit = function() {
-		$uibModalInstance.close(selectedDeliveryServiceIds);
-	};
-
-	$scope.cancel = function () {
-		$uibModalInstance.dismiss('cancel');
-	};
-
-	angular.element(document).ready(function () {
-		var userDSUnassignedTable = $('#userDSUnassignedTable').dataTable({
-			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
-			"iDisplayLength": 25,
-			"order": [[ 1, 'asc' ]],
-			"columnDefs": [
-				{ 'orderable': false, 'targets': 0 },
-				{ "width": "5%", "targets": 0 }
-			],
-			"stateSave": false
-		});
-		userDSUnassignedTable.on( 'search.dt', function () {
-			var search = $('#userDSUnassignedTable_filter input').val();
-			if (search.length > 0) {
-				$("#selectAllCB").attr("disabled", true);
-			} else {
-				$("#selectAllCB").removeAttr("disabled");
-			}
-		} );
-
-	});
-
-};
-
-TableUserDSUnassignedController.$inject = ['user', 'deliveryServices', 'userDeliveryServices', '$scope', '$uibModalInstance'];
-module.exports = TableUserDSUnassignedController;
diff --git a/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDeliveryServicesController.js b/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDeliveryServicesController.js
index 3c82efc..6dd4ce3 100644
--- a/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDeliveryServicesController.js
+++ b/traffic_portal/app/src/common/modules/table/userDeliveryServices/TableUserDeliveryServicesController.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-var TableUserDeliveryServicesController = function(user, userDeliveryServices, useTenancy, $scope, $state, $uibModal, dateUtils, deliveryServiceUtils, locationUtils, userService, propertiesModel) {
+var TableUserDeliveryServicesController = function (user, userDeliveryServices, $scope, $state, $uibModal, dateUtils, deliveryServiceUtils, locationUtils, userService, propertiesModel) {
 
 	var protocols = deliveryServiceUtils.protocols;
 
@@ -27,64 +27,21 @@ var TableUserDeliveryServicesController = function(user, userDeliveryServices, u
 
 	$scope.userDeliveryServices = userDeliveryServices;
 
-	$scope.useTenancy = useTenancy[0].value;
-
 	$scope.showChartsButton = propertiesModel.properties.deliveryServices.charts.customLink.show;
 
 	$scope.openCharts = deliveryServiceUtils.openCharts;
 
-	$scope.protocol = function(ds) {
+	$scope.protocol = function (ds) {
 		return protocols[ds.protocol];
 	};
 
-	$scope.qstring = function(ds) {
+	$scope.qstring = function (ds) {
 		return qstrings[ds.qstringIgnore];
 	};
 
 	$scope.getRelativeTime = dateUtils.getRelativeTime;
 
-	$scope.removeDS = function(dsId, $event) {
-		$event.stopPropagation(); // this kills the click event so it doesn't trigger anything else
-
-		userService.deleteUserDeliveryService(user.id, dsId)
-			.then(
-				function() {
-					$scope.refresh();
-				}
-			);
-	};
-
-	$scope.selectDSs = function() {
-		var modalInstance = $uibModal.open({
-			templateUrl: 'common/modules/table/userDeliveryServices/table.userDSUnassigned.tpl.html',
-			controller: 'TableUserDSUnassignedController',
-			size: 'lg',
-			resolve: {
-				user: function() {
-					return user;
-				},
-				deliveryServices: function(deliveryServiceService) {
-					return deliveryServiceService.getDeliveryServices();
-				},
-				userDeliveryServices: function() {
-					return userDeliveryServices;
-				}
-			}
-		});
-		modalInstance.result.then(function(selectedDSIds) {
-			console.log(selectedDSIds);
-			userService.assignUserDeliveryServices(user.id, selectedDSIds)
-				.then(
-					function() {
-						$scope.refresh();
-					}
-				);
-		}, function () {
-			// do nothing
-		});
-	};
-
-	$scope.refresh = function() {
+	$scope.refresh = function () {
 		$state.reload(); // reloads all the resolves for the view
 	};
 
@@ -100,5 +57,5 @@ var TableUserDeliveryServicesController = function(user, userDeliveryServices, u
 
 };
 
-TableUserDeliveryServicesController.$inject = ['user', 'userDeliveryServices', 'useTenancy', '$scope', '$state', '$uibModal', 'dateUtils', 'deliveryServiceUtils','locationUtils', 'userService', 'propertiesModel'];
+TableUserDeliveryServicesController.$inject = ['user', 'userDeliveryServices', '$scope', '$state', '$uibModal', 'dateUtils', 'deliveryServiceUtils', 'locationUtils', 'userService', 'propertiesModel'];
 module.exports = TableUserDeliveryServicesController;
diff --git a/traffic_portal/app/src/common/modules/table/userDeliveryServices/index.js b/traffic_portal/app/src/common/modules/table/userDeliveryServices/index.js
index 4bcbe1e..eaa7b34 100644
--- a/traffic_portal/app/src/common/modules/table/userDeliveryServices/index.js
+++ b/traffic_portal/app/src/common/modules/table/userDeliveryServices/index.js
@@ -18,5 +18,4 @@
  */
 
 module.exports = angular.module('trafficPortal.table.userDeliveryServices', [])
-	.controller('TableUserDeliveryServicesController', require('./TableUserDeliveryServicesController'))
-	.controller('TableUserDSUnassignedController', require('./TableUserDSUnassignedController'));
+	.controller('TableUserDeliveryServicesController', require('./TableUserDeliveryServicesController'));
diff --git a/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDSUnassigned.tpl.html b/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDSUnassigned.tpl.html
deleted file mode 100644
index d147148..0000000
--- a/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDSUnassigned.tpl.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-
-
-<div class="modal-header">
-    <button type="button" class="close" ng-click="cancel()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
-    <h3 class="modal-title">Assign Delivery Services to {{::user.username}}</h3>
-</div>
-<div class="modal-body">
-    <table id="userDSUnassignedTable" class="table responsive-utilities jambo_table" style="table-layout:fixed; width:100%;">
-        <thead>
-        <tr class="headings">
-            <th style="padding-left: 10px;"><input id="selectAllCB" type="checkbox" ng-click="selectAll($event)" ng-checked="allSelected()"></th>
-            <th>Key (XML ID)</th>
-            <th>Display Name</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr ng-repeat="ds in ::selectedDSs">
-            <td><input type="checkbox" ng-click="updateDeliveryServices($event, ds.id)" ng-checked="ds.selected"></td>
-            <td data-search="^{{::ds.xmlId}}$">{{::ds.xmlId}}</td>
-            <td data-search="^{{::ds.displayName}}$">{{::ds.displayName}}</td>
-        </tr>
-        </tbody>
-    </table>
-</div>
-<div class="modal-footer">
-    <button class="btn btn-link" ng-click="cancel()">cancel</button>
-    <button class="btn btn-primary" ng-click="submit()">Submit</button>
-</div>
diff --git a/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDeliveryServices.tpl.html b/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDeliveryServices.tpl.html
index bf2b2f5..389f131 100644
--- a/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDeliveryServices.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/userDeliveryServices/table.userDeliveryServices.tpl.html
@@ -25,7 +25,6 @@ under the License.
             <li class="active">Delivery Services</li>
         </ol>
         <div class="pull-right">
-            <button class="btn btn-primary" title="Link Delivery Services to User" ng-if="useTenancy == '0'" ng-click="selectDSs()"><i class="fa fa-link"></i></button>
             <button class="btn btn-default" title="Refresh" ng-click="refresh()"><i class="fa fa-refresh"></i></button>
         </div>
         <div class="clearfix"></div>
@@ -65,7 +64,6 @@ under the License.
                 <td data-search="^{{::qstring(ds)}}$">{{::qstring(ds)}}</td>
                 <td data-search="^{{::getRelativeTime(ds.lastUpdated)}}$" data-order="{{::ds.lastUpdated}}">{{::getRelativeTime(ds.lastUpdated)}}</td>
                 <td style="text-align: right;">
-                    <a ng-if="useTenancy == '0'" class="link action-link" title="Unlink Delivery Service from User" ng-click="removeDS(ds.id, $event)"><i class="fa fa-sm fa-chain-broken"></i></a>
                     <span ng-if="showChartsButton"><a class="link action-link" title="View Charts" ng-click="openCharts(ds, $event)"><i class="fa fa-sm fa-bar-chart"></i></a></span>
                 </td>
             </tr>
diff --git a/traffic_portal/app/src/modules/private/users/deliveryServices/index.js b/traffic_portal/app/src/modules/private/users/deliveryServices/index.js
index a6c7d08..cc5d669 100644
--- a/traffic_portal/app/src/modules/private/users/deliveryServices/index.js
+++ b/traffic_portal/app/src/modules/private/users/deliveryServices/index.js
@@ -18,7 +18,7 @@
  */
 
 module.exports = angular.module('trafficPortal.private.users.deliveryServices', [])
-	.config(function($stateProvider, $urlRouterProvider) {
+	.config(function ($stateProvider, $urlRouterProvider) {
 		$stateProvider
 			.state('trafficPortal.private.users.deliveryServices', {
 				url: '/{userId}/delivery-services',
@@ -27,14 +27,11 @@ module.exports = angular.module('trafficPortal.private.users.deliveryServices',
 						templateUrl: 'common/modules/table/userDeliveryServices/table.userDeliveryServices.tpl.html',
 						controller: 'TableUserDeliveryServicesController',
 						resolve: {
-							user: function($stateParams, userService) {
+							user: function ($stateParams, userService) {
 								return userService.getUser($stateParams.userId);
 							},
-							userDeliveryServices: function($stateParams, deliveryServiceService) {
+							userDeliveryServices: function ($stateParams, deliveryServiceService) {
 								return deliveryServiceService.getUserDeliveryServices($stateParams.userId);
-							},
-							useTenancy: function(parameterService) {
-								return parameterService.getParameters({ name: 'use_tenancy', configFile: 'global' });
 							}
 						}
 					}