mirror of https://github.com/tp4a/teleport
parent
3e9809c726
commit
00ead99bb1
File diff suppressed because it is too large
Load Diff
|
@ -54,7 +54,7 @@ $app.create_controls = function (cb_stack) {
|
||||||
// width: 240,
|
// width: 240,
|
||||||
header_render: 'filter_search',
|
header_render: 'filter_search',
|
||||||
render: 'acc_info',
|
render: 'acc_info',
|
||||||
fields: {id: 'id', username: 'username', host_ip: 'host_ip', router_ip: 'router_ip', router_port: 'router_port'}
|
fields: {id: 'id', username: 'username', _host: '_host'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "远程连接协议",
|
title: "远程连接协议",
|
||||||
|
@ -140,7 +140,7 @@ $app.create_controls = function (cb_stack) {
|
||||||
sort: true,
|
sort: true,
|
||||||
header_render: 'filter_search',
|
header_render: 'filter_search',
|
||||||
render: 'acc_info',
|
render: 'acc_info',
|
||||||
fields: {id: 'id', username: 'username', host_ip: 'host_ip', router_ip: 'router_ip', router_port: 'router_port'}
|
fields: {id: 'id', username: 'username', _host: '_host'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "远程连接协议",
|
title: "远程连接协议",
|
||||||
|
@ -296,9 +296,13 @@ $app._add_common_render = function (render) {
|
||||||
render.acc_info = function (row_id, fields) {
|
render.acc_info = function (row_id, fields) {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
ret.push('<span class="user-surname">' + fields.username + '@' + fields.host_ip + '</span>');
|
ret.push('<span class="user-surname">' + fields.username + '@' + fields._host.ip);
|
||||||
if (fields.router_ip.length > 0)
|
if (fields._host.name.length > 0)
|
||||||
ret.push('<span class="user-account">由 ' + fields.router_ip + ':' + fields.router_port + ' 路由</span>');
|
ret.push(' <span class="host-name">(' + fields._host.name + ')</span>');
|
||||||
|
ret.push('</span>');
|
||||||
|
|
||||||
|
if (fields._host.router_ip.length > 0)
|
||||||
|
ret.push('<span class="user-account">由 ' + fields._host.router_ip + ':' + fields._host.router_port + ' 路由</span>');
|
||||||
|
|
||||||
return ret.join('');
|
return ret.join('');
|
||||||
};
|
};
|
||||||
|
|
|
@ -375,7 +375,7 @@ $app.create_controls = function (cb_stack) {
|
||||||
sort: true,
|
sort: true,
|
||||||
header_render: 'filter_search',
|
header_render: 'filter_search',
|
||||||
render: 'acc_info',
|
render: 'acc_info',
|
||||||
fields: {id: 'id', username: 'username', host_ip: 'host_ip', router_ip: 'router_ip', router_port: 'router_port'}
|
fields: {id: 'id', username: 'username', _host: '_host'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "远程连接协议",
|
title: "远程连接协议",
|
||||||
|
@ -1316,9 +1316,12 @@ $app.on_table_sel_acc_render_created = function (render) {
|
||||||
render.acc_info = function (row_id, fields) {
|
render.acc_info = function (row_id, fields) {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
ret.push('<span class="field-name">' + fields.username + '@' + fields.host_ip + '</span>');
|
ret.push('<span class="field-name">' + fields.username + '@' + fields._host.ip);
|
||||||
if (fields.router_ip.length > 0)
|
if(fields._host.name.length > 0)
|
||||||
ret.push('<span class="field-desc">由 ' + fields.router_ip + ':' + fields.router_port + ' 路由</span>');
|
ret.push(' (' + fields._host.name + ')</span>');
|
||||||
|
ret.push('</span>');
|
||||||
|
if (fields._host.router_ip.length > 0)
|
||||||
|
ret.push('<span class="field-desc">由 ' + fields._host.router_ip + ':' + fields._host.router_port + ' 路由</span>');
|
||||||
|
|
||||||
return ret.join('');
|
return ret.join('');
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,7 +74,7 @@ def get_group_with_member(sql_filter, sql_order, sql_limit):
|
||||||
for g in sg.recorder:
|
for g in sg.recorder:
|
||||||
g['member_count'] = 0
|
g['member_count'] = 0
|
||||||
g['members'] = []
|
g['members'] = []
|
||||||
g['_mid'] = [] # 临时使用,构建此组的前5个成员的id
|
g['_mid'] = [] # 临时使用,构建此组的前5个成员的id
|
||||||
|
|
||||||
# 对于本次要返回的用户组,取其中每一个组内成员的基本信息(id/用户名/真实名称等)
|
# 对于本次要返回的用户组,取其中每一个组内成员的基本信息(id/用户名/真实名称等)
|
||||||
groups = [g['id'] for g in sg.recorder]
|
groups = [g['id'] for g in sg.recorder]
|
||||||
|
@ -125,9 +125,12 @@ def get_group_with_member(sql_filter, sql_order, sql_limit):
|
||||||
|
|
||||||
|
|
||||||
def get_accounts(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude):
|
def get_accounts(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude):
|
||||||
dbtp = get_db().table_prefix
|
db = get_db()
|
||||||
s = SQL(get_db())
|
dbtp = db.table_prefix
|
||||||
s.select_from('acc', ['id', 'host_id', 'host_ip', 'router_ip', 'router_port', 'username', 'protocol_type', 'auth_type', 'state'], alt_name='a')
|
|
||||||
|
s = SQL(db)
|
||||||
|
# s.select_from('acc', ['id', 'host_id', 'host_ip', 'router_ip', 'router_port', 'username', 'protocol_type', 'auth_type', 'state'], alt_name='a')
|
||||||
|
s.select_from('acc', ['id', 'host_id', 'username', 'protocol_type', 'auth_type', 'state'], alt_name='a')
|
||||||
|
|
||||||
str_where = ''
|
str_where = ''
|
||||||
_where = list()
|
_where = list()
|
||||||
|
@ -168,12 +171,35 @@ def get_accounts(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude):
|
||||||
s.order_by('a.state', _sort)
|
s.order_by('a.state', _sort)
|
||||||
else:
|
else:
|
||||||
log.e('unknown order field: {}\n'.format(sql_order['name']))
|
log.e('unknown order field: {}\n'.format(sql_order['name']))
|
||||||
return TPE_PARAM, s.total_count, s.recorder
|
return TPE_PARAM, s.total_count, 1, s.recorder
|
||||||
|
|
||||||
if len(sql_limit) > 0:
|
if len(sql_limit) > 0:
|
||||||
s.limit(sql_limit['page_index'], sql_limit['per_page'])
|
s.limit(sql_limit['page_index'], sql_limit['per_page'])
|
||||||
|
|
||||||
err = s.query()
|
err = s.query()
|
||||||
|
if err != TPE_OK:
|
||||||
|
return err, 0, 1, None
|
||||||
|
|
||||||
|
# 得到主机id列表,然后查询相关主机的详细信息
|
||||||
|
host_ids = []
|
||||||
|
for _acc in s.recorder:
|
||||||
|
if _acc.host_id not in host_ids:
|
||||||
|
host_ids.append(_acc.host_id)
|
||||||
|
s_host = SQL(db)
|
||||||
|
s_host.select_from('host', ['id', 'name', 'ip', 'router_ip', 'router_port', 'state'], alt_name='h')
|
||||||
|
str_host_ids = ','.join([str(i) for i in host_ids])
|
||||||
|
s_host.where('h.id IN ({ids})'.format(ids=str_host_ids))
|
||||||
|
err = s_host.query()
|
||||||
|
if err != TPE_OK:
|
||||||
|
return err, 0, None
|
||||||
|
hosts = {}
|
||||||
|
for _host in s_host.recorder:
|
||||||
|
if _host.id not in hosts:
|
||||||
|
hosts[_host.id] = _host
|
||||||
|
|
||||||
|
for _acc in s.recorder:
|
||||||
|
_acc['_host'] = hosts[_acc.host_id]
|
||||||
|
|
||||||
return err, s.total_count, s.page_index, s.recorder
|
return err, s.total_count, s.page_index, s.recorder
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,6 +381,3 @@ def remove_accounts(handler, host_id, acc_ids):
|
||||||
tp_stats().acc_counter_change(-1)
|
tp_stats().acc_counter_change(-1)
|
||||||
|
|
||||||
return TPE_OK
|
return TPE_OK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue