You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/templates/jlog/log_online.html

218 lines
9.0 KiB

10 years ago
{% extends 'base.html' %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<style>
.bootstrap-dialog-body {
background-color: rgba(0, 0, 0, 0);
}
.bootstrap-dialog-message {
background-color: rgba(0, 0, 0, 0);
}
10 years ago
.pre-class {
background-color: rgba(0, 0, 0, 1);
}
10 years ago
.modal-content {
background-color: rgba(0, 0, 0, 0.6);
}
.modal-dialog {
background-color: rgba(0, 0, 0, 0);
width: 800px;
}
.modal-body {
background-color: rgba(0, 0, 0, 0);
}
.modal-header {
background-color: #FFFFFF;
}
</style>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 鐢ㄦ埛鏃ュ織璇︾粏淇℃伅鍒楄〃 </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">鏈惎鐢 1</a>
</li>
<li><a href="#">鏈惎鐢 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="panel-options">
<ul class="nav nav-tabs">
<li class="active"><a href="/jlog/log_list/online/" class="text-center"><i class="fa fa-laptop"></i> 鍦ㄧ嚎 </a></li>
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 鍘嗗彶璁板綍 </a></li>
<li style="float: right">
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' type="button" class="btn btn-sm btn-primary" onclick="log_search()">
Search
</button>
</div>
</div>
</form>
</li>
</ul>
</div>
<br/>
<div class="tab-content">
<table class="table table-striped table-bordered table-hover ">
<thead>
<tr>
<th class="text-center"> 鐢ㄦ埛鍚 </th>
10 years ago
<th class="text-center"> 鎵灞為儴闂 </th>
10 years ago
<th class="text-center"> 鐧诲綍涓绘満 </th>
10 years ago
<th class="text-center"> 鏉ユ簮IP </th>
10 years ago
{% ifnotequal session_role_id 0 %}
<th class="text-center"> 瀹炴椂鐩戞帶 </th>
<th class="text-center"> 闃绘柇 </th>
{% endifnotequal %}
10 years ago
<th class="text-center"> 鐧诲綍鏃堕棿 </th>
</tr>
</thead>
<tbody>
{% for post in contacts.object_list %}
<tr class="gradeX">
<td id="username" class="text-center"> {{ post.user }} </td>
10 years ago
<td id="deptname" class="text-center"> {{ post.dept_name }} </td>
10 years ago
<td id="ip" class="text-center"> {{ post.host }} </td>
10 years ago
<td id="remote_ip" class="text-center"> {{ post.remote_ip }} </td>
10 years ago
{% ifnotequal session_role_id 0 %}
<td class="text-center"><a class="monitor" filename="{{ post.log_path }}"> 鐩戞帶 </a></td>
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="闃绘柇" onclick='cut("{{ post.pid }}")' /></td>
{% endifnotequal %}
10 years ago
<td class="text-center"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
10 years ago
<div class="col-sm-6"></div>
{% include 'paginator.html' %}
</div>
10 years ago
</div>
</div>
</div>
</div>
</div>
</div>
<script src="http://{{ web_socket_host }}/socket.io/socket.io.js"></script>
<script>
$.fn.webSocket = function(opt){
var st = {};
st = $.extend(st,opt);
var message = {};
var $this = $(this);
var genUid = function(){
return new Date().getTime()+""+Math.floor(Math.random()*899+100);
};
var init = function(e){
var socket = io.connect('ws://'+globalConfig.SOCKET_HOST);
var node = $(e.target);
message.id = genUid();
message.filename = node.attr('filename');
var username = $('#username')[0].innerText;
var ip = $('#ip')[0].innerText;
BootstrapDialog.show({message:function(){
10 years ago
var option, exsit_message;
10 years ago
var escapeString = function (html){
var elem = document.createElement('div')
var txt = document.createTextNode(html)
elem.appendChild(txt)
return elem.innerHTML;
}
var tag = $('<div id="log" style="height: 500px;overflow: auto;background-color: rgba(0, 0, 0, 0);"></div>');
//鍛婅瘔鏈嶅姟鍣ㄧ鏈夌敤鎴风櫥褰
socket.emit('login', {userid:message.id, filename:message.filename});
socket.on('message',function(obj){
10 years ago
option = obj.option;
console.log(option+'so')
exsit_message = obj.content;
console.log(obj.content)
10 years ago
//鍘婚櫎log涓殑棰滆壊鎺у埗瀛楃
var regx = /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/g;
// tag.append('<p>'+escapeString(obj.content.replace(regx,''))+'</p>');
10 years ago
if (option == 'new') {
10 years ago
// tag.append('<p style="margin: 2px">' + escapeString(obj.content) + '</p>');
tag.append('<p>'+escapeString(obj.content.replace(regx,' '))+'</p>');
10 years ago
} else if (option == 'exist') {
10 years ago
tag.append('<pre>' + exsit_message + '</pre>');
10 years ago
}
10 years ago
tag.animate({ scrollTop: tag[0].scrollHeight}, 1);
});
tag[0].style.color = "#00FF00";
return tag[0];
10 years ago
10 years ago
} ,
title:'Jumpserver瀹炴椂鐩戞帶 '+' 鐧诲綍鐢ㄦ埛鍚: '+'<span class="text-info">'+username+'</span>'+' 鐧诲綍涓绘満: '+'<span class="text-info">'+ip,
onhide:function(){
socket.emit('disconnect');
}});
}
$this.on("click",function(e){
init(e);
return false;
});
}
$('.log_command').on('click',function(){
var url = $(this).attr('href');
$.ajax({url:url,success:function(data){
BootstrapDialog.show({title:'鍛戒护缁熻',message:data});
}});
return false;
})
globalConfig = {
SOCKET_HOST: "{{ web_socket_host }}"
}
$(".monitor").webSocket()
function log_search(){
$.ajax({
type: "GET",
url: "/jlog/search/?env=online",
data: $("#search_form").serialize(),
success: function (data) {
$(".tab-content").html(data);
}
});
}
$("#search_input").keydown(function(e){
if(e.keyCode==13){
log_search()
}
})
function cut(num){
10 years ago
var g_url = "/jlog/log_kill/?id="+num;
10 years ago
$.ajax({
type: "GET",
url: g_url,
10 years ago
success: window.open("/jlog/log_list/online/", "_self"),
10 years ago
error: window.open(g_url, "_self")
10 years ago
});
}
</script>
{% endblock %}