blob: 1909cce2e3cd18c3a6f330e8e7f8de4770c2d467 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Matteo Scandoloce954e52015-11-04 11:31:05 +010019'use strict';
20
Matteo Scandoloe53ee052015-11-03 14:32:00 +010021angular.module('xos.<%= name %>', [
22 'ngResource',
Matteo Scandoloe53ee052015-11-03 14:32:00 +010023 'ngCookies',
Matteo Scandolo07760222015-11-06 09:34:03 +010024 'ui.router',
Matteo Scandolo3c217ad2015-11-05 16:02:11 +010025 'xos.helpers'
Matteo Scandoloe53ee052015-11-03 14:32:00 +010026])
Matteo Scandolo7db08432015-11-06 18:49:33 +010027.config(($stateProvider) => {
Matteo Scandolo07760222015-11-06 09:34:03 +010028 $stateProvider
29 .state('user-list', {
30 url: '/',
Matteo Scandoloe3bc18d2015-11-05 18:36:10 +010031 template: '<users-list></users-list>'
Matteo Scandolo07760222015-11-06 09:34:03 +010032 });
Matteo Scandoloe53ee052015-11-03 14:32:00 +010033})
Matteo Scandoloe53ee052015-11-03 14:32:00 +010034.config(function($httpProvider){
Matteo Scandolo2b626742015-11-04 16:03:59 +010035 $httpProvider.interceptors.push('NoHyperlinks');
Matteo Scandoloe53ee052015-11-03 14:32:00 +010036})
Matteo Scandolo3c217ad2015-11-05 16:02:11 +010037.directive('usersList', function(){
Matteo Scandoloe53ee052015-11-03 14:32:00 +010038 return {
39 restrict: 'E',
40 scope: {},
41 bindToController: true,
42 controllerAs: 'vm',
43 templateUrl: 'templates/users-list.tpl.html',
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070044 controller: function(Users){
Matteo Scandoloa3839e32016-04-28 16:20:53 -070045
46 this.tableConfig = {
47 columns: [
48 {
49 label: 'E-Mail',
50 prop: 'email'
51 },
52 {
53 label: 'First Name',
54 prop: 'firstname'
55 },
56 {
57 label: 'Last Name',
58 prop: 'lastname'
59 },
60 {
61 label: 'Created',
62 prop: 'created'
63 },
64 {
65 label: 'Is Admin',
66 prop: 'is_admin'
67 }
68 ]
69 };
70
Matteo Scandolo6be0cd22015-11-03 16:27:07 +010071 // retrieving user list
Matteo Scandolobd2e5cd2016-04-12 11:59:29 -070072 Users.query().$promise
Matteo Scandolo6be0cd22015-11-03 16:27:07 +010073 .then((users) => {
74 this.users = users;
75 })
76 .catch((e) => {
77 throw new Error(e);
78 });
Matteo Scandoloe53ee052015-11-03 14:32:00 +010079 }
80 };
81});