[Update] 添加加入会话按钮

pull/3857/head
Bai 5 years ago
parent e9fc56c056
commit 29b099efc0

@ -243,6 +243,11 @@ class Session(OrgModelMixin):
return True
return False
def can_join(self):
if self.protocol in ['ssh', 'telnet', 'mysql']:
return True
return False
def save_to_storage(self, f):
local_path = self.get_local_path()
try:

@ -21,7 +21,7 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
"user_id", "asset_id", "system_user_id",
"login_from", "login_from_display", "remote_addr",
"is_success", "is_finished", "has_replay", "can_replay",
"protocol", "date_start", "date_end",
"can_join", "protocol", "date_start", "date_end",
"terminal",
]

@ -146,10 +146,15 @@ function initTable() {
.replace("sessionID", cellData)
.replace("terminalID", rowData.terminal)
}
var joinBtn = ' <a disabled data-session="sessionID" class="btn btn-xs btn-info btn-join" >{% trans "Join" %}</a>';
joinBtn = joinBtn.replace("sessionID", rowData.id);
if (rowData.can_join){
joinBtn = joinBtn.replace("disabled", "")
}
if (rowData.is_finished) {
btnGroup += replayBtn + downloadBtn
} else {
btnGroup += termBtn;
btnGroup += termBtn + joinBtn;
}
$(td).html(btnGroup);
}},
@ -246,6 +251,11 @@ $(document).ready(function() {
}
window.open(downloadUrl)
})
.on('click', '.btn-join', function () {
var sessionID = $(this).data("session");
var joinUrl = "/luna/join/?shareroom=" + sessionID;
window.open(joinUrl, "height=600, width=800, top=400, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no");
})
.on("click", '#session_table_filter input', function (e) {
e.preventDefault();
e.stopPropagation();

Loading…
Cancel
Save