mirror of https://github.com/tp4a/teleport
temp.
parent
80a792342d
commit
5766a3370a
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
|
@ -77,6 +77,11 @@ $tp.init = function () {
|
|||
{id: TP_STATE_LOCKED, name: '临时锁定', style: 'warning'}
|
||||
];
|
||||
|
||||
$app.user_type = [
|
||||
{id: TP_USER_TYPE_LOCAL, name: '本地用户', style: 'success'},
|
||||
{id: TP_USER_TYPE_LDAP, name: 'LDAP', style: 'warning'}
|
||||
];
|
||||
|
||||
$app.host_types = [
|
||||
{id: 1, name: '物理主机', style: 'success'},
|
||||
{id: 2, name: '虚拟主机', style: 'info'},
|
||||
|
|
|
@ -1706,6 +1706,93 @@ $tp.create_table_header_filter_state = function (tbl, name, states, exclude_ids)
|
|||
};
|
||||
};
|
||||
|
||||
$tp.create_table_header_filter_dropdown = function (tbl, name, states, exclude_ids) {
|
||||
var _tblf = {};
|
||||
_tblf._table_ctrl = tbl;
|
||||
_tblf.dom_id = tbl.dom_id + '-header-filter-' + name;
|
||||
_tblf.name = name;
|
||||
_tblf.default_value = 0;
|
||||
_tblf.filter_value = 0;
|
||||
|
||||
_tblf.states = [];
|
||||
if (exclude_ids && exclude_ids.length > 0) {
|
||||
for (var i = 0; i < states.length; ++i) {
|
||||
if (_.indexOf(exclude_ids, states[i].id) !== -1)
|
||||
continue;
|
||||
_tblf.states.push(states[i]);
|
||||
}
|
||||
} else {
|
||||
_tblf.states = states;
|
||||
}
|
||||
|
||||
_tblf._table_ctrl.add_filter_ctrl(_tblf.name, _tblf);
|
||||
|
||||
_tblf.init = function (cb_stack, cb_args) {
|
||||
// 这是一个表格内嵌过滤器,因此无需在init时创建DOM对象。
|
||||
cb_stack.exec();
|
||||
};
|
||||
|
||||
_tblf.get_filter = function () {
|
||||
var ret = {};
|
||||
if (_tblf.default_value === _tblf.filter_value)
|
||||
return ret;
|
||||
ret[_tblf.name] = _tblf.filter_value;
|
||||
return ret;
|
||||
};
|
||||
|
||||
_tblf.reset = function (cb_stack) {
|
||||
_tblf.filter_value = _tblf.default_value;
|
||||
var name = _tblf._id2name(_tblf.filter_value);
|
||||
$('#' + _tblf.dom_id + ' span[data-tp-select-result]').text(name);
|
||||
cb_stack.exec();
|
||||
};
|
||||
|
||||
_tblf.render = function () {
|
||||
var _ret = [];
|
||||
_ret.push('<div id="' + _tblf.dom_id + '" class="btn-group search-select" role="group">');
|
||||
_ret.push('<button type="button" class="btn dropdown-toggle" data-toggle="dropdown">');
|
||||
_ret.push('<span data-tp-select-result></span> <i class="fa fa-caret-right"></i></button>');
|
||||
_ret.push('<ul class="dropdown-menu dropdown-menu-right dropdown-menu-sm">');
|
||||
_ret.push('<li><a href="javascript:;" data-tp-selector="0"><i class="fa fa-list-ul fa-fw"></i> 所有</a></li>');
|
||||
_ret.push('<li role="separator" class="divider"></li>');
|
||||
$.each(_tblf.states, function (i, state) {
|
||||
_ret.push('<li><a href="javascript:;" data-tp-selector="' + state.id + '"><i class="fa fa-caret-right fa-fw"></i> ' + state.name + '</a></li>');
|
||||
});
|
||||
_ret.push('</ul></div>');
|
||||
|
||||
return _ret.join('');
|
||||
};
|
||||
|
||||
_tblf._id2name = function (id_) {
|
||||
if (id_ === 0)
|
||||
return '所有';
|
||||
for (var i = 0; i < _tblf.states.length; ++i) {
|
||||
if (_tblf.states[i].id === id_)
|
||||
return _tblf.states[i].name;
|
||||
}
|
||||
console.error('on', _tblf.name, 'filter select, no such id.', id_);
|
||||
return '-未知-';
|
||||
};
|
||||
|
||||
_tblf.on_created = function () {
|
||||
$('#' + _tblf.dom_id + ' span[data-tp-select-result]').text('所有');
|
||||
$('#' + _tblf.dom_id + ' li a[data-tp-selector]').click(function () {
|
||||
|
||||
var select = parseInt($(this).attr('data-tp-selector'));
|
||||
if (_tblf.filter_value === select)
|
||||
return;
|
||||
_tblf.filter_value = select;
|
||||
|
||||
var name = _tblf._id2name(select);
|
||||
|
||||
$('#' + _tblf.dom_id + ' span[data-tp-select-result]').text(name);
|
||||
|
||||
// 更新表格过滤器,并刷新数据
|
||||
_tblf._table_ctrl.load_data(CALLBACK_STACK.create(), {});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
$tp.create_table_filter_group = function (tbl, name, dom_id, groups) {
|
||||
var _tblf = {};
|
||||
_tblf._table_ctrl = tbl;
|
||||
|
@ -1762,3 +1849,4 @@ $tp.create_table_filter_group = function (tbl, name, dom_id, groups) {
|
|||
return '-未知-';
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -73,6 +73,9 @@ var TP_STATE_NORMAL = 1; // 正常
|
|||
var TP_STATE_DISABLED = 2; // 禁用
|
||||
var TP_STATE_LOCKED = 3; // 临时禁用(用于用户登录连续错误n次)
|
||||
|
||||
var TP_USER_TYPE_LOCAL = 1;
|
||||
var TP_USER_TYPE_LDAP = 2;
|
||||
|
||||
// =======================================================
|
||||
// 授权策略对象
|
||||
// =======================================================
|
||||
|
|
|
@ -70,6 +70,15 @@ $app.create_controls = function (cb_stack) {
|
|||
render: 'user_info',
|
||||
fields: {id: 'id', username: 'username', surname: 'surname', email: 'email'}
|
||||
},
|
||||
{
|
||||
title: "类型",
|
||||
key: "type",
|
||||
width: 120,
|
||||
sort: true,
|
||||
header_render: 'filter_type',
|
||||
render: 'user_type',
|
||||
fields: {user_type: 'type'}
|
||||
},
|
||||
{
|
||||
title: "角色",
|
||||
key: "role_id",
|
||||
|
@ -118,8 +127,9 @@ $app.create_controls = function (cb_stack) {
|
|||
name: 'search',
|
||||
place_holder: '搜索:用户账号/姓名/邮箱/描述/等等...'
|
||||
});
|
||||
$tp.create_table_header_filter_dropdown($app.table_users, 'type', $app.user_type);
|
||||
$tp.create_table_filter_role($app.table_users, $app.role_list);
|
||||
$tp.create_table_header_filter_state($app.table_users, 'state', $app.obj_states);
|
||||
$tp.create_table_header_filter_dropdown($app.table_users, 'state', $app.obj_states);
|
||||
// 从cookie中读取用户分页限制的选择
|
||||
$tp.create_table_paging($app.table_users, 'table-user-list-paging',
|
||||
{
|
||||
|
@ -255,6 +265,20 @@ $app.on_table_users_render_created = function (render) {
|
|||
return _ret.join('');
|
||||
};
|
||||
|
||||
render.filter_type = function (header, title, col) {
|
||||
var _ret = ['<div class="tp-table-filter tp-table-filter-' + col.cell_align + '">'];
|
||||
_ret.push('<div class="tp-table-filter-inner">');
|
||||
_ret.push('<div class="search-title">' + title + '</div>');
|
||||
|
||||
// 表格内嵌过滤器的DOM实体在这时生成
|
||||
var filter_ctrl = header._table_ctrl.get_filter_ctrl('type');
|
||||
_ret.push(filter_ctrl.render());
|
||||
|
||||
_ret.push('</div></div>');
|
||||
|
||||
return _ret.join('');
|
||||
};
|
||||
|
||||
render.filter_state = function (header, title, col) {
|
||||
var _ret = ['<div class="tp-table-filter tp-table-filter-' + col.cell_align + '">'];
|
||||
_ret.push('<div class="tp-table-filter-inner">');
|
||||
|
@ -302,6 +326,16 @@ $app.on_table_users_render_created = function (render) {
|
|||
return ret.join('');
|
||||
};
|
||||
|
||||
render.user_type = function (row_id, fields) {
|
||||
if(fields.user_type === 1) {
|
||||
return '本地用户';
|
||||
} else if(fields.user_type === 2) {
|
||||
return 'LDAP';
|
||||
} else{
|
||||
return '-未知-'
|
||||
}
|
||||
};
|
||||
|
||||
render.role = function (row_id, fields) {
|
||||
for (var i = 0; i < $app.role_list.length; ++i) {
|
||||
if ($app.role_list[i].id === fields.role_id)
|
||||
|
@ -379,8 +413,9 @@ $app.on_table_users_header_created = function (header) {
|
|||
|
||||
// 表格内嵌过滤器的事件绑定在这时进行(也可以延期到整个表格创建完成时进行)
|
||||
header._table_ctrl.get_filter_ctrl('search').on_created();
|
||||
header._table_ctrl.get_filter_ctrl('role').on_created();
|
||||
header._table_ctrl.get_filter_ctrl('type').on_created();
|
||||
header._table_ctrl.get_filter_ctrl('state').on_created();
|
||||
header._table_ctrl.get_filter_ctrl('role').on_created();
|
||||
};
|
||||
|
||||
$app.on_btn_select_file_click = function () {
|
||||
|
|
|
@ -289,7 +289,7 @@ label.form-control-static {
|
|||
}
|
||||
}
|
||||
|
||||
.table-extend-cell {
|
||||
.table-extend-cell, .table-prefix-area {
|
||||
.btn-group-sm {
|
||||
.btn {
|
||||
padding: 5px 5px;
|
||||
|
|
|
@ -202,7 +202,7 @@ body {
|
|||
position: absolute;
|
||||
min-height: @error-icon-size+30px;
|
||||
overflow: hidden;
|
||||
& > .fas {
|
||||
& > .fas, .fa {
|
||||
margin-top: 30px;
|
||||
font-size: @error-icon-size;
|
||||
//color: rgb(255, 101, 0);
|
||||
|
|
|
@ -854,7 +854,7 @@ body {
|
|||
&.group-actions {
|
||||
& > .btn-group {
|
||||
.btn {
|
||||
padding: 3px 5px;
|
||||
padding: 5px 5px;
|
||||
font-size: @text-size-small;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<div class="page-content">
|
||||
<div class="info-box">
|
||||
<div class="info-icon-box">
|
||||
<i id="icon-bg"></i>
|
||||
<i class="fa fa-key" style="color:#ffa043;"></i>
|
||||
</div>
|
||||
<div class="info-message-box">
|
||||
<div id="title" class="title">设置密码</div>
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
<div class="table-extend-cell table-extend-cell-right group-actions">
|
||||
<button id="btn-create-user" class="btn btn-sm btn-primary"><i class="fa fa-plus-circle fa-fw"></i> 创建用户</button>
|
||||
<button id="btn-import-user" class="btn btn-sm btn-default"><i class="fa fa-plus-square fa-fw"></i> 导入用户</button>
|
||||
<div class="btn-group btn-group-sm dropdown" id="filter-host-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">LDAP管理 <i class="fa fa-caret-right"></i></button>
|
||||
<ul class="dropdown-menu dropdown-menu-sm"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -212,12 +216,22 @@
|
|||
<div class="col-sm-10">
|
||||
<div class="control-desc">当前使用系统默认设置</div>
|
||||
<ul class="list">
|
||||
<li><div id="sec-auth-use-sys-config" class="tp-checkbox tp-editable">使用系统默认设置</div></li>
|
||||
<li><hr class="hr-sm"/></li>
|
||||
## <li><div id="sec-auth-username-password" class="tp-checkbox">用户名 + 密码</div></li>
|
||||
<li><div id="sec-auth-username-password-captcha" class="tp-checkbox">用户名 + 密码 + 验证码</div></li>
|
||||
## <li><div id="sec-auth-username-oath" class="tp-checkbox">用户名 + 身份认证器动态密码</div></li>
|
||||
<li><div id="sec-auth-username-password-oath" class="tp-checkbox">用户名 + 密码 + 身份认证器动态密码</div></li>
|
||||
<li>
|
||||
<div id="sec-auth-use-sys-config" class="tp-checkbox tp-editable">使用系统默认设置</div>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="hr-sm"/>
|
||||
</li>
|
||||
## <li><div id="sec-auth-username-password" class="tp-checkbox">用户名 + 密码</div></li>
|
||||
|
||||
<li>
|
||||
<div id="sec-auth-username-password-captcha" class="tp-checkbox">用户名 + 密码 + 验证码</div>
|
||||
</li>
|
||||
## <li><div id="sec-auth-username-oath" class="tp-checkbox">用户名 + 身份认证器动态密码</div></li>
|
||||
|
||||
<li>
|
||||
<div id="sec-auth-username-password-oath" class="tp-checkbox">用户名 + 密码 + 身份认证器动态密码</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -147,6 +147,8 @@ def get_users(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude):
|
|||
for k in sql_filter:
|
||||
if k == 'role':
|
||||
_where.append('u.role_id={filter}'.format(filter=sql_filter[k]))
|
||||
elif k == 'type':
|
||||
_where.append('u.type={filter}'.format(filter=sql_filter[k]))
|
||||
elif k == 'state':
|
||||
_where.append('u.state={filter}'.format(filter=sql_filter[k]))
|
||||
elif k == 'search':
|
||||
|
@ -165,6 +167,8 @@ def get_users(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude):
|
|||
s.order_by('u.role_id', _sort)
|
||||
elif 'state' == sql_order['name']:
|
||||
s.order_by('u.state', _sort)
|
||||
elif 'type' == sql_order['name']:
|
||||
s.order_by('u.type', _sort)
|
||||
else:
|
||||
log.e('unknown order field: {}\n'.format(sql_order['name']))
|
||||
return TPE_PARAM, 0, 0, {}
|
||||
|
|
Loading…
Reference in New Issue