完成:RDP远程连接按钮+选项功能,同时调整了调用助手的参数(rdp_width, rdp_height, rdp_console)。

pull/105/head
Apex Liu 2017-12-18 03:27:00 +08:00
parent 0d5cf16331
commit c68bbc6f3f
14 changed files with 550 additions and 384 deletions

View File

@ -544,7 +544,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
}
// 判断参数是否正确
if (!jsRoot["teleport_ip"].isString() || !jsRoot["size"].isNumeric()
if (!jsRoot["teleport_ip"].isString()
|| !jsRoot["teleport_port"].isNumeric() || !jsRoot["remote_host_ip"].isString()
|| !jsRoot["session_id"].isString() || !jsRoot["protocol_type"].isNumeric() || !jsRoot["protocol_sub_type"].isNumeric()
)
@ -553,28 +553,15 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
return;
}
int pro_type = jsRoot["protocol_type"].asUInt();
int pro_sub = jsRoot["protocol_sub_type"].asInt();
ex_astr teleport_ip = jsRoot["teleport_ip"].asCString();
int teleport_port = jsRoot["teleport_port"].asUInt();
int windows_size = 3;
if (jsRoot["size"].isNull())
windows_size = 3;
else
windows_size = jsRoot["size"].asUInt();
int console = 0;
if (jsRoot["console"].isNull())
console = 0;
else
console = jsRoot["console"].asUInt();
ex_astr real_host_ip = jsRoot["remote_host_ip"].asCString();
ex_astr sid = jsRoot["session_id"].asCString();
int pro_type = jsRoot["protocol_type"].asUInt();
ex_wstr w_exe_path;
WCHAR w_szCommandLine[MAX_PATH] = { 0 };
@ -592,6 +579,40 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
if (pro_type == TP_PROTOCOL_TYPE_RDP)
{
int rdp_w = 800;
int rdp_h = 640;
bool rdp_console = false;
if (!jsRoot["rdp_width"].isNull()) {
if (jsRoot["rdp_width"].isNumeric()) {
rdp_w = jsRoot["rdp_width"].asUInt();
}
else {
_create_json_ret(buf, TPE_PARAM);
return;
}
}
if (!jsRoot["rdp_height"].isNull()) {
if (jsRoot["rdp_height"].isNumeric()) {
rdp_h = jsRoot["rdp_height"].asUInt();
}
else {
_create_json_ret(buf, TPE_PARAM);
return;
}
}
if (!jsRoot["rdp_console"].isNull()) {
if (jsRoot["rdp_console"].isBool()) {
rdp_console = jsRoot["rdp_console"].asBool();
}
else {
_create_json_ret(buf, TPE_PARAM);
return;
}
}
//==============================================
// RDP
//==============================================
@ -816,41 +837,25 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
ex_wstr rdp_name = g_cfg.rdp_name;
if (rdp_name == L"mstsc") {
int width = 800;
int higth = 600;
int width = 0;
int higth = 0;
int cx = 0;
int cy = 0;
int display = 1;
int iWidth = GetSystemMetrics(SM_CXSCREEN);
int iHeight = GetSystemMetrics(SM_CYSCREEN);
switch (windows_size)
{
case 0:
if (rdp_w == 0 || rdp_h == 0) {
//全屏
width = iWidth;
higth = iHeight;
display = 2;
break;
case 1:
width = 800;
higth = 600;
}
else {
width = rdp_w;
higth = rdp_h;
display = 1;
break;
case 2:
width = 1024;
higth = 768;
display = 1;
break;
case 3:
width = 1280;
higth = 1024;
display = 1;
break;
default:
width = 800;
higth = 600;
break;
}
cx = (iWidth - width) / 2;
@ -864,15 +869,16 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
cy = 0;
}
int split_pos = sid.length() - 2;
std::string real_sid = sid.substr(0, split_pos);
char* sz_console = "0";
if (rdp_console)
sz_console = "1";
char sz_rdp_file_content[4096] = { 0 };
sprintf_s(sz_rdp_file_content, rdp_content.c_str(),
console, display, width, higth
, cx, cy, cx + width + 20, cy + higth + 40
sz_console, display, width, higth
, cx, cy, cx + width + 100, cy + higth + 100
, teleport_ip.c_str(), teleport_port
, real_sid.c_str()
, sid.c_str()
);
char sz_file_name[MAX_PATH] = { 0 };
@ -884,10 +890,8 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
_create_json_ret(buf, TPE_FAILED);
return;
}
ex_wstr w_s_id;
ex_astr2wstr(real_sid, w_s_id);
ex_astr temp_host_ip = real_host_ip;// replace_all_distinct(real_host_ip, ("."), "-");
ex_astr temp_host_ip = real_host_ip;
ex_replace_all(temp_host_ip, ".", "-");
sprintf_s(sz_file_name, ("%s%s.rdp"), temp_path, temp_host_ip.c_str());
@ -908,28 +912,21 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
ex_replace_all(w_exe_path, _T("{tmp_rdp_file}"), tmp_rdp_file);
}
else if (g_cfg.rdp_name == L"freerdp") {
wchar_t* w_screen = NULL;
ex_wstr w_screen;
switch (windows_size)
{
case 0: //È«ÆÁ
if (rdp_w == 0 || rdp_h == 0) {
//È«ÆÁ
w_screen = _T("/f");
break;
case 2:
w_screen = _T("/size:1024x768");
break;
case 3:
w_screen = _T("/size:1280x1024");
break;
case 1:
default:
w_screen = _T("/size:800x600");
break;
}
else {
char sz_size[64] = {0};
ex_strformat(sz_size, 63, "/size:%dx%d", rdp_w, rdp_h);
ex_astr2wstr(sz_size, w_screen);
}
wchar_t* w_console = NULL;
if (console != 0)
if (rdp_console)
{
w_console = L"/admin";
}
@ -938,18 +935,6 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
w_console = L"";
}
int split_pos = sid.length() - 2;
std::string real_sid = sid.substr(0, split_pos);
std::string str_pwd_len = sid.substr(split_pos, sid.length());
int n_pwd_len = strtol(str_pwd_len.c_str(), NULL, 16);
n_pwd_len -= real_sid.length();
WCHAR w_szPwd[256] = { 0 };
for (int i = 0; i < n_pwd_len; i++)
{
w_szPwd[i] = '*';
}
ex_astr2wstr(real_sid, w_sid);
w_exe_path += L" /gdi:sw"; // 使用软件渲染gdi:hw使用硬件加速但是会出现很多黑块录像回放时又是正常的
w_exe_path += L" -grab-keyboard"; // 防止启动FreeRDP后失去本地键盘响应必须得先最小化一下FreeRDP窗口不过貌似不起作用

View File

@ -153,9 +153,9 @@ bool TsSessionManager::request_session(ex_astr& sid, TS_CONNECT_INFO* info)
if (info->protocol_type == TP_PROTOCOL_TYPE_RDP)
{
info->ref_count = 1; // 因为RDP连接之前可能会有很长时间用于确认是否连接、是否信任证书所以很容易超时我们认为将引用计数+1防止因超时被清除。
char szTmp[8] = { 0 };
snprintf(szTmp, 8, "%02X", (unsigned char)(info->acc_username.length() + info->acc_secret.length()));
sid += szTmp;
// char szTmp[8] = { 0 };
// snprintf(szTmp, 8, "%02X", (unsigned char)(info->acc_username.length() + info->acc_secret.length()));
// sid += szTmp;
}
return true;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -57,11 +57,8 @@ $app.init_sys_status_info = function (data) {
type: 'value',
axisLine: {show: false},
axisTick: {show: false},
// min: 0,
// max: 100,
boundaryGap: [0, '60%'],
boundaryGap: [0, '70%'],
axisLabel: {
margin: 5,
fontSize: 11,
fontFamily: 'Monaco, Lucida Console, Consolas, Courier',
formatter: function (value, index) {
@ -86,6 +83,7 @@ $app.init_sys_status_info = function (data) {
if (index === 0)
return '';
return tp_size2str(value, 1);
// return tp_echarts_size(value).val;
}
}
};
@ -126,7 +124,7 @@ $app.init_sys_status_info = function (data) {
var ret = [];
ret.push(params[0].name);
ret.push(params[0].seriesName + ': ' + params[0].value[1] + '%');
if(params.length > 1) {
if (params.length > 1) {
ret.push(params[1].seriesName + ': ' + params[1].value[1] + '%');
}
return ret.join('<br/>');
@ -298,7 +296,7 @@ $app.init_sys_status_info = function (data) {
var ret = [];
ret.push(params[0].name);
ret.push(params[0].seriesName + ': ' + tp_size2str(params[0].value[1], 2));
if(params.length > 1) {
if (params.length > 1) {
ret.push(params[1].seriesName + ': ' + tp_size2str(params[1].value[1], 2));
}
return ret.join('<br/>');
@ -371,7 +369,7 @@ $app.init_sys_status_info = function (data) {
var ret = [];
ret.push(params[0].name);
ret.push(params[0].seriesName + ': ' + tp_size2str(params[0].value[1], 2));
if(params.length > 1) {
if (params.length > 1) {
ret.push(params[1].seriesName + ': ' + tp_size2str(params[1].value[1], 2));
}
return ret.join('<br/>');

View File

@ -2,9 +2,8 @@
$app.on_init = function (cb_stack) {
$app.dom = {
btn_refresh_host: $('#btn-refresh-host'),
btn_add_user: $('#btn-add-host'),
chkbox_host_select_all: $('#table-host-select-all')
btn_refresh_host: $('#btn-refresh-host')
// box_rdp_option: $('#rdp-options')
};
cb_stack
@ -101,6 +100,8 @@ $app.create_controls = function (cb_stack) {
//-------------------------------
// 对话框
//-------------------------------
$app.dlg_rdp_options = $app.create_dlg_rdp_options();
cb_stack.add($app.dlg_rdp_options.init);
//-------------------------------
// 页面控件事件绑定
@ -109,19 +110,19 @@ $app.create_controls = function (cb_stack) {
$app.table_host.load_data();
});
// $app.dom.box_rdp_option.mouseleave(function(){
// console.log('---mouseleave');
// $app.dom.box_rdp_option.hide();
// });
cb_stack.exec();
};
$app.on_table_host_cell_created = function (tbl, row_id, col_key, cell_obj) {
// if (col_key === 'chkbox') {
// cell_obj.find('[data-check-box]').click(function () {
// $app.check_host_all_selected();
// });
// } else
if (col_key === 'action') {
// 绑定系统选择框事件
cell_obj.find('[data-action]').click(function () {
cell_obj.find('[data-action]').click(function (e) {
var action = $(this).attr('data-action');
var protocol_sub_type = $(this).attr('data-sub-protocol');
var uni_id = $(this).attr('data-id');
@ -130,6 +131,9 @@ $app.on_table_host_cell_created = function (tbl, row_id, col_key, cell_obj) {
if (action === 'rdp') {
$app.connect_remote(uni_id, TP_PROTOCOL_TYPE_RDP, TP_PROTOCOL_TYPE_RDP_DESKTOP);
} else if (action === 'rdp-option') {
$app.dlg_rdp_options.show(e.pageX, e.pageY, uni_id, TP_PROTOCOL_TYPE_RDP, TP_PROTOCOL_TYPE_RDP_DESKTOP);
//$app.connect_remote(uni_id, TP_PROTOCOL_TYPE_SSH, protocol_sub_type);
} else if (action === 'ssh') {
$app.connect_remote(uni_id, TP_PROTOCOL_TYPE_SSH, protocol_sub_type);
} else if (action === 'telnet') {
@ -139,30 +143,6 @@ $app.on_table_host_cell_created = function (tbl, row_id, col_key, cell_obj) {
}
};
// $app.check_host_all_selected = function (cb_stack) {
// var _all_checked = true;
// var _objs = $('#' + $app.table_host.dom_id + ' tbody').find('[data-check-box]');
// if (_objs.length === 0) {
// _all_checked = false;
// } else {
// $.each(_objs, function (i, _obj) {
// if (!$(_obj).is(':checked')) {
// _all_checked = false;
// return false;
// }
// });
// }
//
// if (_all_checked) {
// $app.dom.chkbox_host_select_all.prop('checked', true);
// } else {
// $app.dom.chkbox_host_select_all.prop('checked', false);
// }
//
// if (cb_stack)
// cb_stack.exec();
// };
$app.on_table_host_render_created = function (render) {
// render.filter_role = function (header, title, col) {
// var _ret = ['<div class="tp-table-filter tp-table-filter-' + col.cell_align + '">'];
@ -290,32 +270,43 @@ $app.on_table_host_render_created = function (render) {
} else {
if (acc.protocol_type === TP_PROTOCOL_TYPE_RDP) {
if ((acc.policy_.flag_rdp & TP_FLAG_RDP_DESKTOP) !== 0) {
act_btn.push('<li class="remote-action-btn">');
act_btn.push('<button type="button" class="btn btn-sm btn-primary" data-action="rdp" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '"><i class="fa fa-desktop fa-fw"></i> RDP</button>');
act_btn.push('</li>');
act_btn.push('<div class="btn-group btn-group-sm">');
act_btn.push('<button type="button" class="btn btn-primary" data-action="rdp" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '"><i class="fa fa-desktop fa-fw"></i> RDP</button>');
// act_btn.push('<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">');
act_btn.push('<a href="javascript:;" class="btn btn-primary dropdown-toggle" data-action="rdp-option" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '">');
//act_btn.push('<span class="caret"></span>');
act_btn.push('<i class="fa fa-cog"></i>');
act_btn.push('</a>');
// act_btn.push('<ul class="dropdown-menu">');
// act_btn.push('<li><a href="#">Another action</a></li>');
// act_btn.push('<li><a href="#"><i class="fa fa-desktop fa-fw"></i> 连接</a></li>');
// act_btn.push('<li role="separator" class="divider"></li>');
// // act_btn.push('<li><a href="#"><i class="fa fa-desktop fa-fw"></i> Console模式</a></li>');
// // act_btn.push('<li><input type="checkbox">Console模式</input></li>');
// act_btn.push('<li><a href="javascript:;" class="tp-checkbox tp-editable">Console模式</a></li>');
// act_btn.push('<li role="separator" class="divider"></li>');
// act_btn.push('<li><a href="#"><i class="fa fa-desktop fa-fw"></i> 连接</a></li>');
// act_btn.push('</ul>');
act_btn.push('</div>');
}
} else if (acc.protocol_type === TP_PROTOCOL_TYPE_SSH) {
act_btn.push('<div class="btn-group btn-group-sm">');
if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SHELL) !== 0) {
act_btn.push('<li class="remote-action-btn">');
act_btn.push('<button type="button" class="btn btn-sm btn-success" data-action="ssh" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SHELL + '"><i class="fa fa-keyboard-o fa-fw"></i> SSH</button>');
act_btn.push('</li>');
act_btn.push('<button type="button" class="btn btn-success" data-action="ssh" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SHELL + '"><i class="fa fa-keyboard-o fa-fw"></i> SSH</button>');
}
if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SFTP) !== 0) {
act_btn.push('<li class="remote-action-btn">');
act_btn.push('<button type="button" class="btn btn-sm btn-info" data-action="ssh" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SFTP + '"><i class="fa fa-upload fa-fw"></i> SFTP</button>');
act_btn.push('</li>');
act_btn.push('<button type="button" class="btn btn-info" data-action="ssh" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SFTP + '"><i class="fa fa-upload fa-fw"></i> SFTP</button>');
}
act_btn.push('</div>');
} else if (acc.protocol_type === TP_PROTOCOL_TYPE_TELNET) {
act_btn.push('<li class="remote-action-btn">');
act_btn.push('<button type="button" class="btn btn-sm btn-success" data-action="telnet" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_TELNET_SHELL + '"><i class="fa fa-keyboard-o fa-fw"></i> TELNET</button>');
act_btn.push('</li>');
act_btn.push('<button type="button" class="btn btn-warning" data-action="telnet" data-id="' + acc.uni_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_TELNET_SHELL + '"><i class="fa fa-keyboard-o fa-fw"></i> TELNET</button>');
}
}
h.push('<div class="remote-action-group" id =' + "account-id-" + acc.id + '"><ul>');
h.push('<div class="remote-action-group" id =' + "account-id-" + acc.id + '">');
h.push(act_btn.join(''));
h.push('</ul></div>');
h.push('</div>');
}
return h.join('');
};
@ -386,31 +377,126 @@ $app.on_table_host_header_created = function (header) {
.exec();
});
// TODO: 当过滤器不是默认值时,让“重置过滤器按钮”有呼吸效果,避免用户混淆 - 实验性质
// var t1 = function(){
// $app.dom.btn_table_host_reset_filter.fadeTo(1000, 1.0, function(){
// $app.dom.btn_table_host_reset_filter.fadeTo(1000, 0.2, t1);
// });
// };
// $app.dom.btn_table_host_reset_filter.fadeTo(1000, 0.2, t1);
// 表格内嵌过滤器的事件绑定在这时进行(也可以延期到整个表格创建完成时进行)
header._table_ctrl.get_filter_ctrl('search').on_created();
// header._table_ctrl.get_filter_ctrl('role').on_created();
// header._table_ctrl.get_filter_ctrl('state').on_created();
};
$app.get_selected_user = function (tbl) {
var users = [];
var _objs = $('#' + $app.table_host.dom_id + ' tbody tr td input[data-check-box]');
$.each(_objs, function (i, _obj) {
if ($(_obj).is(':checked')) {
var _row_data = tbl.get_row(_obj);
// _all_checked = false;
users.push(_row_data.id);
$app.create_dlg_rdp_options = function () {
var dlg = {};
dlg.dom_id = 'dlg-rdp-options';
dlg.uni_id = '';
dlg.protocol_type = TP_PROTOCOL_TYPE_RDP;
dlg.protocol_sub_type = TP_PROTOCOL_TYPE_RDP_DESKTOP;
dlg.rdp_w = 0;
dlg.rdp_h = 0;
dlg.rdp_console = false;
dlg.dom = {
dialog: $('#' + dlg.dom_id),
screen_size: $('#' + dlg.dom_id + ' [data-field="screen-size"]'),
console_mode: $('#' + dlg.dom_id + ' input[data-field="console-mode"]'),
btn_connect: $('#' + dlg.dom_id + ' [data-field="do-rdp-connect"]')
};
dlg.timer = null;
dlg.init = function (cb_stack) {
dlg.dom.dialog.mouseleave(function () {
dlg.timer = setTimeout(function () {
dlg.hide();
}, 800);
});
dlg.dom.dialog.mouseenter(function () {
if (dlg.timer !== null) {
clearTimeout(dlg.timer);
dlg.timer = null;
}
});
return users;
dlg.dom.btn_connect.click(function () {
dlg.hide();
var _size_obj = $('#' + dlg.dom_id + ' input[name="screen-size"]:checked');
var _console = dlg.dom.console_mode.is(':checked');
var _w = parseInt(_size_obj.attr('data-w'));
var _h = parseInt(_size_obj.attr('data-h'));
dlg.rdp_w = _w;
dlg.rdp_h = _h;
Cookies.set('rdp_options', {w: _w, h: _h, 'c': _console}, {path: '/ops/remote'});
$app.connect_remote(dlg.uni_id, dlg.protocol_type, dlg.protocol_sub_type);
});
var ops = Cookies.getJSON('rdp_options');
dlg.rdp_w = 0;
dlg.rdp_h = 0;
dlg.rdp_console = false;
if (!_.isUndefined(ops)) {
dlg.rdp_w = ops.w;
dlg.rdp_h = ops.h;
dlg.rdp_console = ops.c;
}
if (_.isUndefined(dlg.rdp_w) || _.isUndefined(dlg.rdp_h)) {
dlg.rdp_w = 0;
dlg.rdp_h = 0;
}
if (_.isUndefined(dlg.rdp_console))
dlg.rdp_console = false;
var ss = [
{w: 800, h: 600},
{w: 1024, h: 768},
{w: 1280, h: 1024},
{w: 1366, h: 768},
{w: 1440, h: 900}
];
var h = [];
h.push('<div class="radio">');
h.push('<div><label><input type="radio" name="screen-size" data-w="0" data-h="0"');
if (dlg.rdp_w === 0 && dlg.rdp_h === 0)
h.push(' checked');
h.push('> 全屏</label></div>');
for (var i = 0; i < ss.length; ++i) {
var _w = ss[i].w;
var _h = ss[i].h;
h.push('<div><label><input type="radio" name="screen-size" data-w="'+_w+'" data-h="'+_h+'"');
if (dlg.rdp_w === _w && dlg.rdp_h === _h)
h.push(' checked');
h.push('> ' + _w + ' x ' + _h + '</label></div>');
}
h.push('</div>');
dlg.dom.screen_size.html($(h.join('')));
if(dlg.rdp_console)
dlg.dom.console_mode.prop('checked', true);
cb_stack.exec();
};
dlg.show = function (x, y, uni_id, protocol_type, protocol_sub_type) {
if (dlg.timer !== null) {
clearTimeout(dlg.timer);
dlg.timer = null;
}
dlg.uni_id = uni_id;
dlg.protocol_type = protocol_type;
dlg.protocol_sub_type = protocol_sub_type;
var w = dlg.dom.dialog.width();
x -= w / 3;
y -= 12;
dlg.dom.dialog.css({left: x, top: y});
dlg.dom.dialog.fadeIn();
};
dlg.hide = function () {
dlg.dom.dialog.fadeOut();
};
return dlg;
};
$app.connect_remote = function (uni_id, protocol_type, protocol_sub_type) {
@ -418,7 +504,10 @@ $app.connect_remote = function (uni_id, protocol_type, protocol_sub_type) {
{
auth_id: uni_id,
protocol_type: protocol_type,
protocol_sub_type: protocol_sub_type
protocol_sub_type: protocol_sub_type,
rdp_width: $app.dlg_rdp_options.rdp_w,
rdp_height: $app.dlg_rdp_options.rdp_h,
rdp_console: $app.dlg_rdp_options.rdp_console
},
function () {
// func_success

View File

@ -104,12 +104,19 @@ $assist.do_teleport = function (args, func_success, func_error) {
teleport_port: teleport_port,
remote_host_ip: remote_host_ip,
// remote_host_port: args.host_port,
size: 3, //parseInt(args.size),
console: 0, //args.console,
// rdp_size: args.rdp_size,
// rdp_console: args.rdp_console,
session_id: session_id,
protocol_type: parseInt(args.protocol_type),
protocol_sub_type: parseInt(args.protocol_sub_type)
};
if(args.protocol_type === TP_PROTOCOL_TYPE_RDP) {
data.rdp_width = args.rdp_width;
data.rdp_height = args.rdp_height;
data.rdp_console = args.rdp_console;
}
// console.log('---', data);
var args_ = encodeURIComponent(JSON.stringify(data));
$.ajax({

View File

@ -126,217 +126,6 @@ ul.list {
}
}
.remote-action-group {
margin-bottom: 3px;
height: 28px;
//min-width: 390px;
ul {
display: block;
height: 28px;
margin: 0;
padding: 0;
li {
float: left;
position: relative;
display: block;
height: 28px;
padding: 4px 5px;
background-color: #eee;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
&.remote-action-btn {
background: none;
padding: 0;
border: none;
}
&.remote-action-input {
background: none;
padding: 4px 0;
select {
border: none;
}
}
&.remote-action-chk-protocol {
width: 86px;
}
&.remote-action-state {
//width: 64px;
text-align: center;
white-space: nowrap;
&.state-disabled {
background-color: @color-bg-ignore;
color: #aaa;
text-shadow: -1px -1px 1px #fff;
& > i.fa {
color: #b53a2f;
}
}
}
&.remote-action-username, &.remote-action-name, &.remote-action-protocol {
width: 96px;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&.remote-action-username {
font-size: 90%;
color: #999;
}
&.remote-action-name, &.remote-action-protocol, &.remote-action-chk-protocol {
color: #000;
}
&.remote-action-name, &.remote-action-chk-protocol {
font-weight: bold;
}
&.remote-action-password, &.remote-action-sshkey, &.remote-action-noauth {
text-align: center;
padding: 4px 8px;
width: 45px;
}
&.remote-action-password {
background-color: #e3ffe3;
color: #999;
}
&.remote-action-sshkey {
background-color: #fbe9c8;
color: #666;
}
&.remote-action-noauth {
background-color: #e0e0e0;
color: #666;
}
.btn {
line-height: 1.5;
margin: 0;
padding: 4px 8px;
font-size: 12px;
border-radius: 0;
}
label {
padding: 0;
display: block;
float: left;
margin-top: 1px;
cursor: pointer;
}
input[type=checkbox] {
display: block;
float: left;
margin: 3px 5px 0 0;
}
select {
margin-top: -3px;
}
&:first-child {
border-left: 1px solid #ccc;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
&.remote-action-btn:first-child {
border: none;
.btn {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
}
&:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
&.remote-action-btn:last-child {
border: none;
.btn {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
}
}
}
.remote-info-group {
margin-bottom: 3px;
height: 28px;
ul {
display: inline-block;
height: 28px;
margin: 0;
padding: 0;
li {
float: left;
position: relative;
display: block;
height: 28px;
padding: 4px 5px;
//background-color: #efefef;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
&.remote-action-btn {
background: none;
padding: 0;
border: none;
}
&.remote-action-input {
background: none;
padding: 4px 0;
select {
border: none;
}
}
label {
padding: 0;
display: block;
float: left;
margin-top: 1px;
cursor: pointer;
}
select {
margin-top: -3px;
}
&:first-child {
border-left: 1px solid #ccc;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
&:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
}
}
hr.small {
margin: 5px 0;
}

View File

@ -0,0 +1,260 @@
@charset "utf-8";
.remote-action-group {
margin-bottom: 3px;
height: 28px;
.btn-group-sm > .btn {
margin: 0;
padding: 6px 6px;
font-size: 12px;
height: 28px;
min-width: 80px;
&.dropdown-toggle {
min-width: 0;
}
}
//& > ul {
// display: block;
// height: 28px;
// margin: 0;
// padding: 0;
//
// & > li {
// float: left;
// position: relative;
// display: block;
// height: 28px;
// padding: 4px 5px;
//
// background-color: #eee;
// border-top: 1px solid #ccc;
// border-right: 1px solid #ccc;
// border-bottom: 1px solid #ccc;
//
// &.remote-action-btn {
// background: none;
// padding: 0;
// border: none;
// }
//
// &.remote-action-input {
// background: none;
// padding: 4px 0;
//
// select {
// border: none;
// }
// }
//
// &.remote-action-chk-protocol {
// width: 86px;
// }
//
// &.remote-action-state {
// //width: 64px;
// text-align: center;
// white-space: nowrap;
//
// &.state-disabled {
// background-color: @color-bg-ignore;
// color: #aaa;
// text-shadow: -1px -1px 1px #fff;
//
// & > i.fa {
// color: #b53a2f;
// }
// }
// }
//
// &.remote-action-username, &.remote-action-name, &.remote-action-protocol {
// width: 96px;
// text-align: center;
// white-space: nowrap;
// overflow: hidden;
// text-overflow: ellipsis;
// }
// &.remote-action-username {
// font-size: 90%;
// color: #999;
// }
// &.remote-action-name, &.remote-action-protocol, &.remote-action-chk-protocol {
// color: #000;
// }
// &.remote-action-name, &.remote-action-chk-protocol {
// font-weight: bold;
// }
//
// &.remote-action-password, &.remote-action-sshkey, &.remote-action-noauth {
// text-align: center;
// padding: 4px 8px;
// width: 45px;
// }
// &.remote-action-password {
// background-color: #e3ffe3;
// color: #999;
// }
// &.remote-action-sshkey {
// background-color: #fbe9c8;
// color: #666;
// }
// &.remote-action-noauth {
// background-color: #e0e0e0;
// color: #666;
// }
//
// & > .btn {
// line-height: 1.5;
// margin: 0;
// padding: 4px 8px;
// font-size: 12px;
// border-radius: 0;
// }
//
// label {
// padding: 0;
// display: block;
// float: left;
// margin-top: 1px;
// cursor: pointer;
// }
// input[type=checkbox] {
// display: block;
// float: left;
// margin: 3px 5px 0 0;
// }
// select {
// margin-top: -3px;
// }
//
// &:first-child {
// border-left: 1px solid #ccc;
// border-top-left-radius: 4px;
// border-bottom-left-radius: 4px;
// }
//
// &.remote-action-btn:first-child {
// border: none;
// .btn {
// border-top-left-radius: 4px;
// border-bottom-left-radius: 4px;
// }
// }
//
// &:last-child {
// border-top-right-radius: 4px;
// border-bottom-right-radius: 4px;
// }
//
// &.remote-action-btn:last-child {
// border: none;
// .btn {
// border-top-right-radius: 4px;
// border-bottom-right-radius: 4px;
// }
// }
//
// }
//}
}
.remote-info-group {
margin-bottom: 3px;
height: 28px;
ul {
display: inline-block;
height: 28px;
margin: 0;
padding: 0;
li {
float: left;
position: relative;
display: block;
height: 28px;
padding: 4px 5px;
//background-color: #efefef;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
&.remote-action-btn {
background: none;
padding: 0;
border: none;
}
&.remote-action-input {
background: none;
padding: 4px 0;
select {
border: none;
}
}
label {
padding: 0;
display: block;
float: left;
margin-top: 1px;
cursor: pointer;
}
select {
margin-top: -3px;
}
&:first-child {
border-left: 1px solid #ccc;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
&:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
}
}
.rdp-options {
position: absolute;
display: none;
left: 10px;
top: 30px;
border: 1px solid rgba(0, 0, 0, .25);
z-index: 9999;
background-color: #fff;
border-radius: 4px;
box-shadow: 0 6px 12px rgba(0, 0, 0, .2);
font-size: 13px;
hr {
margin: 3px 0;
}
.title {
background-color: #eee;
padding: 3px 5px;
}
.item {
width: 100%;
padding: 3px 20px;
.radio, .checkbox {
// overwrite bootstrap.
margin:0;
font-family: @font-family-mono;
}
.center {
text-align: center;
}
}
}

View File

@ -2,9 +2,10 @@
@import "_color";
@import "_base";
@import "_overwrite_bootstrap";
@import "_role";
@import "_table";
@import "_overwrite_bootstrap";
@import "_remote_action";
//@menu-admin-bg-color: #930;

View File

@ -27,23 +27,24 @@
<button id="btn-refresh-host" class="btn btn-sm btn-default"><i class="fa fa-rotate-right fa-fw"></i> 刷新列表</button>
</div>
<div class="table-extend-cell table-extend-cell-right group-actions">
## <button id="btn-add-host" class="btn btn-sm btn-primary"><i class="fa fa-plus-circle fa-fw"></i> 添加主机</button>
## <button id="btn-add-host" class="btn btn-sm btn-primary"><i class="fa fa-plus-circle fa-fw"></i> 添加主机</button>
</div>
</div>
<table id="table-host" class="table table-striped table-bordered table-hover table-data no-footer dtr-inline"></table>
<div class="table-extend-area">
## <div class="table-extend-cell checkbox-select-all"><input id="table-host-select-all" type="checkbox"/></div>
## <div class="table-extend-cell group-actions">
## <div class="btn-group" role="group">
## ## <button id="btn-edit-host" type="button" class="btn btn-default"><i class="fa fa-edit fa-fw"></i> 编辑</button>
##
## <button id="btn-lock-host" type="button" class="btn btn-default"><i class="fa fa-lock fa-fw"></i> 禁用</button>
## <button id="btn-unlock-host" type="button" class="btn btn-default"><i class="fa fa-unlock fa-fw"></i> 解禁</button>
## <button id="btn-remove-host" type="button" class="btn btn-default"><i class="fa fa-times-circle fa-fw"></i> 删除</button>
## </div>
## </div>
## <div class="table-extend-cell checkbox-select-all"><input id="table-host-select-all" type="checkbox"/></div>
## <div class="table-extend-cell group-actions">
## <div class="btn-group" role="group">
## ## <button id="btn-edit-host" type="button" class="btn btn-default"><i class="fa fa-edit fa-fw"></i> 编辑</button>
##
## <button id="btn-lock-host" type="button" class="btn btn-default"><i class="fa fa-lock fa-fw"></i> 禁用</button>
## <button id="btn-unlock-host" type="button" class="btn btn-default"><i class="fa fa-unlock fa-fw"></i> 解禁</button>
## <button id="btn-remove-host" type="button" class="btn btn-default"><i class="fa fa-times-circle fa-fw"></i> 删除</button>
## </div>
## </div>
<div class="table-extend-cell table-item-counter">
<ol id="table-host-paging"></ol>
</div>
@ -71,7 +72,45 @@
<%block name="extend_content">
<div id="dlg-rdp-options" class="rdp-options">
<div class="title">RDP连接选项</div>
<div class="item" data-field="screen-size">
## 屏幕尺寸:
## <select data-field="screen-size">
## <option value="0">全屏</option>
## <option value="800x600">800x600</option>
## <option value="1024x768">1024x768</option>
## <option value="1280x1024">1280x1024</option>
## <option value="1366x768">1366x768</option>
## <option value="1440x900">1440x900</option>
## <option value="1600x1024">1600x1024</option>
## </select>
<div class="radio">
<div><label><input type="radio" name="screen-size" id="ss-800x600" checked> 800 x 600</label></div>
<div><label><input type="radio" name="screen-size" id="ss-1024x768"> 1024 x 768</label></div>
</div>
</div>
## <div class="item"><a href="javascript:;" data-field="allow-clipboard" class="tp-checkbox tp-editable">允许映射剪贴板</a></div>
## <div class="item"><a href="javascript:;" class="tp-checkbox tp-editable">允许映射本地磁盘</a></div>
<hr/>
<div class="item">
## <a href="javascript:;" data-field="console-mode" class="tp-checkbox tp-editable">Console模式</a>
<div class="checkbox">
<label><input type="checkbox" data-field="console-mode"> Console模式</label>
</div>
</div>
<hr/>
<div class="item">
<div class="center">
<button type="button" data-field="do-rdp-connect" class="btn btn-sm btn-primary"><i class="fa fa-desktop fa-fw"></i> 开始连接</button>
</div>
</div>
</div>
</%block>
## <%block name="embed_js">

View File

@ -58,8 +58,6 @@ def login(handler, username, password=None, oath_code=None):
# syslog.sys_log({'username': username, 'surname': username}, handler.request.remote_ip, TPE_NOT_EXISTS, '用户身份验证失败,用户`{}`不存在'.format(username))
return err, None
print(user_info)
if user_info.privilege == 0:
# 尚未为此用户设置角色
return TPE_PRIVILEGE, None