From c79905cd922c594c0497a6ab604b2fb1b4f71d4f Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 10 Jul 2015 17:08:39 -0700 Subject: [PATCH] Refactoring views to use modals for create/edit instead of their own pages. --- .../authorities/authority/authority.js | 28 ++- .../authority/authorityWizard.tpl.html | 36 ++-- .../authorities/authority/options.tpl.html | 6 +- .../authorities/authority/tracking.tpl.html | 27 +-- .../app/angular/authorities/view/view.js | 34 +++- .../angular/authorities/view/view.tpl.html | 6 +- .../certificates/certificate/certificate.js | 27 +-- .../certificate/certificate.tpl.html | 20 -- .../certificate/certificateWizard.tpl.html | 40 ++-- .../certificate/destinations.tpl.html | 58 ++---- .../certificate/tracking.tpl.html | 4 +- .../certificates/certificate/upload.js | 19 +- .../certificates/certificate/upload.tpl.html | 173 ++++++------------ .../app/angular/certificates/services.js | 28 +-- .../app/angular/certificates/view/view.js | 30 ++- .../angular/certificates/view/view.tpl.html | 16 +- .../static/app/angular/components/filters.js | 4 +- lemur/static/app/angular/loadingModal.html | 6 - lemur/static/app/angular/roles/role/role.js | 38 ++-- .../app/angular/roles/role/role.tpl.html | 139 +++++++------- lemur/static/app/angular/roles/services.js | 4 +- lemur/static/app/angular/roles/view/view.js | 36 +++- .../app/angular/roles/view/view.tpl.html | 6 +- lemur/static/app/angular/users/services.js | 4 +- lemur/static/app/angular/users/user/user.js | 38 ++-- .../app/angular/users/user/user.tpl.html | 163 ++++++++--------- lemur/static/app/angular/users/view/view.js | 35 +++- .../app/angular/users/view/view.tpl.html | 6 +- lemur/static/app/angular/wizard.html | 19 +- lemur/static/app/index.html | 2 +- lemur/static/app/styles/lemur.css | 10 + 31 files changed, 533 insertions(+), 529 deletions(-) delete mode 100644 lemur/static/app/angular/certificates/certificate/certificate.tpl.html delete mode 100644 lemur/static/app/angular/loadingModal.html diff --git a/lemur/static/app/angular/authorities/authority/authority.js b/lemur/static/app/angular/authorities/authority/authority.js index 6129b250..e5f4ffc2 100644 --- a/lemur/static/app/angular/authorities/authority/authority.js +++ b/lemur/static/app/angular/authorities/authority/authority.js @@ -2,17 +2,6 @@ angular.module('lemur') - .config(function config($routeProvider) { - $routeProvider.when('/authorities/create', { - templateUrl: '/angular/authorities/authority/authorityWizard.tpl.html', - controller: 'AuthorityCreateController' - }); - $routeProvider.when('/authorities/:id/edit', { - templateUrl: '/angular/authorities/authority/authorityEdit.tpl.html', - controller: 'AuthorityEditController' - }); - }) - .controller('AuthorityEditController', function ($scope, $routeParams, AuthorityApi, AuthorityService, RoleService){ AuthorityApi.get($routeParams.id).then(function (authority) { AuthorityService.getRoles(authority); @@ -24,16 +13,21 @@ angular.module('lemur') $scope.roleService = RoleService; }) - .controller('AuthorityCreateController', function ($scope, $modal, AuthorityService, LemurRestangular, RoleService) { + .controller('AuthorityCreateController', function ($scope, $modalInstance, AuthorityService, LemurRestangular, RoleService, PluginService, WizardHandler) { $scope.authority = LemurRestangular.restangularizeElement(null, {}, 'authorities'); - $scope.save = function (authority) { - var loadingModal = $modal.open({backdrop: 'static', template: '', windowTemplateUrl: 'angular/loadingModal.html', size: 'large'}); - return AuthorityService.create(authority).then(function (response) { - loadingModal.close(); - }); + $scope.loading = false; + $scope.create = function (authority) { + WizardHandler.wizard().context.loading = true; + AuthorityService.create(authority).then(function (resposne) { + WizardHandler.wizard().context.loading = false; + $modalInstance.close(); + }) }; + PluginService.get('issuer').then(function (plugins) { + $scope.plugins = plugins; + }); $scope.roleService = RoleService; diff --git a/lemur/static/app/angular/authorities/authority/authorityWizard.tpl.html b/lemur/static/app/angular/authorities/authority/authorityWizard.tpl.html index 70cc0e5f..8eef96f1 100644 --- a/lemur/static/app/angular/authorities/authority/authorityWizard.tpl.html +++ b/lemur/static/app/angular/authorities/authority/authorityWizard.tpl.html @@ -1,17 +1,21 @@ -

CreateEdit Authority The nail that sticks out farthest gets hammered the hardest -
- - - - - - - - - - - - - - + + diff --git a/lemur/static/app/angular/authorities/authority/options.tpl.html b/lemur/static/app/angular/authorities/authority/options.tpl.html index 3cb0b912..26c6fdc6 100644 --- a/lemur/static/app/angular/authorities/authority/options.tpl.html +++ b/lemur/static/app/angular/authorities/authority/options.tpl.html @@ -15,7 +15,7 @@
@@ -69,10 +69,10 @@
- +
diff --git a/lemur/static/app/angular/authorities/authority/tracking.tpl.html b/lemur/static/app/angular/authorities/authority/tracking.tpl.html index 161ce2a0..5d9e9b58 100644 --- a/lemur/static/app/angular/authorities/authority/tracking.tpl.html +++ b/lemur/static/app/angular/authorities/authority/tracking.tpl.html @@ -31,37 +31,40 @@
+ ng-class="{'has-error': trackingForm.commonName.$invalid, 'has-success': !trackingForm.$invalid&&trackingForm.commonName.$dirty}">
-

You must enter a common name

+

You must enter a common name

-
+
- - - - + +

A start date is required!

+ + +
- +
- - - - + +

A end date is required!

+ + +
diff --git a/lemur/static/app/angular/authorities/view/view.js b/lemur/static/app/angular/authorities/view/view.js index 0b93466d..0208307f 100644 --- a/lemur/static/app/angular/authorities/view/view.js +++ b/lemur/static/app/angular/authorities/view/view.js @@ -9,7 +9,7 @@ angular.module('lemur') }); }) - .controller('AuthoritiesViewController', function ($scope, $q, AuthorityApi, AuthorityService, ngTableParams) { + .controller('AuthoritiesViewController', function ($scope, $q, $modal, AuthorityApi, AuthorityService, ngTableParams) { $scope.filter = {}; $scope.authoritiesTable = new ngTableParams({ page: 1, // show first page @@ -43,4 +43,36 @@ angular.module('lemur') params.settings().$scope.show_filter = !params.settings().$scope.show_filter; }; + $scope.edit = function (authorityId) { + var modalInstance = $modal.open({ + animation: true, + templateUrl: '/angular/authorities/authority/authorityWizard.tpl.html', + controller: 'AuthorityEditController', + size: 'lg', + resolve: { + editId: function () { + return authorityId; + } + } + }); + + modalInstance.result.then(function () { + $scope.authoritiesTable.reload(); + }); + + }; + + $scope.create = function () { + var modalInstance = $modal.open({ + animation: true, + controller: 'AuthorityCreateController', + templateUrl: '/angular/authorities/authority/authorityWizard.tpl.html', + size: 'lg' + }); + + modalInstance.result.then(function () { + $scope.authoritiesTable.reload(); + }); + + }; }); diff --git a/lemur/static/app/angular/authorities/view/view.tpl.html b/lemur/static/app/angular/authorities/view/view.tpl.html index 9bbbaeb7..f6a60c3a 100644 --- a/lemur/static/app/angular/authorities/view/view.tpl.html +++ b/lemur/static/app/angular/authorities/view/view.tpl.html @@ -5,7 +5,7 @@
- Create +
@@ -36,9 +36,9 @@ diff --git a/lemur/static/app/angular/certificates/certificate/certificate.js b/lemur/static/app/angular/certificates/certificate/certificate.js index 4815121e..c2c47f0f 100644 --- a/lemur/static/app/angular/certificates/certificate/certificate.js +++ b/lemur/static/app/angular/certificates/certificate/certificate.js @@ -1,18 +1,6 @@ 'use strict'; angular.module('lemur') - .config(function config($routeProvider) { - $routeProvider.when('/certificates/create', { - templateUrl: '/angular/certificates/certificate/certificateWizard.tpl.html', - controller: 'CertificateCreateController' - }); - - $routeProvider.when('/certificates/:id/edit', { - templateUrl: '/angular/certificates/certificate/edit.tpl.html', - controller: 'CertificateEditController' - }); - }) - .controller('CertificateEditController', function ($scope, $routeParams, CertificateApi, CertificateService, MomentService) { CertificateApi.get($routeParams.id).then(function (certificate) { $scope.certificate = certificate; @@ -23,13 +11,14 @@ angular.module('lemur') }) - .controller('CertificateCreateController', function ($scope, $modal, CertificateApi, CertificateService, AccountService, ELBService, AuthorityService, MomentService, LemurRestangular) { + .controller('CertificateCreateController', function ($scope, $modalInstance, CertificateApi, CertificateService, DestinationService, ELBService, AuthorityService, PluginService, MomentService, WizardHandler, LemurRestangular) { $scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates'); - $scope.save = function (certificate) { - var loadingModal = $modal.open({backdrop: 'static', template: '', windowTemplateUrl: 'angular/loadingModal.html', size: 'large'}); + $scope.create = function (certificate) { + WizardHandler.wizard().context.loading = true; CertificateService.create(certificate).then(function (response) { - loadingModal.close(); + WizardHandler.wizard().context.loading = false; + $modalInstance.close(); }); }; @@ -88,7 +77,11 @@ angular.module('lemur') }; + PluginService.get('destination').then(function (plugins) { + $scope.plugins = plugins; + }); + $scope.elbService = ELBService; $scope.authorityService = AuthorityService; - $scope.accountService = AccountService; + $scope.destinationService = DestinationService; }); diff --git a/lemur/static/app/angular/certificates/certificate/certificate.tpl.html b/lemur/static/app/angular/certificates/certificate/certificate.tpl.html deleted file mode 100644 index 73d63a26..00000000 --- a/lemur/static/app/angular/certificates/certificate/certificate.tpl.html +++ /dev/null @@ -1,20 +0,0 @@ -

Create a certificate encrypt all the things -

-
-
- Cancel -
-
-
-
- -
-
- -
diff --git a/lemur/static/app/angular/certificates/certificate/certificateWizard.tpl.html b/lemur/static/app/angular/certificates/certificate/certificateWizard.tpl.html index dbd7595f..a7e36c1f 100644 --- a/lemur/static/app/angular/certificates/certificate/certificateWizard.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/certificateWizard.tpl.html @@ -1,17 +1,23 @@ -

CreateEdit Certificate encrypt all the things -
- - - - - - - - - - - - - - -
+ + + + diff --git a/lemur/static/app/angular/certificates/certificate/destinations.tpl.html b/lemur/static/app/angular/certificates/certificate/destinations.tpl.html index 443d6fab..58d88dc7 100644 --- a/lemur/static/app/angular/certificates/certificate/destinations.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/destinations.tpl.html @@ -1,62 +1,28 @@ -

Destinations are purely optional, if you think the created certificate will be used in AWS select one or more accounts and Lemur will upload it for you.

-
-
+
- -
- - - + + +
{{ account.label }}{{ account.comments }}
{{ destination.label }}{{ destination.description }} - +
-
-
diff --git a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html index 4dab6044..8ceb50c0 100644 --- a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html @@ -47,7 +47,7 @@ Common Name
- +

You must enter a common name

@@ -65,7 +65,7 @@

- +
diff --git a/lemur/static/app/angular/certificates/certificate/upload.js b/lemur/static/app/angular/certificates/certificate/upload.js index de2c88b4..0bf57b4f 100644 --- a/lemur/static/app/angular/certificates/certificate/upload.js +++ b/lemur/static/app/angular/certificates/certificate/upload.js @@ -2,20 +2,16 @@ angular.module('lemur') - .config(function config($routeProvider) { - $routeProvider.when('/certificates/upload', { - templateUrl: '/angular/certificates/certificate/upload.tpl.html', - controller: 'CertificatesUploadController' - }); - }) - - .controller('CertificatesUploadController', function ($scope, CertificateService, LemurRestangular, AccountService, ELBService) { + .controller('CertificateUploadController', function ($scope, $modalInstance, CertificateService, LemurRestangular, DestinationService, ELBService, PluginService) { $scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates'); $scope.upload = CertificateService.upload; - $scope.accountService = AccountService; + $scope.destinationService = DestinationService; $scope.elbService = ELBService; + PluginService.get('destination').then(function (plugins) { + $scope.plugins = plugins; + }); $scope.attachELB = function (elb) { $scope.certificate.attachELB(elb); @@ -23,4 +19,9 @@ angular.module('lemur') $scope.certificate.elb.listeners = listeners; }); }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + }); diff --git a/lemur/static/app/angular/certificates/certificate/upload.tpl.html b/lemur/static/app/angular/certificates/certificate/upload.tpl.html index adfebba9..afefa5e3 100644 --- a/lemur/static/app/angular/certificates/certificate/upload.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/upload.tpl.html @@ -1,136 +1,71 @@ -

Upload a certificate encrypt all the things -

-
-
- Cancel -
-
-
-
-
- + diff --git a/lemur/static/app/angular/certificates/services.js b/lemur/static/app/angular/certificates/services.js index b5dd898e..bb7eba53 100644 --- a/lemur/static/app/angular/certificates/services.js +++ b/lemur/static/app/angular/certificates/services.js @@ -58,15 +58,15 @@ angular.module('lemur') removeCustom: function (index) { this.extensions.custom.splice(index, 1); }, - attachAccount: function (account) { - this.selectedAccount = null; - if (this.accounts === undefined) { - this.accounts = []; + attachDestination: function (destination) { + this.selectedDestination = null; + if (this.destinations === undefined) { + this.destinations = []; } - this.accounts.push(account); + this.destinations.push(destination); }, - removeAccount: function (index) { - this.accounts.splice(index, 1); + removeDestination: function (index) { + this.destinations.splice(index, 1); }, attachELB: function (elb) { this.selectedELB = null; @@ -99,13 +99,6 @@ angular.module('lemur') }); }; - CertificateService.getARNs = function (certificate) { - certificate.arns = []; - _.each(certificate.accounts, function (account) { - certificate.arns.push('arn:aws:iam::' + account.accountNumber + ':server-certificate/' + certificate.name); - }); - }; - CertificateService.create = function (certificate) { certificate.attachSubAltName(); return CertificateApi.post(certificate).then( @@ -191,10 +184,9 @@ angular.module('lemur') }); }; - CertificateService.getAccounts = function (certificate) { - certificate.getList('accounts').then(function (accounts) { - certificate.accounts = accounts; - CertificateService.getARNs(certificate); + CertificateService.getDestinations = function (certificate) { + certificate.getList('destinations').then(function (destinations) { + certificate.destinations = destinations; }); }; diff --git a/lemur/static/app/angular/certificates/view/view.js b/lemur/static/app/angular/certificates/view/view.js index eba4e63f..230f9181 100644 --- a/lemur/static/app/angular/certificates/view/view.js +++ b/lemur/static/app/angular/certificates/view/view.js @@ -9,7 +9,7 @@ angular.module('lemur') }); }) - .controller('CertificatesViewController', function ($q, $scope, CertificateApi, CertificateService, MomentService, ngTableParams) { + .controller('CertificatesViewController', function ($q, $scope, $modal, CertificateApi, CertificateService, MomentService, ngTableParams) { $scope.filter = {}; $scope.certificateTable = new ngTableParams({ page: 1, // show first page @@ -26,7 +26,7 @@ angular.module('lemur') // TODO we should attempt to resolve all of these in parallel _.each(data, function (certificate) { CertificateService.getDomains(certificate); - CertificateService.getAccounts(certificate); + CertificateService.getDestinations(certificate); CertificateService.getListeners(certificate); CertificateService.getAuthority(certificate); CertificateService.getCreator(certificate); @@ -60,4 +60,30 @@ angular.module('lemur') $scope.toggleFilter = function (params) { params.settings().$scope.show_filter = !params.settings().$scope.show_filter; }; + + $scope.create = function () { + var modalInstance = $modal.open({ + animation: true, + controller: 'CertificateCreateController', + templateUrl: '/angular/certificates/certificate/certificateWizard.tpl.html', + size: 'lg' + }); + + modalInstance.result.then(function () { + $scope.certificateTable.reload(); + }); + }; + + $scope.import = function () { + var modalInstance = $modal.open({ + animation: true, + controller: 'CertificateUploadController', + templateUrl: '/angular/certificates/certificate/upload.tpl.html', + size: 'lg' + }); + + modalInstance.result.then(function () { + $scope.certificateTable.reload(); + }); + }; }); diff --git a/lemur/static/app/angular/certificates/view/view.tpl.html b/lemur/static/app/angular/certificates/view/view.tpl.html index d7bac81e..abe3c5f3 100644 --- a/lemur/static/app/angular/certificates/view/view.tpl.html +++ b/lemur/static/app/angular/certificates/view/view.tpl.html @@ -5,14 +5,14 @@
@@ -30,9 +30,9 @@
  • {{ certificate.owner }}
  • - + @@ -106,7 +106,7 @@ -

    ARNs

    +

    ARNs

    • {{ arn }}
    diff --git a/lemur/static/app/angular/components/filters.js b/lemur/static/app/angular/components/filters.js index 96471a44..6229e25d 100644 --- a/lemur/static/app/angular/components/filters.js +++ b/lemur/static/app/angular/components/filters.js @@ -1,8 +1,8 @@ angular.module('lemur'). filter('titleCase', function () { return function (str) { - return (str === undefined || str === null) ? '' : str.replace(/_|-/, ' ').replace(/\w\S*/g, function (txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + return (str === undefined || str === null) ? '' : str.replace(/([A-Z])/g, ' $1').replace(/^./, function (txt) { + return txt.toUpperCase(); }); }; }); diff --git a/lemur/static/app/angular/loadingModal.html b/lemur/static/app/angular/loadingModal.html deleted file mode 100644 index 1f65a57e..00000000 --- a/lemur/static/app/angular/loadingModal.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/lemur/static/app/angular/roles/role/role.js b/lemur/static/app/angular/roles/role/role.js index fb8bbee4..2e977637 100644 --- a/lemur/static/app/angular/roles/role/role.js +++ b/lemur/static/app/angular/roles/role/role.js @@ -2,29 +2,37 @@ angular.module('lemur') - .config(function config($routeProvider) { - $routeProvider.when('/roles/create', { - templateUrl: '/angular/roles/role/role.tpl.html', - controller: 'RoleCreateController' - }); - $routeProvider.when('/roles/:id/edit', { - templateUrl: '/angular/roles/role/role.tpl.html', - controller: 'RoleEditController' - }); - }) - .controller('RoleEditController', function ($scope, $routeParams, RoleApi, RoleService, UserService) { - RoleApi.get($routeParams.id).then(function (role) { + .controller('RolesEditController', function ($scope, $modalInstance, RoleApi, RoleService, UserService, editId) { + RoleApi.get(editId).then(function (role) { $scope.role = role; RoleService.getUsers(role); }); - $scope.save = RoleService.update; + $scope.save = function (role) { + RoleService.update(role).then(function () { + $modalInstance.close(); + }); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + $scope.userService = UserService; $scope.roleService = RoleService; }) - .controller('RoleCreateController', function ($scope, RoleApi, RoleService, UserService, LemurRestangular ) { + .controller('RolesCreateController', function ($scope,$modalInstance, RoleApi, RoleService, UserService, LemurRestangular) { $scope.role = LemurRestangular.restangularizeElement(null, {}, 'roles'); $scope.userService = UserService; - $scope.save = RoleService.create; + + $scope.save = function (role) { + RoleService.create(role).then(function () { + $modalInstance.close(); + }); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; }); diff --git a/lemur/static/app/angular/roles/role/role.tpl.html b/lemur/static/app/angular/roles/role/role.tpl.html index d88e08d4..dc36bf19 100644 --- a/lemur/static/app/angular/roles/role/role.tpl.html +++ b/lemur/static/app/angular/roles/role/role.tpl.html @@ -1,85 +1,82 @@ -

    CreateEdit Role The nail that sticks out farthest gets hammered the hardest -

    -
    -
    - - Cancel -
    -
    -
    -
    -
    - -
    - -

    You must enter an role name

    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    + -
    - -
    - - - - - - -
    {{ user.username }} - -
    -
    -
    - -
    - +
    diff --git a/lemur/static/app/angular/roles/services.js b/lemur/static/app/angular/roles/services.js index 8d3afd56..84e972c5 100644 --- a/lemur/static/app/angular/roles/services.js +++ b/lemur/static/app/angular/roles/services.js @@ -38,7 +38,7 @@ angular.module('lemur') }; RoleService.create = function (role) { - RoleApi.post(role).then( + return RoleApi.post(role).then( function () { toaster.pop({ type: 'success', @@ -57,7 +57,7 @@ angular.module('lemur') }; RoleService.update = function (role) { - role.put().then( + return role.put().then( function () { toaster.pop({ type: 'success', diff --git a/lemur/static/app/angular/roles/view/view.js b/lemur/static/app/angular/roles/view/view.js index c79b3755..17d60ae4 100644 --- a/lemur/static/app/angular/roles/view/view.js +++ b/lemur/static/app/angular/roles/view/view.js @@ -9,7 +9,7 @@ angular.module('lemur') }); }) - .controller('RolesViewController', function ($scope, RoleApi, RoleService, ngTableParams) { + .controller('RolesViewController', function ($scope, $modal, RoleApi, RoleService, ngTableParams) { $scope.filter = {}; $scope.rolesTable = new ngTableParams({ page: 1, // show first page @@ -39,4 +39,38 @@ angular.module('lemur') params.settings().$scope.show_filter = !params.settings().$scope.show_filter; }; + + $scope.edit = function (roleId) { + var modalInstance = $modal.open({ + animation: true, + templateUrl: '/angular/roles/role/role.tpl.html', + controller: 'RolesEditController', + size: 'lg', + resolve: { + editId: function () { + return roleId; + } + } + }); + + modalInstance.result.then(function () { + $scope.rolesTable.reload(); + }); + + }; + + $scope.create = function () { + var modalInstance = $modal.open({ + animation: true, + controller: 'RolesCreateController', + templateUrl: '/angular/roles/role/role.tpl.html', + size: 'lg' + }); + + modalInstance.result.then(function () { + $scope.rolesTable.reload(); + }); + + }; + }); diff --git a/lemur/static/app/angular/roles/view/view.tpl.html b/lemur/static/app/angular/roles/view/view.tpl.html index 86258c57..90490de3 100644 --- a/lemur/static/app/angular/roles/view/view.tpl.html +++ b/lemur/static/app/angular/roles/view/view.tpl.html @@ -5,7 +5,7 @@
    - Create +
    @@ -24,9 +24,9 @@
    - + Remove diff --git a/lemur/static/app/angular/users/services.js b/lemur/static/app/angular/users/services.js index b1077b6f..3075beb3 100644 --- a/lemur/static/app/angular/users/services.js +++ b/lemur/static/app/angular/users/services.js @@ -50,7 +50,7 @@ angular.module('lemur') }; UserService.create = function (user) { - UserApi.post(user).then( + return UserApi.post(user).then( function () { toaster.pop({ type: 'success', @@ -69,7 +69,7 @@ angular.module('lemur') }; UserService.update = function (user) { - user.put().then( + return user.put().then( function () { toaster.pop({ type: 'success', diff --git a/lemur/static/app/angular/users/user/user.js b/lemur/static/app/angular/users/user/user.js index 009133cb..7a3524f2 100644 --- a/lemur/static/app/angular/users/user/user.js +++ b/lemur/static/app/angular/users/user/user.js @@ -2,19 +2,8 @@ angular.module('lemur') - .config(function config($routeProvider) { - $routeProvider.when('/users/create', { - templateUrl: '/angular/users/user/user.tpl.html', - controller: 'UsersCreateController' - }); - $routeProvider.when('/users/:id/edit', { - templateUrl: '/angular/users/user/user.tpl.html', - controller: 'UsersEditController' - }); - }) - - .controller('UsersEditController', function ($scope, $routeParams, UserApi, UserService, RoleService) { - UserApi.get($routeParams.id).then(function (user) { + .controller('UsersEditController', function ($scope, $modalInstance, UserApi, UserService, RoleService, editId) { + UserApi.get(editId).then(function (user) { UserService.getRoles(user); $scope.user = user; }); @@ -24,15 +13,36 @@ angular.module('lemur') $scope.rolePage = 1; + + $scope.save = function (user) { + UserService.update(user).then(function () { + $modalInstance.close(); + }); + } + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + $scope.loadMoreRoles = function () { $scope.rolePage += 1; UserService.loadMoreRoles($scope.user, $scope.rolePage); }; }) - .controller('UsersCreateController', function ($scope, UserService, LemurRestangular, RoleService) { + .controller('UsersCreateController', function ($scope, $modalInstance, UserService, LemurRestangular, RoleService) { $scope.user = LemurRestangular.restangularizeElement(null, {}, 'users'); $scope.save = UserService.create; $scope.roleService = RoleService; + $scope.create = function (user) { + UserService.create(user).then(function () { + $modalInstance.close(); + }); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + }); diff --git a/lemur/static/app/angular/users/user/user.tpl.html b/lemur/static/app/angular/users/user/user.tpl.html index 21ade85b..9b1aca52 100644 --- a/lemur/static/app/angular/users/user/user.tpl.html +++ b/lemur/static/app/angular/users/user/user.tpl.html @@ -1,89 +1,86 @@ -

    CreateEdit User what was your name again? -

    -
    -
    - Cancel -
    -
    -
    -
    -
    - -
    - -

    You must enter a username

    -
    -
    -
    - -
    - -

    You must enter an email

    -
    -
    -
    - -
    - -

    You must enter an password

    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - + - -
    - +
    diff --git a/lemur/static/app/angular/users/view/view.js b/lemur/static/app/angular/users/view/view.js index 71dc8ff6..104fc245 100644 --- a/lemur/static/app/angular/users/view/view.js +++ b/lemur/static/app/angular/users/view/view.js @@ -9,7 +9,7 @@ angular.module('lemur') }); }) - .controller('UsersViewController', function ($scope, UserApi, UserService, ngTableParams) { + .controller('UsersViewController', function ($scope, $modal, UserApi, UserService, ngTableParams) { $scope.filter = {}; $scope.usersTable = new ngTableParams({ page: 1, // show first page @@ -36,6 +36,39 @@ angular.module('lemur') }); }; + $scope.edit = function (userId) { + var modalInstance = $modal.open({ + animation: true, + templateUrl: '/angular/users/user/user.tpl.html', + controller: 'UsersEditController', + size: 'lg', + resolve: { + editId: function () { + return userId; + } + } + }); + + modalInstance.result.then(function () { + $scope.usersTable.reload(); + }); + + }; + + $scope.create = function () { + var modalInstance = $modal.open({ + animation: true, + controller: 'UsersCreateController', + templateUrl: '/angular/users/user/user.tpl.html', + size: 'lg' + }); + + modalInstance.result.then(function () { + $scope.usersTable.reload(); + }); + + }; + $scope.toggleFilter = function (params) { params.settings().$scope.show_filter = !params.settings().$scope.show_filter; }; diff --git a/lemur/static/app/angular/users/view/view.tpl.html b/lemur/static/app/angular/users/view/view.tpl.html index 41f91dea..b27b2c05 100644 --- a/lemur/static/app/angular/users/view/view.tpl.html +++ b/lemur/static/app/angular/users/view/view.tpl.html @@ -5,7 +5,7 @@
    - Create +
    @@ -29,9 +29,9 @@ diff --git a/lemur/static/app/angular/wizard.html b/lemur/static/app/angular/wizard.html index 56090a3f..1ff4b641 100644 --- a/lemur/static/app/angular/wizard.html +++ b/lemur/static/app/angular/wizard.html @@ -1,23 +1,12 @@
    -
    - -
    + -
    diff --git a/lemur/static/app/index.html b/lemur/static/app/index.html index 3a81560c..f8bd8abb 100644 --- a/lemur/static/app/index.html +++ b/lemur/static/app/index.html @@ -55,7 +55,7 @@
  • Domains
  • Roles
  • Users
  • -
  • Accounts
  • +
  • Destinations