You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/05/19 19:00:01 UTC

[1/2] incubator-trafficcontrol git commit: allows user to assign/unassign params from profile or cachegroup

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 08ae1af97 -> 7d9509fc0


allows user to assign/unassign params from profile or cachegroup


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/bf8c39e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/bf8c39e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/bf8c39e1

Branch: refs/heads/master
Commit: bf8c39e1e83811075c1ffe3cda7070e0bc780b8c
Parents: 08ae1af
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Thu May 18 20:34:23 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri May 19 12:59:28 2017 -0600

----------------------------------------------------------------------
 .../common/api/CacheGroupParameterService.js    | 28 +++++++-
 .../ui/app/src/common/api/ParameterService.js   |  8 +++
 .../src/common/api/ProfileParameterService.js   | 16 ++++-
 .../ui/app/src/common/api/ProfileService.js     |  5 ++
 .../form/parameter/form.parameter.tpl.html      |  3 +-
 .../TableCacheGroupParametersController.js      | 47 ++++++++++---
 ...TableCacheGroupParamsUnassignedController.js | 69 ++++++++++++++++++++
 .../modules/table/cacheGroupParameters/index.js |  3 +-
 .../table.cacheGroupParameters.tpl.html         |  4 +-
 .../table.cacheGroupParamsUnassigned.tpl.html   | 49 ++++++++++++++
 .../TableParamProfilesUnassignedController.js   | 69 ++++++++++++++++++++
 .../TableParameterProfilesController.js         | 35 +++++++++-
 .../modules/table/parameterProfiles/index.js    |  3 +-
 .../table.paramProfilesUnassigned.tpl.html      | 51 +++++++++++++++
 .../table.parameterProfiles.tpl.html            |  2 +-
 .../table/parameters/table.parameters.tpl.html  |  2 +-
 .../TableProfileParametersController.js         | 40 ++++++++++--
 .../TableProfileParamsUnassignedController.js   | 69 ++++++++++++++++++++
 .../modules/table/profileParameters/index.js    |  3 +-
 .../table.profileParameters.tpl.html            |  4 +-
 .../table.profileParamsUnassigned.tpl.html      | 49 ++++++++++++++
 21 files changed, 528 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/api/CacheGroupParameterService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupParameterService.js b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupParameterService.js
index 651385c..ee1da69 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/CacheGroupParameterService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/CacheGroupParameterService.js
@@ -17,13 +17,37 @@
  * under the License.
  */
 
