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 | |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 28 | this.smartTableConfig = { |
| 29 | resource: 'Subscribers' |
| 30 | }; |
Matteo Scandolo | 741d6b4 | 2016-05-25 16:02:16 -0700 | [diff] [blame^] | 31 | |
| 32 | this.formConfig = { |
| 33 | exclude: ['password', 'last_login'], |
| 34 | formName: 'sampleForm', |
| 35 | actions: [ |
| 36 | { |
| 37 | label: 'Save', |
| 38 | icon: 'ok', // refers to bootstraps glyphicon |
| 39 | cb: (user) => { // receive the model |
| 40 | console.log(user); |
| 41 | }, |
| 42 | class: 'success' |
| 43 | } |
| 44 | ] |
| 45 | }; |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 46 | |
| 47 | // retrieving user list |
| 48 | Subscribers.query().$promise |
| 49 | .then((users) => { |
Matteo Scandolo | 741d6b4 | 2016-05-25 16:02:16 -0700 | [diff] [blame^] | 50 | this.users = users[0]; |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 51 | }) |
| 52 | .catch((e) => { |
| 53 | throw new Error(e); |
| 54 | }); |
| 55 | } |
| 56 | }; |
| 57 | }); |