Merge pull request #113 from jumpserver/bug_fix_guang

fix(ws protocal): 修复所有ws自动获取
pull/114/head
ibuler 2016-03-03 18:09:26 +08:00
commit 6436fab837
3 changed files with 12 additions and 15 deletions

View File

@ -9,7 +9,6 @@ from django.http import HttpResponseNotFound
from jlog.log_api import renderTemplate
from jlog.models import Log, ExecLog, FileLog
from jumpserver.settings import WEB_SOCKET_URL
@require_role('admin')
@ -66,8 +65,6 @@ def log_list(request, offset):
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
web_monitor_url = '%s/monitor' % WEB_SOCKET_URL
web_kill_url = '/kill'
session_id = request.session.session_key
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))

View File

@ -36,6 +36,5 @@
} else {
$("#"+s1).addClass('active');
$('#'+s1+' .'+s2).addClass('active');
console.log(s1)
}
</script>

View File

@ -128,17 +128,17 @@
</div>
{#<script src="http://{{ web_socket_host }}/socket.io/socket.io.js"></script>#}
<script>
{# $(document).ready(function(){#}
{# $('.monitor').click(function(){#}
{# window.open('/jlog/monitor/', '监控', 'height=500, width=910, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');#}
{# })#}
{# });#}
function init(obj){
if (window.location.protocol == 'https:') {
var protocol = 'wss://';
} else {
var protocol = 'ws://';
}
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/monitor';
var file_path = obj.attr('file_path');
var wsUri = '{{ web_monitor_url }}';
var socket = new WebSocket(wsUri + '?file_path=' + file_path);
var socket = new WebSocket(endpoint + '?file_path=' + file_path);
var term = new Terminal({
cols: 80,
@ -165,7 +165,6 @@
BootstrapDialog.show({message: function(){
//服务器端认证
{# socket.send('login', {userid:message.id, filename:message.filename,username:username,seed:seed});#}
window.setTimeout(function(){
$('.terminal').detach().appendTo('#term');
socket.onmessage = function(evt){
@ -204,9 +203,11 @@
});
function cut(num, login_type){
console.log(login_type);
var protocol = window.location.protocol;
var endpoint = protocol + '//' + document.URL.match(RegExp('//(.*?)/'))[1] + '/kill';
if (login_type=='web'){
var g_url = '{{ web_kill_url }}' + '?id=' + num;
var g_url = endpoint + '?id=' + num;
console.log(g_url);
} else {
var g_url = "{% url 'log_kill' %}?id=" + num;
}