blob: 31fc373ac6ff64189a4fbfdb73a334afb9e204a6 [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 ],
55 filter: 'field'
Matteo Scandolo18adcb52016-04-14 12:06:50 -070056 };
57
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070058 // retrieving user list
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070059 Users.query().$promise
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070060 .then((users) => {
61 this.users = users;
62 })
63 .catch((e) => {
64 throw new Error(e);
65 });
66 }
67 };
68});