Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | angular.module('xos.subscribers', [ |
| 4 | 'ngResource', |
| 5 | 'ngCookies', |
| 6 | 'ui.router', |
| 7 | 'xos.helpers' |
| 8 | ]) |
| 9 | .config(($stateProvider) => { |
| 10 | $stateProvider |
| 11 | .state('user-list', { |
| 12 | url: '/', |
| 13 | template: '<subscribers-list></subscribers-list>' |
| 14 | }); |
| 15 | }) |
| 16 | .config(function($httpProvider){ |
| 17 | $httpProvider.interceptors.push('NoHyperlinks'); |
| 18 | }) |
| 19 | .directive('subscribersList', function(){ |
| 20 | return { |
| 21 | restrict: 'E', |
| 22 | scope: {}, |
| 23 | bindToController: true, |
| 24 | controllerAs: 'vm', |
| 25 | templateUrl: 'templates/subscribers-list.tpl.html', |
| 26 | controller: function(Subscribers){ |
| 27 | |
| 28 | this.tableConfig = { |
| 29 | filter: 'field', |
| 30 | order: true, |
| 31 | pagination: { |
| 32 | pageSize: 10 |
| 33 | }, |
| 34 | columns: [ |
| 35 | { |
| 36 | label: 'Name', |
| 37 | prop: 'humanReadableName' |
| 38 | }, |
| 39 | { |
| 40 | label: 'Identity', |
| 41 | prop: 'identity', |
| 42 | type: 'object' |
| 43 | }, |
| 44 | { |
| 45 | label: 'Related Info', |
| 46 | prop: 'related', |
| 47 | type: 'object' |
| 48 | } |
| 49 | ] |
| 50 | }; |
| 51 | |
| 52 | this.smartTableConfig = { |
| 53 | resource: 'Subscribers' |
| 54 | }; |
| 55 | |
| 56 | // retrieving user list |
| 57 | Subscribers.query().$promise |
| 58 | .then((users) => { |
| 59 | this.users = users; |
| 60 | }) |
| 61 | .catch((e) => { |
| 62 | throw new Error(e); |
| 63 | }); |
| 64 | } |
| 65 | }; |
| 66 | }); |