blob: b00aa0b70dcc79b25a1879807e0a9f96be7fe8a7 [file] [log] [blame]
Matteo Scandolo8cc22e42016-04-12 09:00:04 -07001'use strict';
2
3angular.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 Scandolobd2e5cd2016-04-12 11:59:29 -070027 controller: function(Users){
Matteo Scandolo18adcb52016-04-14 12:06:50 -070028
29 this.tableConfig = {
30 columns: [
31 {
32 label: 'E-Mail',
33 prop: 'email'
34 },
35 {
Matteo Scandoloa6a9e612016-04-14 16:52:13 -070036 label: 'First Name',
Matteo Scandolo18adcb52016-04-14 12:06:50 -070037 prop: 'firstname'
38 },
39 {
Matteo Scandoloa6a9e612016-04-14 16:52:13 -070040 label: 'Last Name',
Matteo Scandolo18adcb52016-04-14 12:06:50 -070041 prop: 'lastname'
42 }
43 ],
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070044 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 Scandoloa6a9e612016-04-14 16:52:13 -070054 ],
Matteo Scandolo03e59602016-04-14 17:19:08 -070055 filter: 'field',
Matteo Scandolocc6954e2016-04-15 12:20:14 -070056 order: true,
Matteo Scandoloe15a8202016-04-15 14:27:54 -070057 // pagination: {
58 // pageSize: 6
59 // }
Matteo Scandolo18adcb52016-04-14 12:06:50 -070060 };
61
Matteo Scandolo74b6ef72016-04-15 16:43:48 -070062 this.alertConfig = {
63 type: 'danger',
64 closeBtn: true
65 }
66
67
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070068 // retrieving user list
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070069 Users.query().$promise
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070070 .then((users) => {
Matteo Scandoloe15a8202016-04-15 14:27:54 -070071 this.users = users;
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070072 })
73 .catch((e) => {
74 throw new Error(e);
75 });
76 }
77 };
78});