blob: 803f344d5f2980303f93dfa7ae23d9582a2603aa [file] [log] [blame]
Matteo Scandoloce954e52015-11-04 11:31:05 +01001'use strict';
2
Matteo Scandoloe53ee052015-11-03 14:32:00 +01003angular.module('xos.<%= name %>', [
4 'ngResource',
Matteo Scandoloe53ee052015-11-03 14:32:00 +01005 'ngCookies',
Matteo Scandolo07760222015-11-06 09:34:03 +01006 'ui.router',
Matteo Scandolo3c217ad2015-11-05 16:02:11 +01007 'xos.helpers'
Matteo Scandoloe53ee052015-11-03 14:32:00 +01008])
Matteo Scandolo7db08432015-11-06 18:49:33 +01009.config(($stateProvider) => {
Matteo Scandolo07760222015-11-06 09:34:03 +010010 $stateProvider
11 .state('user-list', {
12 url: '/',
Matteo Scandoloe3bc18d2015-11-05 18:36:10 +010013 template: '<users-list></users-list>'
Matteo Scandolo07760222015-11-06 09:34:03 +010014 });
Matteo Scandoloe53ee052015-11-03 14:32:00 +010015})
Matteo Scandoloe53ee052015-11-03 14:32:00 +010016.config(function($httpProvider){
Matteo Scandolo2b626742015-11-04 16:03:59 +010017 $httpProvider.interceptors.push('NoHyperlinks');
Matteo Scandoloe53ee052015-11-03 14:32:00 +010018})
Matteo Scandolo3c217ad2015-11-05 16:02:11 +010019.directive('usersList', function(){
Matteo Scandoloe53ee052015-11-03 14:32:00 +010020 return {
21 restrict: 'E',
22 scope: {},
23 bindToController: true,
24 controllerAs: 'vm',
25 templateUrl: 'templates/users-list.tpl.html',
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070026 controller: function(Users){
Matteo Scandoloa3839e32016-04-28 16:20:53 -070027
28 this.tableConfig = {
29 columns: [
30 {
31 label: 'E-Mail',
32 prop: 'email'
33 },
34 {
35 label: 'First Name',
36 prop: 'firstname'
37 },
38 {
39 label: 'Last Name',
40 prop: 'lastname'
41 },
42 {
43 label: 'Created',
44 prop: 'created'
45 },
46 {
47 label: 'Is Admin',
48 prop: 'is_admin'
49 }
50 ]
51 };
52
Matteo Scandolo6be0cd22015-11-03 16:27:07 +010053 // retrieving user list
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070054 Users.query().$promise
Matteo Scandolo6be0cd22015-11-03 16:27:07 +010055 .then((users) => {
56 this.users = users;
57 })
58 .catch((e) => {
59 throw new Error(e);
60 });
Matteo Scandoloe53ee052015-11-03 14:32:00 +010061 }
62 };
63});