Work on vpn view
diff --git a/views/ngXosViews/vpnDashboard/src/css/dev.css b/views/ngXosViews/vpnDashboard/src/css/dev.css
index 67c3992..4c504c9 100644
--- a/views/ngXosViews/vpnDashboard/src/css/dev.css
+++ b/views/ngXosViews/vpnDashboard/src/css/dev.css
@@ -9,3 +9,6 @@
display: table-cell;
padding: 5px;
}
+.header {
+ font-weight: bold;
+}
diff --git a/views/ngXosViews/vpnDashboard/src/js/main.js b/views/ngXosViews/vpnDashboard/src/js/main.js
index b3b7f85..7a576df 100644
--- a/views/ngXosViews/vpnDashboard/src/js/main.js
+++ b/views/ngXosViews/vpnDashboard/src/js/main.js
@@ -12,18 +12,18 @@
.state('vpnList', {
url: '/',
template: '<vpn-list></vpn-list>'
- })
- .state('clientScript', {
- url: '/client/:tenantId',
- template: '<client-script></client-script>'
});
})
+.config(($compileProvider) => {
+ $compileProvider.aHrefSanitizationWhitelist(
+ /^\s*(https?|ftp|mailto|tel|file|blob):/);
+})
.service('Vpn', function($http, $q){
this.getVpnTenants = () => {
let deferred = $q.defer();
- $http.get('/xoslib/vpntenants/')
+ $http.get('/xoslib/vpntenant/')
.then((res) => {
deferred.resolve(res.data)
})
@@ -33,19 +33,6 @@
return deferred.promise;
}
- this.getVpnTenants = (tenantId) => {
- let deferred = $q.defer();
-
- $http.get('/xoslib/clientscript/', {params: {tenantId: tenantId}})
- .then((res) => {
- deferred.resolve(res.data)
- })
- .catch((e) => {
- deferred.reject(e);
- });
-
- return deferred.promise;
- };
})
.config(function($httpProvider){
$httpProvider.interceptors.push('NoHyperlinks');
@@ -66,27 +53,12 @@
.catch((e) => {
throw new Error(e);
});
- }
- };
-})
-.directive('clientScript', function(){
- return {
- restrict: 'E',
- scope: {
- tenantId: '=tenantId',
- },
- bindToController: true,
- controllerAs: 'vm',
- templateUrl: 'templates/client-script.tpl.html',
- controller: function(Vpn){
- // retrieving user list
- Vpn.getClientScript(tenantId)
- .then((script_location) => {
- this.script_location = script_location;
- })
- .catch((e) => {
- throw new Error(e);
- });
+
+ this.getScriptLocation = function(vpn) {
+ var content = vpn.create_client_script();
+ var blob = new Blob([ content ], { type : 'text/plain' });
+ return (window.URL || window.webkitURL).createObjectURL( blob );
+ }
}
};
});
diff --git a/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html b/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html
deleted file mode 100644
index 6810580..0000000
--- a/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<a href="/static/vpn/{{ vm.script_location }}" download id="download" hidden>{{ vm.script_location }}</a>
-<script>
-// document.getElementById('download').click();
-</script>
diff --git a/views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html b/views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html
index 8d4df52..95d197f 100644
--- a/views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html
+++ b/views/ngXosViews/vpnDashboard/src/templates/vpn-list.tpl.html
@@ -1,17 +1,19 @@
-<div class="row">
- <h1>VPN List</h1>
-</div>
-<div class="row">
- <div class="cell">ID</div>
- <div class="cell">VPN Network</div>
- <div class="cell">VPN Subnet</div>
- <div class="cell">Script Link</div>
-</div>
-<div class="row" ng-repeat="vpn in vm.vpns">
- <div class="cell">{{vpn.instance.instance_id}}</div>
- <div class="cell">{{vpn.server_network}}</div>
- <div class="cell">{{vpn.vpn_subnet}}</div>
- <div class="cell">
- <a href="client/{{ vpn.pk }}/" target="_blank">Script</a>
+<div style="display: table;">
+ <div class="row">
+ <h1 class="cell">VPN List</h1>
+ </div>
+ <div class="row">
+ <div class="cell header">ID</div>
+ <div class="cell header">VPN Network</div>
+ <div class="cell header">VPN Subnet</div>
+ <div class="cell header">Script Link</div>
+ </div>
+ <div class="row" ng-repeat="vpn in vm.vpns">
+ <div class="cell">{{ vpn.id }}</div>
+ <div class="cell">{{ vpn.server_network }}</div>
+ <div class="cell">{{ vpn.vpn_subnet }}</div>
+ <div class="cell">
+ <a download="connect-{{ vpn.id }}.vpn" ng-href="{{ vm.getScriptLocation(vpn) }}">Script</a>
+ </div>
</div>
</div>