1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-10 01:17:59 +03:00

Restored autorun functionality

This commit is contained in:
Adolfo Gómez García 2015-04-24 17:32:15 +02:00
parent a1bd7274f4
commit 1ea3261b27
2 changed files with 24 additions and 13 deletions

View File

@ -186,7 +186,19 @@
{% block js %}
<script>
function launchURL(el) {
var $el = $(el);
url = $el.attr('data-href');
url = url != null ? url : $el.attr('href');
if ( url.substring(0, 7) == 'udsa://' ) {
uds.launch($el);
} else {
window.location = url;
}
}
$(function() {
var autorun = {% if autorun %}true{% else %}false{% endif %};
$('.with-tooltip').popover({container: 'body', trigger: 'hover', delay: { show: 500, hide: 100 }, placement: 'auto bottom'});
@ -196,16 +208,7 @@
var url, el;
event.preventDefault();
// check url
el = $(this)
url = el.attr('data-href');
url = url != null ? url : el.attr('href');
if ( url.substring(0, 7) == 'udsa://' ) {
uds.launch(el);
} else {
window.location = url;
}
launchURL(this);
return false;
}).on("mouseenter mouseleave", function (event) {
@ -248,6 +251,12 @@
return false;
});
if( autorun ) {
if( $('.service').length > 0)
launchURL($('.service')[0]);
autorun = false;
}
});
</script>
{% endblock %}

View File

@ -30,7 +30,7 @@
'''
from __future__ import unicode_literals
__updated__ = '2015-03-26'
__updated__ = '2015-04-24'
from django.shortcuts import render_to_response
from django.shortcuts import render
@ -172,11 +172,12 @@ def index(request):
services = sorted(services, key=lambda s: s['name'].upper())
autorun = False
if len(services) == 1 and GlobalConfig.AUTORUN_SERVICE.get(True) == '1' and len(services[0]['transports']) > 0:
if request.session.get('autorunDone', '0') == '0':
request.session['autorunDone'] = '1'
# TODO: Make this to redirect to uds link directly
return redirect('uds.web.views.service', idService=services[0]['id'], idTransport=services[0]['transports'][0]['id'])
autorun = True
# return redirect('uds.web.views.service', idService=services[0]['id'], idTransport=services[0]['transports'][0]['id'])
response = render_to_response(
theme.template('index.html'),
@ -185,6 +186,7 @@ def index(request):
'ip': request.ip,
'nets': nets,
'transports': validTrans,
'autorun': autorun
},
context_instance=RequestContext(request)
)