Fix bugs
diff --git a/views/ngXosViews/vpnDashboard/src/js/main.js b/views/ngXosViews/vpnDashboard/src/js/main.js
index aee3bc7..b3b7f85 100644
--- a/views/ngXosViews/vpnDashboard/src/js/main.js
+++ b/views/ngXosViews/vpnDashboard/src/js/main.js
@@ -9,12 +9,12 @@
])
.config(($stateProvider) => {
$stateProvider
- .state('vpn-list', {
+ .state('vpnList', {
url: '/',
template: '<vpn-list></vpn-list>'
})
- .state('cleint-script', {
- url: '/client/:pk',
+ .state('clientScript', {
+ url: '/client/:tenantId',
template: '<client-script></client-script>'
});
})
@@ -33,10 +33,10 @@
return deferred.promise;
}
- this.getVpnTenants = (pk) => {
+ this.getVpnTenants = (tenantId) => {
let deferred = $q.defer();
- $http.get('/xoslib/clientscript/', {params: {pk: pk}})
+ $http.get('/xoslib/clientscript/', {params: {tenantId: tenantId}})
.then((res) => {
deferred.resolve(res.data)
})
@@ -73,14 +73,14 @@
return {
restrict: 'E',
scope: {
- pk: '=pk',
+ tenantId: '=tenantId',
},
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/client-script.tpl.html',
controller: function(Vpn){
// retrieving user list
- Vpn.getClientScript(pk)
+ Vpn.getClientScript(tenantId)
.then((script_location) => {
this.script_location = script_location;
})
diff --git a/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html b/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html
index 882f2eb..6810580 100644
--- a/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html
+++ b/views/ngXosViews/vpnDashboard/src/templates/client-script.tpl.html
@@ -1,4 +1,4 @@
-<a href="/static/vpn/{{ vm.script_location }}" download id="download" hidden></a>
+<a href="/static/vpn/{{ vm.script_location }}" download id="download" hidden>{{ vm.script_location }}</a>
<script>
-document.getElementById('download').click();
+// document.getElementById('download').click();
</script>
diff --git a/xos/core/xoslib/methods/vpnview.py b/xos/core/xoslib/methods/vpnview.py
index 9789604..f8983ab 100644
--- a/xos/core/xoslib/methods/vpnview.py
+++ b/xos/core/xoslib/methods/vpnview.py
@@ -19,5 +19,5 @@
def get(self, request, format=None):
if (not request.user.is_authenticated()):
raise PermissionDenied("You must be authenticated in order to use this API")
- pk = request.QUERY_PARAMS.get('pk', None)
- return Response(VPNTenant.get_tenant_objects().filter(pk=pk))
+ teant_id = request.QUERY_PARAMS.get('tenantId', None)
+ return Response(VPNTenant.get_tenant_objects().filter(pk=tenantId))
diff --git a/xos/services/vpn/admin.py b/xos/services/vpn/admin.py
index dbf0d1e..bec46aa 100644
--- a/xos/services/vpn/admin.py
+++ b/xos/services/vpn/admin.py
@@ -51,7 +51,7 @@
client_address (forms.GenericIPAddressField): The ip address on the VPN of the client.
is_persistent (forms.BooleanField): Determines if this Tenant keeps this connection alive through failures.
can_view_subnet (forms.BooleanField): Determines if this Tenant makes it's subnet available to the client.
- port_number (forms.PositiveIntegerField): The port to use for this Tenant.
+ port_number (forms.IntegerField): The port to use for this Tenant.
"""
creator = forms.ModelChoiceField(queryset=User.objects.all())
server_network = forms.GenericIPAddressField(
@@ -59,7 +59,7 @@
vpn_subnet = forms.GenericIPAddressField(protocol="IPv4", required=True)
is_persistent = forms.BooleanField(required=False)
clients_can_see_each_other = forms.BooleanField(required=False)
- port_number = forms.PositiveIntegerField(required=True)
+ port_number = forms.IntegerField(required=True)
def __init__(self, *args, **kwargs):
super(VPNTenantForm, self).__init__(*args, **kwargs)
@@ -99,12 +99,12 @@
'clients_can_see_each_other')
self.instance.port_number = self.cleaned_data.get('port_number')
- if (not self.instance.script):
- self.instance.script = str(time.time()) + ".vpn"
-
if (not self.instance.ca_crt):
self.instance.ca_crt = self.generate_ca_crt()
+ if (not self.instance.script):
+ self.instance.script = str(time.time()) + ".vpn"
+
return super(VPNTenantForm, self).save(commit=commit)
def generate_ca_crt(self):
@@ -125,7 +125,7 @@
fieldsets = [(None, {'fields': ['backend_status_text', 'kind',
'provider_service', 'instance', 'creator',
'server_network', 'vpn_subnet', 'is_persistent',
- 'clients_can_see_each_other'],
+ 'clients_can_see_each_other', 'port_number'],
'classes': ['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', 'instance')
form = VPNTenantForm
diff --git a/xos/services/vpn/models.py b/xos/services/vpn/models.py
index 1a81b5a..7e324af 100644
--- a/xos/services/vpn/models.py
+++ b/xos/services/vpn/models.py
@@ -145,8 +145,8 @@
"""string: the location of the client script that is generated when
this method is called.
"""
- script_name = time.time() + ".vpn"
- create_client_script(script_name)
+ script_name = str(time.time()) + ".vpn"
+ self.create_client_script(script_name)
return script_name
def create_client_script(self, script_name):