Matteo Scandolo | ce954e5 | 2015-11-04 11:31:05 +0100 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 3 | angular.module('xos.<%= name %>', [ |
| 4 | 'ngResource', |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 5 | 'ngCookies', |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 6 | 'ui.router', |
Matteo Scandolo | 3c217ad | 2015-11-05 16:02:11 +0100 | [diff] [blame] | 7 | 'xos.helpers' |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 8 | ]) |
Matteo Scandolo | 7db0843 | 2015-11-06 18:49:33 +0100 | [diff] [blame] | 9 | .config(($stateProvider) => { |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 10 | $stateProvider |
| 11 | .state('user-list', { |
| 12 | url: '/', |
Matteo Scandolo | e3bc18d | 2015-11-05 18:36:10 +0100 | [diff] [blame] | 13 | template: '<users-list></users-list>' |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 14 | }); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 15 | }) |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 16 | .config(function($httpProvider){ |
Matteo Scandolo | 2b62674 | 2015-11-04 16:03:59 +0100 | [diff] [blame] | 17 | $httpProvider.interceptors.push('NoHyperlinks'); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 18 | }) |
Matteo Scandolo | 3c217ad | 2015-11-05 16:02:11 +0100 | [diff] [blame] | 19 | .directive('usersList', function(){ |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 20 | return { |
| 21 | restrict: 'E', |
| 22 | scope: {}, |
| 23 | bindToController: true, |
| 24 | controllerAs: 'vm', |
| 25 | templateUrl: 'templates/users-list.tpl.html', |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 26 | controller: function(Users){ |
Matteo Scandolo | a3839e3 | 2016-04-28 16:20:53 -0700 | [diff] [blame] | 27 | |
| 28 | this.tableConfig = { |
| 29 | columns: [ |
| 30 | { |
| 31 | label: 'E-Mail', |
| 32 | prop: 'email' |
| 33 | }, |
| 34 | { |
| 35 | label: 'First Name', |
| 36 | prop: 'firstname' |
| 37 | }, |
| 38 | { |
| 39 | label: 'Last Name', |
| 40 | prop: 'lastname' |
| 41 | }, |
| 42 | { |
| 43 | label: 'Created', |
| 44 | prop: 'created' |
| 45 | }, |
| 46 | { |
| 47 | label: 'Is Admin', |
| 48 | prop: 'is_admin' |
| 49 | } |
| 50 | ] |
| 51 | }; |
| 52 | |
Matteo Scandolo | 6be0cd2 | 2015-11-03 16:27:07 +0100 | [diff] [blame] | 53 | // retrieving user list |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 54 | Users.query().$promise |
Matteo Scandolo | 6be0cd2 | 2015-11-03 16:27:07 +0100 | [diff] [blame] | 55 | .then((users) => { |
| 56 | this.users = users; |
| 57 | }) |
| 58 | .catch((e) => { |
| 59 | throw new Error(e); |
| 60 | }); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 61 | } |
| 62 | }; |
| 63 | }); |