Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | angular.module('xos.vpnDashboard', [ |
| 4 | 'ngResource', |
| 5 | 'ngCookies', |
| 6 | 'ngLodash', |
| 7 | 'ui.router', |
| 8 | 'xos.helpers' |
| 9 | ]) |
| 10 | .config(($stateProvider) => { |
| 11 | $stateProvider |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 12 | .state('vpn-list', { |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 13 | url: '/', |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 14 | template: '<vpn-list></vpn-list>' |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 15 | }); |
| 16 | }) |
| 17 | .service('Vpn', function($http, $q){ |
| 18 | |
| 19 | this.getVpnTenants = () => { |
| 20 | let deferred = $q.defer(); |
| 21 | |
| 22 | $http.get('/xoslib/vpntenants/') |
| 23 | .then((res) => { |
| 24 | deferred.resolve(res.data) |
| 25 | }) |
| 26 | .catch((e) => { |
| 27 | deferred.reject(e); |
| 28 | }); |
| 29 | |
| 30 | return deferred.promise; |
| 31 | }; |
| 32 | }) |
| 33 | .config(function($httpProvider){ |
| 34 | $httpProvider.interceptors.push('NoHyperlinks'); |
| 35 | }) |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 36 | .directive('vpnList', function(){ |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 37 | return { |
| 38 | restrict: 'E', |
| 39 | scope: {}, |
| 40 | bindToController: true, |
| 41 | controllerAs: 'vm', |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 42 | templateUrl: 'templates/vpn-list.tpl.html', |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 43 | controller: function(Vpn){ |
| 44 | // retrieving user list |
| 45 | Vpn.getVpnTenants() |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 46 | .then((vpns) => { |
| 47 | this.vpns = vpns; |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 48 | }) |
| 49 | .catch((e) => { |
| 50 | throw new Error(e); |
| 51 | }); |
| 52 | } |
| 53 | }; |
| 54 | }); |