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 | 9fa1255 | 2016-03-01 08:30:30 -0700 | [diff] [blame] | 12 | .state('vpnList', { |
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 | }) |
Jeremy Mowery | bd3dfae | 2016-03-01 19:15:40 -0700 | [diff] [blame] | 17 | .config(($compileProvider) => { |
| 18 | $compileProvider.aHrefSanitizationWhitelist( |
| 19 | /^\s*(https?|ftp|mailto|tel|file|blob):/); |
| 20 | }) |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 21 | .service('Vpn', function($http, $q){ |
| 22 | |
| 23 | this.getVpnTenants = () => { |
| 24 | let deferred = $q.defer(); |
| 25 | |
Jeremy Mowery | bd3dfae | 2016-03-01 19:15:40 -0700 | [diff] [blame] | 26 | $http.get('/xoslib/vpntenant/') |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 27 | .then((res) => { |
| 28 | deferred.resolve(res.data) |
| 29 | }) |
| 30 | .catch((e) => { |
| 31 | deferred.reject(e); |
| 32 | }); |
| 33 | |
| 34 | return deferred.promise; |
Jeremy Mowery | 33e861a | 2016-02-25 18:14:03 -0700 | [diff] [blame] | 35 | } |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 36 | }) |
| 37 | .config(function($httpProvider){ |
| 38 | $httpProvider.interceptors.push('NoHyperlinks'); |
| 39 | }) |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 40 | .directive('vpnList', function(){ |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 41 | return { |
| 42 | restrict: 'E', |
| 43 | scope: {}, |
| 44 | bindToController: true, |
| 45 | controllerAs: 'vm', |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 46 | templateUrl: 'templates/vpn-list.tpl.html', |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 47 | controller: function(Vpn){ |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 48 | Vpn.getVpnTenants() |
Jeremy Mowery | 05cdae8 | 2016-02-28 22:21:54 -0700 | [diff] [blame] | 49 | .then((vpns) => { |
Jeremy Mowery | 42b2c01 | 2016-02-25 11:25:53 -0700 | [diff] [blame] | 50 | this.vpns = vpns; |
Jeremy Mowery | 47c9374 | 2016-03-02 00:01:25 -0700 | [diff] [blame] | 51 | for (var i = 0; i < this.vpns.length; i++) { |
| 52 | var blob = new Blob([ this.vpns[i].script_text ], { type : 'text/plain' }); |
| 53 | this.vpns[i].script_text = (window.URL || window.webkitURL).createObjectURL( blob ); |
| 54 | } |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 55 | }) |
| 56 | .catch((e) => { |
| 57 | throw new Error(e); |
| 58 | }); |
Jeremy Mowery | 33e861a | 2016-02-25 18:14:03 -0700 | [diff] [blame] | 59 | } |
| 60 | }; |
Jeremy Mowery | 159f97b | 2016-02-25 09:32:00 -0700 | [diff] [blame] | 61 | }); |