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