hooks up tenant table and form
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/f9e77e28 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/f9e77e28 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/f9e77e28 Branch: refs/heads/master Commit: f9e77e283f75d0a915ec292c926d0dd7ff1c9e62 Parents: 64efcec Author: Jeremy Mitchell <mitchell...@gmail.com> Authored: Wed Mar 22 21:11:18 2017 -0600 Committer: Dewayne Richardson <dewr...@apache.org> Committed: Thu Apr 6 14:41:34 2017 -0600 ---------------------------------------------------------------------- traffic_ops/experimental/ui/app/src/app.js | 1 + .../ui/app/src/common/api/TenantService.js | 8 +++--- .../modules/form/tenant/FormTenantController.js | 25 +++++++++++----- .../modules/form/tenant/form.tenant.tpl.html | 30 +++++++++++++++----- .../modules/navigation/navigation.tpl.html | 1 + .../table/tenants/table.tenants.tpl.html | 8 +++++- 6 files changed, 54 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/app.js ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/app.js b/traffic_ops/experimental/ui/app/src/app.js index d6877f8..05dce5b 100644 --- a/traffic_ops/experimental/ui/app/src/app.js +++ b/traffic_ops/experimental/ui/app/src/app.js @@ -239,6 +239,7 @@ var trafficOps = angular.module('trafficOps', [ require('./common/modules/table/serverDeliveryServices').name, require('./common/modules/table/statuses').name, require('./common/modules/table/statusServers').name, + require('./common/modules/table/tenants').name, require('./common/modules/table/types').name, require('./common/modules/table/typeCacheGroups').name, require('./common/modules/table/typeDeliveryServices').name, http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/common/api/TenantService.js ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/common/api/TenantService.js b/traffic_ops/experimental/ui/app/src/common/api/TenantService.js index edec73e..b350033 100644 --- a/traffic_ops/experimental/ui/app/src/common/api/TenantService.js +++ b/traffic_ops/experimental/ui/app/src/common/api/TenantService.js @@ -20,15 +20,15 @@ var TenantService = function(Restangular, messageModel) { this.getTenants = function(queryParams) { - return Restangular.all('tenant').getList(queryParams); + return Restangular.all('tenants').getList(queryParams); }; this.getTenant = function(id) { - return Restangular.one("tenant", id).get(); + return Restangular.one("tenants", id).get(); }; this.createTenant = function(tenant) { - return Restangular.service('tenant').post(tenant) + return Restangular.service('tenants').post(tenant) .then( function() { messageModel.setMessages([ { level: 'success', text: 'Tenant created' } ], true); @@ -52,7 +52,7 @@ var TenantService = function(Restangular, messageModel) { }; this.deleteTenant = function(id) { - return Restangular.one("tenant", id).remove() + return Restangular.one("tenants", id).remove() .then( function() { messageModel.setMessages([ { level: 'success', text: 'Tenant deleted' } ], true); http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/FormTenantController.js ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/FormTenantController.js b/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/FormTenantController.js index 0fc3096..4acf374 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/FormTenantController.js +++ b/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/FormTenantController.js @@ -17,15 +17,21 @@ * under the License. */ -var FormTenantController = function(tenant, $scope, formUtils, stringUtils, locationUtils) { +var FormTenantController = function(tenant, $scope, formUtils, locationUtils, tenantService) { - $scope.tenant = angular.copy(tenant); + var getTenants = function() { + tenantService.getTenants() + .then(function(result) { + $scope.tenants = result; + }); + }; - $scope.props = [ - { name: 'name', type: 'text', required: true, maxLength: 45 } - ]; + $scope.tenant = tenant; - $scope.labelize = stringUtils.labelize; + $scope.falseTrue = [ + { value: false, label: 'false' }, + { value: true, label: 'true' } + ]; $scope.navigateToPath = locationUtils.navigateToPath; @@ -33,7 +39,12 @@ var FormTenantController = function(tenant, $scope, formUtils, stringUtils, loca $scope.hasPropertyError = formUtils.hasPropertyError; + var init = function () { + getTenants(); + }; + init(); + }; -FormTenantController.$inject = ['tenant', '$scope', 'formUtils', 'stringUtils', 'locationUtils']; +FormTenantController.$inject = ['tenant', '$scope', 'formUtils', 'locationUtils', 'tenantService']; module.exports = FormTenantController; http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/form.tenant.tpl.html ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/form.tenant.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/form.tenant.tpl.html index d80aea0..8567a86 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/form.tenant.tpl.html +++ b/traffic_ops/experimental/ui/app/src/common/modules/form/tenant/form.tenant.tpl.html @@ -20,7 +20,7 @@ under the License. <div class="x_panel"> <div class="x_title"> <ol class="breadcrumb"> - <li><a ng-click="navigateToPath('/configure/tenants')">Tenants</a></li> + <li><a ng-click="navigateToPath('/admin/tenants')">Tenants</a></li> <li class="active">{{tenantName}}</li> </ol> <div class="clearfix"></div> @@ -28,13 +28,29 @@ under the License. <div class="x_content"> <br> <form name="tenantForm" class="form-horizontal form-label-left" novalidate> - <div class="form-group" ng-class="{'has-error': hasError(tenantForm[prop.name]), 'has-feedback': hasError(tenantForm[prop.name])}" ng-repeat="prop in props"> - <label class="control-label col-md-2 col-sm-2 col-xs-12">{{labelize(prop.name)}} <span ng-show="prop.required">*</span></label> + <div class="form-group" ng-class="{'has-error': hasError(tenantForm.name), 'has-feedback': hasError(tenantForm.name)}"> + <label class="control-label col-md-2 col-sm-2 col-xs-12">Name *</label> <div class="col-md-10 col-sm-10 col-xs-12"> - <input id="{{prop.name}}" name="{{prop.name}}" type="{{prop.type}}" class="form-control" ng-model="tenant[prop.name]" ng-readonly="prop.readonly" ng-required="prop.required" ng-maxlength="prop.maxLength" autofocus> - <small class="input-error" ng-show="hasPropertyError(tenantForm[prop.name], 'required')">Required</small> - <small class="input-error" ng-show="hasPropertyError(tenantForm[prop.name], 'maxlength')">Too Long</small> - <span ng-show="hasError(tenantForm[prop.name])" class="form-control-feedback"><i class="fa fa-times"></i></span> + <input id="name" name="name" type="text" class="form-control" ng-model="tenant.name" ng-required="true" ng-maxlength="45" autofocus> + <small class="input-error" ng-show="hasPropertyError(tenantForm.name, 'required')">Required</small> + <small class="input-error" ng-show="hasPropertyError(tenantForm.name, 'maxlength')">Too Long</small> + <span ng-show="hasError(tenantForm.name)" class="form-control-feedback"><i class="fa fa-times"></i></span> + </div> + </div> + <div class="form-group" ng-class="{'has-error': hasError(tenantForm.active), 'has-feedback': hasError(tenantForm.active)}"> + <label class="control-label col-md-2 col-sm-2 col-xs-12">Active *</label> + <div class="col-md-10 col-sm-10 col-xs-12"> + <select id="active" name="active" class="form-control" ng-model="tenant.active" ng-options="x.value as x.label for x in falseTrue" required></select> + <small class="input-error" ng-show="hasPropertyError(tenantForm.active, 'required')">Required</small> + </div> + </div> + <div class="form-group" ng-class="{'has-error': hasError(tenantForm.parentId), 'has-feedback': hasError(tenantForm.parentId)}"> + <label class="control-label col-md-2 col-sm-2 col-xs-12">Parent Tenant *</label> + <div class="col-md-10 col-sm-10 col-xs-12"> + <select id="parentId" name="parentId" class="form-control" ng-model="tenant.parentId" ng-options="tenant.id as tenant.name for tenant in tenants" required> + <option value="">Select...</option> + </select> + <small class="input-error" ng-show="hasPropertyError(tenantForm.parentId, 'required')">Required</small> </div> </div> <div class="modal-footer"> http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html index 0452689..6814241 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html +++ b/traffic_ops/experimental/ui/app/src/common/modules/navigation/navigation.tpl.html @@ -50,6 +50,7 @@ under the License. <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.admin.regions')}"><a ng-click="navigateToPath('/admin/regions')">Regions</a></li> <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.admin.statuses')}"><a ng-click="navigateToPath('/admin/statuses')">Statuses</a></li> <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.admin.types')}"><a ng-click="navigateToPath('/admin/types')">Types</a></li> + <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.admin.tenants')}"><a ng-click="navigateToPath('/admin/tenants')">Tenants</a></li> <li class="side-menu-category-item" ng-class="{'current-page': isState('trafficOps.private.admin.users')}"><a ng-click="navigateToPath('/admin/users')">Users</a></li> </ul> </li> http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f9e77e28/traffic_ops/experimental/ui/app/src/common/modules/table/tenants/table.tenants.tpl.html ---------------------------------------------------------------------- diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/tenants/table.tenants.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/tenants/table.tenants.tpl.html index f8155e4..40c19bc 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/table/tenants/table.tenants.tpl.html +++ b/traffic_ops/experimental/ui/app/src/common/modules/table/tenants/table.tenants.tpl.html @@ -23,8 +23,8 @@ under the License. <li class="active">Tenants</li> </ol> <div class="pull-right"> + <button class="btn btn-primary" ng-click="createTenant()"><i class="fa fa-plus"></i></button> <button class="btn btn-default" title="Refresh" ng-click="refresh()"><i class="fa fa-refresh"></i></button> - <button class="btn btn-primary" ng-click="createTenant()"><i class="fa fa-plus"></i> Create Tenant</button> </div> <div class="clearfix"></div> </div> @@ -34,11 +34,17 @@ under the License. <thead> <tr class="headings"> <th>id</th> + <th>name</th> + <th>active</th> + <th>parent</th> </tr> </thead> <tbody> <tr ng-click="editTenant(tenant.id)" ng-repeat="tenant in tenants"> <td>{{tenant.id}}</td> + <td>{{tenant.name}}</td> + <td>{{tenant.active}}</td> + <td>{{tenant.parentId}}</td> </tr> </tbody> </table>