Matteo Scandolo | de76a45 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | angular.module('xos.sampleView', [ |
| 4 | 'ngResource', |
| 5 | 'ngCookies', |
| 6 | 'ngLodash', |
| 7 | 'ui.router', |
| 8 | 'xos.helpers' |
| 9 | ]) |
| 10 | .config(($stateProvider) => { |
| 11 | $stateProvider |
| 12 | .state('user-list', { |
| 13 | url: '/', |
| 14 | template: '<users-list></users-list>' |
| 15 | }); |
| 16 | }) |
| 17 | .config(function($httpProvider){ |
| 18 | $httpProvider.interceptors.push('NoHyperlinks'); |
| 19 | }) |
| 20 | .directive('usersList', function(){ |
| 21 | return { |
| 22 | restrict: 'E', |
| 23 | scope: {}, |
| 24 | bindToController: true, |
| 25 | controllerAs: 'vm', |
| 26 | templateUrl: 'templates/users-list.tpl.html', |
Matteo Scandolo | 2ef0cd7 | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 27 | controller: function(Users){ |
Matteo Scandolo | dcc6524 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 28 | |
| 29 | this.tableConfig = { |
| 30 | columns: [ |
| 31 | { |
| 32 | label: 'E-Mail', |
| 33 | prop: 'email' |
| 34 | }, |
| 35 | { |
Matteo Scandolo | 6a6586e | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 36 | label: 'First Name', |
Matteo Scandolo | dcc6524 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 37 | prop: 'firstname' |
| 38 | }, |
| 39 | { |
Matteo Scandolo | 6a6586e | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 40 | label: 'Last Name', |
Matteo Scandolo | dcc6524 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 41 | prop: 'lastname' |
| 42 | } |
| 43 | ], |
Matteo Scandolo | a7e64fd | 2016-04-14 14:59:09 -0700 | [diff] [blame] | 44 | classes: 'table table-striped table-condensed', |
| 45 | actions: [ |
| 46 | { |
| 47 | label: 'delete', |
| 48 | icon: 'remove', |
| 49 | cb: (user) => { |
| 50 | console.log(user); |
| 51 | }, |
| 52 | color: 'red' |
| 53 | } |
Matteo Scandolo | 6a6586e | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 54 | ], |
Matteo Scandolo | f32a2e9 | 2016-04-14 17:19:08 -0700 | [diff] [blame] | 55 | filter: 'field', |
Matteo Scandolo | 320ce2c | 2016-04-15 12:20:14 -0700 | [diff] [blame] | 56 | order: true, |
Matteo Scandolo | fb5937d | 2016-04-15 14:27:54 -0700 | [diff] [blame] | 57 | // pagination: { |
| 58 | // pageSize: 6 |
| 59 | // } |
Matteo Scandolo | dcc6524 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Matteo Scandolo | 918c0fa | 2016-04-15 16:43:48 -0700 | [diff] [blame] | 62 | this.alertConfig = { |
| 63 | type: 'danger', |
| 64 | closeBtn: true |
| 65 | } |
| 66 | |
| 67 | |
Matteo Scandolo | de76a45 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 68 | // retrieving user list |
Matteo Scandolo | 2ef0cd7 | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 69 | Users.query().$promise |
Matteo Scandolo | de76a45 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 70 | .then((users) => { |
Matteo Scandolo | fb5937d | 2016-04-15 14:27:54 -0700 | [diff] [blame] | 71 | this.users = users; |
Matteo Scandolo | de76a45 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 72 | }) |
| 73 | .catch((e) => { |
| 74 | throw new Error(e); |
| 75 | }); |
| 76 | } |
| 77 | }; |
| 78 | }); |