blob: 4923b1cc9cd5b28caf0f07b7eb9877aef4b2c67a [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 Mowery98dd6c82016-02-25 11:25:53 -070012 .state('vpn-list', {
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})
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 Mowery98dd6c82016-02-25 11:25:53 -070036.directive('vpnList', function(){
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070037 return {
38 restrict: 'E',
39 scope: {},
40 bindToController: true,
41 controllerAs: 'vm',
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070042 templateUrl: 'templates/vpn-list.tpl.html',
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070043 controller: function(Vpn){
44 // retrieving user list
45 Vpn.getVpnTenants()
Jeremy Mowery98dd6c82016-02-25 11:25:53 -070046 .then((vpns) => {
47 this.vpns = vpns;
Jeremy Mowery6efeb7a2016-02-25 09:32:00 -070048 })
49 .catch((e) => {
50 throw new Error(e);
51 });
52 }
53 };
54});