Matteo Scandolo | 8cc22e4 | 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 | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 27 | controller: function(Users){ |
Matteo Scandolo | 18adcb5 | 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 | a6a9e61 | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 36 | label: 'First Name', |
Matteo Scandolo | 18adcb5 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 37 | prop: 'firstname' |
| 38 | }, |
| 39 | { |
Matteo Scandolo | a6a9e61 | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 40 | label: 'Last Name', |
Matteo Scandolo | 18adcb5 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 41 | prop: 'lastname' |
| 42 | } |
| 43 | ], |
Matteo Scandolo | 9e6c6fc | 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 | a6a9e61 | 2016-04-14 16:52:13 -0700 | [diff] [blame] | 54 | ], |
Matteo Scandolo | 03e5960 | 2016-04-14 17:19:08 -0700 | [diff] [blame] | 55 | filter: 'field', |
Matteo Scandolo | cc6954e | 2016-04-15 12:20:14 -0700 | [diff] [blame] | 56 | order: true, |
| 57 | pagination: { |
Matteo Scandolo | d72d490 | 2016-04-15 13:00:01 -0700 | [diff] [blame^] | 58 | pageSize: 6 |
Matteo Scandolo | cc6954e | 2016-04-15 12:20:14 -0700 | [diff] [blame] | 59 | } |
Matteo Scandolo | 18adcb5 | 2016-04-14 12:06:50 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 62 | // retrieving user list |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 63 | Users.query().$promise |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 64 | .then((users) => { |
Matteo Scandolo | cc6954e | 2016-04-15 12:20:14 -0700 | [diff] [blame] | 65 | this.users = users.concat(users, users, users); |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 66 | }) |
| 67 | .catch((e) => { |
| 68 | throw new Error(e); |
| 69 | }); |
| 70 | } |
| 71 | }; |
| 72 | }); |