blob: a93f720da2837a3ae5cb4cc71719715640849d38 [file] [log] [blame]
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -07001'use strict';
2
3angular.module('xos.vpnDashboard', [
4 'ngResource',
5 'ngCookies',
6 'ngLodash',
7 'ui.router',
8 'xos.helpers'
9])
10.config(($stateProvider) => {
11 $stateProvider
Jeremy Moweryb1387d22016-03-01 08:30:30 -070012 .state('vpnList', {
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070013 url: '/',
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070014 template: '<vpn-list></vpn-list>'
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070015 });
16})
Jeremy Moweryc257c412016-03-01 19:15:40 -070017.config(($compileProvider) => {
18 $compileProvider.aHrefSanitizationWhitelist(
19 /^\s*(https?|ftp|mailto|tel|file|blob):/);
20})
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070021.service('Vpn', function($http, $q){
22
23 this.getVpnTenants = () => {
24 let deferred = $q.defer();
25
Jeremy Moweryc257c412016-03-01 19:15:40 -070026 $http.get('/xoslib/vpntenant/')
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070027 .then((res) => {
28 deferred.resolve(res.data)
29 })
30 .catch((e) => {
31 deferred.reject(e);
32 });
33
34 return deferred.promise;
Jeremy Moweryc770ba02016-02-25 18:14:03 -070035 }
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070036})
37.config(function($httpProvider){
38 $httpProvider.interceptors.push('NoHyperlinks');
39})
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070040.directive('vpnList', function(){
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070041 return {
42 restrict: 'E',
43 scope: {},
44 bindToController: true,
45 controllerAs: 'vm',
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070046 templateUrl: 'templates/vpn-list.tpl.html',
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070047 controller: function(Vpn){
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070048 Vpn.getVpnTenants()
Jeremy Mowerye84e3ee2016-02-28 22:21:54 -070049 .then((vpns) => {
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070050 this.vpns = vpns;
Jeremy Mowery37e4efe2016-03-02 00:01:25 -070051 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 Mowery6efeb7a2016-02-25 09:32:00 -070055 })
56 .catch((e) => {
57 throw new Error(e);
58 });
Jeremy Moweryc770ba02016-02-25 18:14:03 -070059 }
60 };
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070061});