-var CacheGroupParameterService = function(Restangular) {
+var CacheGroupParameterService = function(Restangular, messageModel, httpService, ENV) {
 
 	this.getCacheGroupParameters = function(cachegroupId) {
 		return Restangular.one('cachegroups', cachegroupId).getList('parameters')
 	};
 
+	this.unlinkCacheGroupParameter = function(cgId, paramId) {
+		return httpService.delete(ENV.api['root'] + 'cachegroupparameters/' + cgId + '/' + paramId)
+			.then(
+				function() {
+					messageModel.setMessages([ { level: 'success', text: 'Cachegroup and parameter were unlinked.' } ], false);
+				},
+				function(fault) {
+					messageModel.setMessages(fault.data.alerts, true);
+				}
+			);
+	};
+
+	this.linkCacheGroupParameters = function(cgParamMappings) {
+		return Restangular.service('cachegroupparameters').post(cgParamMappings)
+			.then(
+				function() {
+					messageModel.setMessages([ { level: 'success', text: 'Parameters linked to cache group' } ], false);
+				},
+				function(fault) {
+					messageModel.setMessages(fault.data.alerts, false);
+				}
+			);
+	};
+
 };
 
-CacheGroupParameterService.$inject = ['Restangular'];
+CacheGroupParameterService.$inject = ['Restangular', 'messageModel', 'httpService', 'ENV'];
 module.exports = CacheGroupParameterService;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js b/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
index 46a9b43..21223f2 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ParameterService.js
@@ -68,6 +68,14 @@ var ParameterService = function(Restangular, locationUtils, messageModel) {
         return Restangular.one('profiles', profileId).getList('parameters');
     };
 
+    this.getProfileUnassignedParams = function(profileId) {
+        return Restangular.one('profiles', profileId).getList('unassigned_parameters');
+    };
+
+    this.getCacheGroupUnassignedParams = function(cgId) {
+        return Restangular.one('cachegroups', cgId).getList('unassigned_parameters');
+    };
+
 };
 
 ParameterService.$inject = ['Restangular', 'locationUtils', 'messageModel'];

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/api/ProfileParameterService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ProfileParameterService.js b/traffic_ops/experimental/ui/app/src/common/api/ProfileParameterService.js
index bd24c1f..a81678d 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ProfileParameterService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ProfileParameterService.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-var ProfileParameterService = function(httpService, messageModel, ENV) {
+var ProfileParameterService = function(Restangular, httpService, messageModel, ENV) {
 
 	this.unlinkProfileParameter = function(profileId, paramId) {
 		return httpService.delete(ENV.api['root'] + 'profileparameters/' + profileId + '/' + paramId)
@@ -31,7 +31,19 @@ var ProfileParameterService = function(httpService, messageModel, ENV) {
 			);
 	};
 
+	this.linkProfileParameters = function(profileParamMappings) {
+		return Restangular.service('profileparameters').post(profileParamMappings)
+			.then(
+				function() {
+					messageModel.setMessages([ { level: 'success', text: 'Parameters linked to profile' } ], false);
+				},
+				function(fault) {
+					messageModel.setMessages(fault.data.alerts, false);
+				}
+			);
+	};
+
 };
 
-ProfileParameterService.$inject = ['httpService', 'messageModel', 'ENV'];
+ProfileParameterService.$inject = ['Restangular', 'httpService', 'messageModel', 'ENV'];
 module.exports = ProfileParameterService;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js b/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
index bbd3eb4..d7c9df9 100644
--- a/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
+++ b/traffic_ops/experimental/ui/app/src/common/api/ProfileService.js
@@ -68,6 +68,11 @@ var ProfileService = function(Restangular, locationUtils, messageModel) {
         return Restangular.one('parameters', paramId).getList('profiles');
     };
 
+    this.getParamUnassignedProfiles = function(paramId) {
+        return Restangular.one('parameters', paramId).getList('unassigned_profiles');
+    };
+
+
 };
 
 ProfileService.$inject = ['Restangular', 'locationUtils', 'messageModel'];

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/form/parameter/form.parameter.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/form/parameter/form.parameter.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/form/parameter/form.parameter.tpl.html
index 1958ce9..b05a89c 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/form/parameter/form.parameter.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/form/parameter/form.parameter.tpl.html
@@ -30,7 +30,8 @@ under the License.
                     <span class="caret"></span>
                 </button>
                 <ul class="dropdown-menu-right dropdown-menu" uib-dropdown-menu>
-                    <li role="menuitem"><a ng-click="viewCacheGroups()">View Cache Groups</a></li>
+                    <!--todo: show cache groups for a parameter-->
+                    <!--<li role="menuitem"><a ng-click="viewCacheGroups()">View Cache Groups</a></li>-->
                     <li role="menuitem"><a ng-click="viewProfiles()">View Profiles</a></li>
                 </ul>
             </div>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js
index 032154d..a50ae02 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParametersController.js
@@ -17,24 +17,55 @@
  * under the License.
  */
 
