Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 1 | |
| 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 Scandolo | ce954e5 | 2015-11-04 11:31:05 +0100 | [diff] [blame] | 19 | 'use strict'; |
| 20 | |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 21 | angular.module('xos.<%= name %>', [ |
| 22 | 'ngResource', |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 23 | 'ngCookies', |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 24 | 'ui.router', |
Matteo Scandolo | 3c217ad | 2015-11-05 16:02:11 +0100 | [diff] [blame] | 25 | 'xos.helpers' |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 26 | ]) |
Matteo Scandolo | 7db0843 | 2015-11-06 18:49:33 +0100 | [diff] [blame] | 27 | .config(($stateProvider) => { |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 28 | $stateProvider |
| 29 | .state('user-list', { |
| 30 | url: '/', |
Matteo Scandolo | e3bc18d | 2015-11-05 18:36:10 +0100 | [diff] [blame] | 31 | template: '<users-list></users-list>' |
Matteo Scandolo | 0776022 | 2015-11-06 09:34:03 +0100 | [diff] [blame] | 32 | }); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 33 | }) |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 34 | .config(function($httpProvider){ |
Matteo Scandolo | 2b62674 | 2015-11-04 16:03:59 +0100 | [diff] [blame] | 35 | $httpProvider.interceptors.push('NoHyperlinks'); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 36 | }) |
Matteo Scandolo | 3c217ad | 2015-11-05 16:02:11 +0100 | [diff] [blame] | 37 | .directive('usersList', function(){ |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 38 | return { |
| 39 | restrict: 'E', |
| 40 | scope: {}, |
| 41 | bindToController: true, |
| 42 | controllerAs: 'vm', |
| 43 | templateUrl: 'templates/users-list.tpl.html', |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 44 | controller: function(Users){ |
Matteo Scandolo | a3839e3 | 2016-04-28 16:20:53 -0700 | [diff] [blame] | 45 | |
| 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 Scandolo | 6be0cd2 | 2015-11-03 16:27:07 +0100 | [diff] [blame] | 71 | // retrieving user list |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 72 | Users.query().$promise |
Matteo Scandolo | 6be0cd2 | 2015-11-03 16:27:07 +0100 | [diff] [blame] | 73 | .then((users) => { |
| 74 | this.users = users; |
| 75 | }) |
| 76 | .catch((e) => { |
| 77 | throw new Error(e); |
| 78 | }); |
Matteo Scandolo | e53ee05 | 2015-11-03 14:32:00 +0100 | [diff] [blame] | 79 | } |
| 80 | }; |
| 81 | }); |