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/05/17 02:25:58 UTC
[incubator-trafficcontrol] 12/17: adds the ability to view all
users for a specific capability
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/incubator-trafficcontrol.git
commit 29cc4b3c4eef2737699c28c7ea2c86506139c76c
Author: Jeremy Mitchell <mi...@gmail.com>
AuthorDate: Fri May 4 11:19:09 2018 -0600
adds the ability to view all users for a specific capability
---
traffic_portal/app/src/app.js | 4 +-
.../edit/FormEditCapabilityController.js | 2 -
.../TableCapabilityUsersController.js | 47 ++++++++++++++++++++++
.../common/modules/table/capabilityUsers/index.js | 22 ++++++++++
.../table.capabilityUsers.tpl.html} | 29 +++++++------
.../TableRoleCapabilitiesController.js | 4 ++
.../table.roleCapabilities.tpl.html | 2 +-
.../modules/private/capabilities/users/index.js | 42 +++++++++++++++++++
8 files changed, 135 insertions(+), 17 deletions(-)
diff --git a/traffic_portal/app/src/app.js b/traffic_portal/app/src/app.js
index 9f5065d..32425b4 100644
--- a/traffic_portal/app/src/app.js
+++ b/traffic_portal/app/src/app.js
@@ -60,9 +60,10 @@ var trafficPortal = angular.module('trafficPortal', [
require('./modules/private/cacheChecks').name,
require('./modules/private/cacheStats').name,
require('./modules/private/capabilities').name,
- require('./modules/private/capabilities/new').name,
+ require('./modules/private/capabilities/new').name, // this must be defined before edit for the url matcher to work
require('./modules/private/capabilities/list').name,
require('./modules/private/capabilities/edit').name,
+ require('./modules/private/capabilities/users').name,
require('./modules/private/cdns').name,
require('./modules/private/cdns/config').name,
require('./modules/private/cdns/deliveryServices').name,
@@ -289,6 +290,7 @@ var trafficPortal = angular.module('trafficPortal', [
require('./common/modules/table/cacheGroupServers').name,
require('./common/modules/table/cacheGroupStaticDnsEntries').name,
require('./common/modules/table/capabilities').name,
+ require('./common/modules/table/capabilityUsers').name,
require('./common/modules/table/changeLogs').name,
require('./common/modules/table/asns').name,
require('./common/modules/table/cdns').name,
diff --git a/traffic_portal/app/src/common/modules/form/capability/edit/FormEditCapabilityController.js b/traffic_portal/app/src/common/modules/form/capability/edit/FormEditCapabilityController.js
index da933ab..60ca4fc 100644
--- a/traffic_portal/app/src/common/modules/form/capability/edit/FormEditCapabilityController.js
+++ b/traffic_portal/app/src/common/modules/form/capability/edit/FormEditCapabilityController.js
@@ -53,8 +53,6 @@ var FormEditCapabilityController = function(capability, $scope, $controller, $ui
};
$scope.viewUsers = function() {
- alert('viewUsers');
- return;
$location.path($location.path() + '/users');
};
diff --git a/traffic_portal/app/src/common/modules/table/capabilityUsers/TableCapabilityUsersController.js b/traffic_portal/app/src/common/modules/table/capabilityUsers/TableCapabilityUsersController.js
new file mode 100644
index 0000000..48b6372
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/table/capabilityUsers/TableCapabilityUsersController.js
@@ -0,0 +1,47 @@
+/*
+ * 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 TableCapabilityUsersController = function(capability, capUsers, $scope, $state, locationUtils) {
+
+ $scope.capability = capability;
+
+ $scope.capUsers = capUsers;
+
+ $scope.editUser = function(id) {
+ locationUtils.navigateToPath('/users/' + id);
+ };
+
+ $scope.refresh = function() {
+ $state.reload(); // reloads all the resolves for the view
+ };
+
+ $scope.navigateToPath = locationUtils.navigateToPath;
+
+ angular.element(document).ready(function () {
+ $('#capUsersTable').dataTable({
+ "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
+ "iDisplayLength": 25,
+ "aaSorting": []
+ });
+ });
+
+};
+
+TableCapabilityUsersController.$inject = ['capability', 'capUsers', '$scope', '$state', 'locationUtils'];
+module.exports = TableCapabilityUsersController;
diff --git a/traffic_portal/app/src/common/modules/table/capabilityUsers/index.js b/traffic_portal/app/src/common/modules/table/capabilityUsers/index.js
new file mode 100644
index 0000000..a1b336e
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/table/capabilityUsers/index.js
@@ -0,0 +1,22 @@
+
+/*
+ * 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.
+ */
+
+module.exports = angular.module('trafficPortal.table.capabilityUsers', [])
+ .controller('TableCapabilityUsersController', require('./TableCapabilityUsersController'));
diff --git a/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html b/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
similarity index 57%
copy from traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html
copy to traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
index c712622..50c6f2d 100644
--- a/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html
@@ -20,31 +20,34 @@ under the License.
<div class="x_panel">
<div class="x_title">
<ol class="breadcrumb pull-left">
- <li><a ng-click="navigateToPath('/roles')">Roles</a></li>
- <li><a ng-click="navigateToPath('/roles/' + role.id)">{{::role.name}}</a></li>
- <li class="active">Capabilities</li>
+ <li><a ng-click="navigateToPath('/capabilities')">Capabilities</a></li>
+ <li><a ng-click="navigateToPath('/capabilities/' + capability.id)">{{::capability.name}}</a></li>
+ <li class="active">Users</li>
</ol>
- <div class="pull-right" role="group">
- <button class="btn btn-primary" title="Add Capabilties to Role" ng-click="selectCapabilities()"><i class="fa fa-plus"></i></button>
+ <div class="pull-right">
<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="capabilitiesTable" class="table responsive-utilities jambo_table">
+ <table id="capUsersTable" class="table responsive-utilities jambo_table">
<thead>
<tr class="headings">
- <th>Name</th>
- <th style="text-align: right;">Actions</th>
+ <th>Full Name</th>
+ <th>Username</th>
+ <th>Email</th>
+ <th>Tenant</th>
+ <th>Role</th>
</tr>
</thead>
<tbody>
- <tr ng-repeat="c in ::role.capabilities">
- <td data-search="^{{::c}}$">{{::c}}</td>
- <td style="text-align: right;">
- <a class="link action-link" title="Remove Capability from Role" ng-click="confirmRemoveCapability(c, $event)"><i class="fa fa-sm fa-chain-broken"></i></a>
- </td>
+ <tr ng-click="editUser(u.id)" ng-repeat="u in ::capUsers">
+ <td data-search="^{{::u.fullName}}$">{{::u.fullName}}</td>
+ <td data-search="^{{::u.username}}$">{{::u.username}}</td>
+ <td data-search="^{{::u.email}}$">{{::u.email}}</td>
+ <td data-search="^{{::u.tenant}}$">{{::u.tenant}}</td>
+ <td data-search="^{{::u.rolename}}$">{{::u.rolename}}</td>
</tr>
</tbody>
</table>
diff --git a/traffic_portal/app/src/common/modules/table/roleCapabilities/TableRoleCapabilitiesController.js b/traffic_portal/app/src/common/modules/table/roleCapabilities/TableRoleCapabilitiesController.js
index 3e7623c..7b22658 100644
--- a/traffic_portal/app/src/common/modules/table/roleCapabilities/TableRoleCapabilitiesController.js
+++ b/traffic_portal/app/src/common/modules/table/roleCapabilities/TableRoleCapabilitiesController.js
@@ -21,6 +21,10 @@ var TableRoleCapabilitiesController = function(roles, $scope, $state, $uibModal,
$scope.role = roles[0];
+ $scope.editCapability = function(name) {
+ locationUtils.navigateToPath('/capabilities/' + name);
+ };
+
$scope.selectCapabilities = function() {
var modalInstance = $uibModal.open({
templateUrl: 'common/modules/table/roleCapabilities/table.assignCapabilities.tpl.html',
diff --git a/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html b/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html
index c712622..911bff1 100644
--- a/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html
+++ b/traffic_portal/app/src/common/modules/table/roleCapabilities/table.roleCapabilities.tpl.html
@@ -40,7 +40,7 @@ under the License.
</tr>
</thead>
<tbody>
- <tr ng-repeat="c in ::role.capabilities">
+ <tr ng-click="editCapability(c)" ng-repeat="c in ::role.capabilities">
<td data-search="^{{::c}}$">{{::c}}</td>
<td style="text-align: right;">
<a class="link action-link" title="Remove Capability from Role" ng-click="confirmRemoveCapability(c, $event)"><i class="fa fa-sm fa-chain-broken"></i></a>
diff --git a/traffic_portal/app/src/modules/private/capabilities/users/index.js b/traffic_portal/app/src/modules/private/capabilities/users/index.js
new file mode 100644
index 0000000..42f4d55
--- /dev/null
+++ b/traffic_portal/app/src/modules/private/capabilities/users/index.js
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+module.exports = angular.module('trafficPortal.private.capabilities.users', [])
+ .config(function($stateProvider, $urlRouterProvider) {
+ $stateProvider
+ .state('trafficPortal.private.capabilities.users', {
+ url: '/{capName}/users',
+ views: {
+ capabilitiesContent: {
+ templateUrl: 'common/modules/table/capabilityUsers/table.capabilityUsers.tpl.html',
+ controller: 'TableCapabilityUsersController',
+ resolve: {
+ capability: function($stateParams, capabilityService) {
+ return capabilityService.getCapability($stateParams.capName);
+ },
+ capUsers: function($stateParams, userService) {
+ return userService.getUsers({ capability: $stateParams.capName });
+ }
+ }
+ }
+ }
+ })
+ ;
+ $urlRouterProvider.otherwise('/');
+ });
--
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.