-var TableCacheGroupParametersController = function(cacheGroup, cacheGroupParameters, $scope, $state, locationUtils) {
+var TableCacheGroupParametersController = function(cacheGroup, cacheGroupParameters, $scope, $state, $uibModal, locationUtils, cacheGroupParameterService) {
 
 	$scope.cacheGroup = cacheGroup;
 
 	$scope.cacheGroupParameters = cacheGroupParameters;
 
-	$scope.addParameter = function() {
-		alert('not hooked up yet: add parameter to cache group');
-	};
-
-	$scope.removeParameter = function() {
-		alert('not hooked up yet: remove Parameter from cache group');
+	$scope.removeParameter = function(paramId) {
+		cacheGroupParameterService.unlinkCacheGroupParameter(cacheGroup.id, paramId)
+			.then(
+				function() {
+					$scope.refresh();
+				}
+			);
 	};
 
 	$scope.refresh = function() {
 		$state.reload(); // reloads all the resolves for the view
 	};
 
+	$scope.selectParams = function() {
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/table/cacheGroupParameters/table.cacheGroupParamsUnassigned.tpl.html',
+			controller: 'TableCacheGroupParamsUnassignedController',
+			size: 'lg',
+			resolve: {
+				cg: function() {
+					return cacheGroup;
+				},
+				parameters: function(parameterService) {
+					return parameterService.getCacheGroupUnassignedParams(cacheGroup.id);
+				}
+			}
+		});
+		modalInstance.result.then(function(selectedParams) {
+			var massagedArray = [];
+			for (i = 0; i < selectedParams.length; i++) {
+				massagedArray.push( { cacheGroupId: cacheGroup.id, parameterId: selectedParams[i] } );
+			}
+			cacheGroupParameterService.linkCacheGroupParameters(massagedArray)
+				.then(
+					function() {
+						$scope.refresh();
+					}
+				);
+		}, function () {
+			// do nothing
+		});
+	};
+
 	$scope.navigateToPath = locationUtils.navigateToPath;
 
 	angular.element(document).ready(function () {
@@ -47,5 +78,5 @@ var TableCacheGroupParametersController = function(cacheGroup, cacheGroupParamet
 
 };
 
-TableCacheGroupParametersController.$inject = ['cacheGroup', 'cacheGroupParameters', '$scope', '$state', 'locationUtils'];
+TableCacheGroupParametersController.$inject = ['cacheGroup', 'cacheGroupParameters', '$scope', '$state', '$uibModal', 'locationUtils', 'cacheGroupParameterService'];
 module.exports = TableCacheGroupParametersController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js
new file mode 100644
index 0000000..d7f0c9c
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/TableCacheGroupParamsUnassignedController.js
@@ -0,0 +1,69 @@
+/*
+ * 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 TableProfileParamsUnassignedController = function(cg, parameters, $scope, $uibModalInstance) {
+
+	var selectedParams = [];
+
+	$scope.cg = cg;
+
+	$scope.unassignedParams = parameters;
+
+	var addParam = function(paramId) {
+		if (_.indexOf(selectedParams, paramId) == -1) {
+			selectedParams.push(paramId);
+		}
+	};
+
+	var removeParam = function(paramId) {
+		selectedParams = _.without(selectedParams, paramId);
+	};
+
+	$scope.updateParams = function($event, paramId) {
+		var checkbox = $event.target;
+		if (checkbox.checked) {
+			addParam(paramId);
+		} else {
+			removeParam(paramId);
+		}
+	};
+
+	$scope.submit = function() {
+		$uibModalInstance.close(selectedParams);
+	};
+
+	$scope.cancel = function () {
+		$uibModalInstance.dismiss('cancel');
+	};
+
+	angular.element(document).ready(function () {
+		$('#cgParamsUnassignedTable').dataTable({
+			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
+			"iDisplayLength": 25,
+			"order": [[ 1, 'asc' ]],
+			"columnDefs": [
+				{ "width": "5%", "targets": 0 }
+			]
+		});
+	});
+
+};
+
+TableProfileParamsUnassignedController.$inject = ['cg', 'parameters', '$scope', '$uibModalInstance'];
+module.exports = TableProfileParamsUnassignedController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/index.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/index.js b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/index.js
index 0509780..0e93bc6 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/index.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/index.js
@@ -18,4 +18,5 @@
  */
 
 module.exports = angular.module('trafficOps.table.cacheGroupParameters', [])
-	.controller('TableCacheGroupParametersController', require('./TableCacheGroupParametersController'));
+	.controller('TableCacheGroupParametersController', require('./TableCacheGroupParametersController'))
+	.controller('TableCacheGroupParamsUnassignedController', require('./TableCacheGroupParamsUnassignedController'));

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParameters.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParameters.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParameters.tpl.html
index 6ab49f0..d8f51d1 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParameters.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParameters.tpl.html
@@ -25,7 +25,7 @@ under the License.
             <li class="active">Parameters</li>
         </ol>
         <div class="pull-right" role="group" ng-show="!settings.isNew">
-            <button class="btn btn-primary" title="Link Parameter to Cache Group" ng-click="addParameter()"><i class="fa fa-link"></i></button>
+            <button class="btn btn-primary" title="Link Parameter to Cache Group" ng-click="selectParams()"><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>
@@ -48,7 +48,7 @@ under the License.
                 <td>{{::parameter.name}}</td>
                 <td>{{::parameter.configFile}}</td>
                 <td>{{::parameter.value}}</td>
-                <td><button type="button" class="btn btn-link" title="Remove from Cache Group" ng-click="removeParameter()"><i class="fa fa-chain-broken"></i></button></td>
+                <td><button type="button" class="btn btn-link" title="Unlink Parameter from Cache Group" ng-click="removeParameter(parameter.id)"><i class="fa fa-chain-broken"></i></button></td>
             </tr>
             </tbody>
         </table>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParamsUnassigned.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParamsUnassigned.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParamsUnassigned.tpl.html
new file mode 100644
index 0000000..05ac1ed
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/cacheGroupParameters/table.cacheGroupParamsUnassigned.tpl.html
@@ -0,0 +1,49 @@
+<!--
+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">Link Parameters to {{::cg.name}}</h3>
+</div>
+<div class="modal-body">
+    <table id="cgParamsUnassignedTable" class="table responsive-utilities jambo_table" style="table-layout:fixed; width:100%;">
+        <thead>
+        <tr class="headings">
+            <th></th>
+            <th>name</th>
+            <th>configFile</th>
+            <th>value</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr ng-repeat="parameter in ::unassignedParams">
+            <td><input type="checkbox" ng-click="updateParams($event, parameter.id)"></td>
+            <td>{{::parameter.name}}</td>
+            <td>{{::parameter.configFile}}</td>
+            <td>{{::parameter.value}}</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>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParamProfilesUnassignedController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParamProfilesUnassignedController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParamProfilesUnassignedController.js
new file mode 100644
index 0000000..2aa585b
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParamProfilesUnassignedController.js
@@ -0,0 +1,69 @@
+/*
+ * 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 TableParamProfilesUnassignedController = function(parameter, profiles, $scope, $uibModalInstance) {
+
+	var selectedProfiles = [];
+
+	$scope.parameter = parameter;
+
+	$scope.unassignedProfiles = profiles;
+
+	var addProfile = function(profileId) {
+		if (_.indexOf(selectedProfiles, profileId) == -1) {
+			selectedProfiles.push(profileId);
+		}
+	};
+
+	var removeProfile = function(profileId) {
+		selectedProfiles = _.without(selectedProfiles, profileId);
+	};
+
+	$scope.updateProfiles = function($event, profileId) {
+		var checkbox = $event.target;
+		if (checkbox.checked) {
+			addProfile(profileId);
+		} else {
+			removeProfile(profileId);
+		}
+	};
+
+	$scope.submit = function() {
+		$uibModalInstance.close(selectedProfiles);
+	};
+
+	$scope.cancel = function () {
+		$uibModalInstance.dismiss('cancel');
+	};
+
+	angular.element(document).ready(function () {
+		$('#paramProfilesUnassignedTable').dataTable({
+			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
+			"iDisplayLength": 25,
+			"order": [[ 1, 'asc' ]],
+			"columnDefs": [
+				{ "width": "5%", "targets": 0 }
+			]
+		});
+	});
+
+};
+
+TableParamProfilesUnassignedController.$inject = ['parameter', 'profiles', '$scope', '$uibModalInstance'];
+module.exports = TableParamProfilesUnassignedController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
index dfc1e38..c6eaf07 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-var TableParameterProfilesController = function(parameter, parameterProfiles, $scope, $state, locationUtils, profileParameterService) {
+var TableParameterProfilesController = function(parameter, parameterProfiles, $scope, $state, $uibModal, locationUtils, profileParameterService) {
 
 	$scope.parameter = parameter;
 
@@ -40,6 +40,37 @@ var TableParameterProfilesController = function(parameter, parameterProfiles, $s
 		$state.reload(); // reloads all the resolves for the view
 	};
 
+	$scope.selectProfiles = function() {
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/table/parameterProfiles/table.paramProfilesUnassigned.tpl.html',
+			controller: 'TableParamProfilesUnassignedController',
+			size: 'lg',
+			resolve: {
+				parameter: function() {
+					return parameter;
+				},
+				profiles: function(profileService) {
+					return profileService.getParamUnassignedProfiles(parameter.id);
+				}
+			}
+		});
+		modalInstance.result.then(function(selectedProfiles) {
+			var massagedArray = [];
+			for (i = 0; i < selectedProfiles.length; i++) {
+				massagedArray.push( { parameterId: parameter.id, profileId: selectedProfiles[i] } );
+			}
+			profileParameterService.linkProfileParameters(massagedArray)
+				.then(
+					function() {
+						$scope.refresh();
+					}
+				);
+		}, function () {
+			// do nothing
+		});
+	};
+
+
 	$scope.navigateToPath = locationUtils.navigateToPath;
 
 	angular.element(document).ready(function () {
@@ -52,5 +83,5 @@ var TableParameterProfilesController = function(parameter, parameterProfiles, $s
 
 };
 
-TableParameterProfilesController.$inject = ['parameter', 'parameterProfiles', '$scope', '$state', 'locationUtils', 'profileParameterService'];
+TableParameterProfilesController.$inject = ['parameter', 'parameterProfiles', '$scope', '$state', '$uibModal', 'locationUtils', 'profileParameterService'];
 module.exports = TableParameterProfilesController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/index.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/index.js b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/index.js
index b5b0968..a1a46c8 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/index.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/index.js
@@ -18,4 +18,5 @@
  */
 
 module.exports = angular.module('trafficOps.table.parameterProfiles', [])
-	.controller('TableParameterProfilesController', require('./TableParameterProfilesController'));
+	.controller('TableParameterProfilesController', require('./TableParameterProfilesController'))
+	.controller('TableParamProfilesUnassignedController', require('./TableParamProfilesUnassignedController'));

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.paramProfilesUnassigned.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.paramProfilesUnassigned.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.paramProfilesUnassigned.tpl.html
new file mode 100644
index 0000000..f24e240
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.paramProfilesUnassigned.tpl.html
@@ -0,0 +1,51 @@
+<!--
+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">Link Profiles to {{::parameter.name}}</h3>
+</div>
+<div class="modal-body">
+    <table id="paramProfilesUnassignedTable" class="table responsive-utilities jambo_table" style="table-layout:fixed; width:100%;">
+        <thead>
+        <tr class="headings">
+            <th></th>
+            <th>name</th>
+            <th>description</th>
+            <th>type</th>
+            <th>cdn</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr ng-repeat="profile in ::unassignedProfiles">
+            <td><input type="checkbox" ng-click="updateProfiles($event, profile.id)"></td>
+            <td>{{::profile.name}}</td>
+            <td>{{::profile.description}}</td>
+            <td>{{::profile.type}}</td>
+            <td>{{::profile.cdnName}}</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>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.parameterProfiles.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.parameterProfiles.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.parameterProfiles.tpl.html
index 51f00e8..a455aac 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.parameterProfiles.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameterProfiles/table.parameterProfiles.tpl.html
@@ -25,7 +25,7 @@ under the License.
             <li class="active">Profiles</li>
         </ol>
         <div class="pull-right">
-            <button class="btn btn-primary" title="Link Profile to Parameter" ng-click="addProfile()"><i class="fa fa-link"></i></button>
+            <button class="btn btn-primary" title="Link Profile to Parameter" ng-click="selectProfiles()"><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>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/parameters/table.parameters.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/parameters/table.parameters.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/parameters/table.parameters.tpl.html
index 059efd1..6ac3799 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/parameters/table.parameters.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/parameters/table.parameters.tpl.html
@@ -30,7 +30,7 @@ under the License.
     </div>
     <div class="x_content">
         <br>
-        <table id="parametersTable" class="table responsive-utilities jambo_table">
+        <table id="parametersTable" class="table responsive-utilities jambo_table" >
             <thead>
                 <tr class="headings">
                     <th>id</th>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParametersController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
index 7db062c..33a6c67 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
@@ -17,16 +17,12 @@
  * under the License.
  */
 
-var TableProfileParametersController = function(profile, profileParameters, $scope, $state, locationUtils, profileParameterService) {
+var TableProfileParametersController = function(profile, profileParameters, $scope, $state, $uibModal, locationUtils, profileParameterService) {
 
 	$scope.profile = profile;
 
 	$scope.profileParameters = profileParameters;
 
-	$scope.addParameter = function() {
-		alert('not hooked up yet: add parameter to profile');
-	};
-
 	$scope.removeParameter = function(paramId) {
 		profileParameterService.unlinkProfileParameter(profile.id, paramId)
 			.then(
@@ -40,10 +36,40 @@ var TableProfileParametersController = function(profile, profileParameters, $sco
 		$state.reload(); // reloads all the resolves for the view
 	};
 
+	$scope.selectParams = function() {
+		var modalInstance = $uibModal.open({
+			templateUrl: 'common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html',
+			controller: 'TableProfileParamsUnassignedController',
+			size: 'lg',
+			resolve: {
+				profile: function(parameterService) {
+					return profile;
+				},
+				parameters: function(parameterService) {
+					return parameterService.getProfileUnassignedParams(profile.id);
+				}
+			}
+		});
+		modalInstance.result.then(function(selectedParams) {
+			var massagedArray = [];
+			for (i = 0; i < selectedParams.length; i++) {
+				massagedArray.push( { profileId: profile.id, parameterId: selectedParams[i] } );
+			}
+			profileParameterService.linkProfileParameters(massagedArray)
+				.then(
+					function() {
+						$scope.refresh();
+					}
+				);
+		}, function () {
+			// do nothing
+		});
+	};
+
 	$scope.navigateToPath = locationUtils.navigateToPath;
 
 	angular.element(document).ready(function () {
-		$('#parametersTable').dataTable({
+		$('#profileParametersTable').dataTable({
 			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
 			"iDisplayLength": 100,
 			"aaSorting": []
@@ -52,5 +78,5 @@ var TableProfileParametersController = function(profile, profileParameters, $sco
 
 };
 
-TableProfileParametersController.$inject = ['profile', 'profileParameters', '$scope', '$state', 'locationUtils', 'profileParameterService'];
+TableProfileParametersController.$inject = ['profile', 'profileParameters', '$scope', '$state', '$uibModal', 'locationUtils', 'profileParameterService'];
 module.exports = TableProfileParametersController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParamsUnassignedController.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParamsUnassignedController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParamsUnassignedController.js
new file mode 100644
index 0000000..23cefcb
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/TableProfileParamsUnassignedController.js
@@ -0,0 +1,69 @@
+/*
+ * 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 TableProfileParamsUnassignedController = function(profile, parameters, $scope, $uibModalInstance) {
+
+	var selectedParams = [];
+
+	$scope.profile = profile;
+
+	$scope.unassignedParams = parameters;
+
+	var addParam = function(paramId) {
+		if (_.indexOf(selectedParams, paramId) == -1) {
+			selectedParams.push(paramId);
+		}
+	};
+
+	var removeParam = function(paramId) {
+		selectedParams = _.without(selectedParams, paramId);
+	};
+
+	$scope.updateParams = function($event, paramId) {
+		var checkbox = $event.target;
+		if (checkbox.checked) {
+			addParam(paramId);
+		} else {
+			removeParam(paramId);
+		}
+	};
+
+	$scope.submit = function() {
+		$uibModalInstance.close(selectedParams);
+	};
+
+	$scope.cancel = function () {
+		$uibModalInstance.dismiss('cancel');
+	};
+
+	angular.element(document).ready(function () {
+		$('#profileParamsUnassignedTable').dataTable({
+			"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
+			"iDisplayLength": 25,
+			"order": [[ 1, 'asc' ]],
+			"columnDefs": [
+				{ "width": "5%", "targets": 0 }
+			]
+		});
+	});
+
+};
+
+TableProfileParamsUnassignedController.$inject = ['profile', 'parameters', '$scope', '$uibModalInstance'];
+module.exports = TableProfileParamsUnassignedController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/index.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/index.js b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/index.js
index b5d6584..29521ee 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/index.js
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/index.js
@@ -18,4 +18,5 @@
  */
 
 module.exports = angular.module('trafficOps.table.profileParameters', [])
-	.controller('TableProfileParametersController', require('./TableProfileParametersController'));
+	.controller('TableProfileParametersController', require('./TableProfileParametersController'))
+	.controller('TableProfileParamsUnassignedController', require('./TableProfileParamsUnassignedController'));

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParameters.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParameters.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParameters.tpl.html
index 3a36e8b..966b8a5 100644
--- a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParameters.tpl.html
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParameters.tpl.html
@@ -25,14 +25,14 @@ under the License.
             <li class="active">Parameters</li>
         </ol>
         <div class="pull-right">
-            <button class="btn btn-primary" title="Link Parameter to Profile" ng-click="addParameter()"><i class="fa fa-link"></i></button>
+            <button class="btn btn-primary" title="Link Parameter to Profile" ng-click="selectParams()"><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>
     </div>
     <div class="x_content">
         <br>
-        <table id="parametersTable" class="table responsive-utilities jambo_table">
+        <table id="profileParametersTable" class="table responsive-utilities jambo_table">
             <thead>
             <tr class="headings">
                 <th>id</th>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/bf8c39e1/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html
new file mode 100644
index 0000000..34b2bdf
--- /dev/null
+++ b/traffic_ops/experimental/ui/app/src/common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html
@@ -0,0 +1,49 @@
+<!--
+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">Link Parameters to {{::profile.name}}</h3>
+</div>
+<div class="modal-body">
+    <table id="profileParamsUnassignedTable" class="table responsive-utilities jambo_table" style="table-layout:fixed; width:100%;">
+        <thead>
+        <tr class="headings">
+            <th></th>
+            <th>name</th>
+            <th>configFile</th>
+            <th>value</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr ng-repeat="parameter in ::unassignedParams">
+            <td><input type="checkbox" ng-click="updateParams($event, parameter.id)"></td>
+            <td>{{::parameter.name}}</td>
+            <td>{{::parameter.configFile}}</td>
+            <td>{{::parameter.value}}</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>



[2/2] incubator-trafficcontrol git commit: This closes #589.

Posted by da...@apache.org.
This closes #589.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7d9509fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7d9509fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7d9509fc

Branch: refs/heads/master
Commit: 7d9509fc04de01bb176293fb7b424a015f84fcaa
Parents: bf8c39e
Author: Dan Kirkwood <da...@gmail.com>
Authored: Fri May 19 12:59:47 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri May 19 12:59:47 2017 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------