275 lines
13 KiB
Go
275 lines
13 KiB
Go
<div class="wrapper wrapper-content animated fadeInRight">
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="ibox float-e-margins">
|
|
<div class="ibox-title">
|
|
<h5 langtag="page-clientlist"></h5>
|
|
|
|
<div class="ibox-tools">
|
|
<a class="collapse-link">
|
|
<i class="fa fa-chevron-up"></i>
|
|
</a>
|
|
<a class="close-link">
|
|
<i class="fa fa-times"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="content">
|
|
{{if eq true .isAdmin}}
|
|
|
|
<div class="table-responsive">
|
|
<div id="toolbar">
|
|
<a href="{{.web_base_url}}/client/add" class="btn btn-primary dim">
|
|
<i class="fa fa-fw fa-lg fa-plus"></i> <span langtag="word-add"></span></a>
|
|
<a href="#" onclick="batchDelete('{{.web_base_url}}/client/del');return false;" class="btn btn-danger dim">
|
|
<i class="fa fa-fw fa-lg fa-trash"></i> <span langtag="word-batchdelete"></span></a>
|
|
</div>
|
|
<table id="taskList_table" class="table-striped table-hover" data-mobile-responsive="true"></table>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
<div class="ibox-content">
|
|
|
|
<table id="table"></table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
/*bootstrap table*/
|
|
$('#table').bootstrapTable({
|
|
toolbar: "#toolbar",
|
|
method: 'post', // 服务器数据的请求方式 get or post
|
|
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
|
|
contentType: "application/x-www-form-urlencoded",
|
|
queryParams: function (params) {
|
|
return {
|
|
"offset": params.offset,
|
|
"limit": params.limit,
|
|
"search": params.search,
|
|
"sort": params.sort,
|
|
"order": params.order
|
|
}
|
|
},
|
|
striped: true, // 设置为true会有隔行变色效果
|
|
search: true,
|
|
showHeader: true,
|
|
showColumns: true,
|
|
showRefresh: true,
|
|
pagination: true,//分页
|
|
sidePagination: 'server',//服务器端分页
|
|
pageNumber: 1,
|
|
pageList: [5, 10, 20, 50],//分页步进值
|
|
detailView: true,
|
|
smartDisplay: true, // 智能显示 pagination 和 cardview 等
|
|
onExpandRow: function () {$('body').setLang ('.detail-view');},
|
|
onPostBody: function (data) { if ($(this)[0].locale != undefined ) $('body').setLang ('#table'); },
|
|
detailFormatter: function (index, row, element) {
|
|
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + ' '
|
|
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + ' '
|
|
+ '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm '
|
|
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'KB/s '
|
|
+ '<b langtag="word-maxtunnels"></b>: ' + row.MaxTunnelNum + ' <br/><br/>'
|
|
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + ' '
|
|
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + ' '
|
|
+ '<b langtag="word-basicusername"></b>: ' + row.Cnf.U + ' '
|
|
+ '<b langtag="word-basicpassword"></b>: ' + row.Cnf.P + ' <br/><br/>'
|
|
+ '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span> <br/><br/>'
|
|
+ '<b langtag="word-ipwhite"></b>: ' + row.IpWhite + ' '
|
|
+ '<b langtag="word-ipwhitepass"></b>: ' + row.IpWhitePass + ' <br/>'
|
|
+ '<b langtag="word-ipwhitelist"></b>: ' + row.IpWhiteList + ' <br/>'
|
|
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + ' <br/><br/>'
|
|
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + ' <br/>'
|
|
+ '<b langtag="word-lastonlinetime"></b>: ' + row.LastOnlineTime + ' <br/>'
|
|
+ '<b langtag="word-expiretime"></b>: ' + (row.ExpireTime || '<span langtag="info-unrestricted"></span>') + ' <br/><br/>'
|
|
+ '<b langtag="word-quicklycommand"></b>: <span>' + encodeToBase64(row.Remark +'|'+'{{.ip}}:{{.p}}|' + row.VerifyKey + '|false') + '</span> <button class="copy btn btn-info btn-xs" onclick="copyCommand(this)" data-clipboard-text="">复制</button><br/>'
|
|
+ '<b langtag="word-tlsquicklycommand"></b>: <span>' + encodeToBase64(row.Remark +'|'+'{{.ip}}:{{.tls_p}}|' + row.VerifyKey + '|true') + '</span> <button class="copy btn btn-info btn-xs" onclick="copyCommand(this)" data-clipboard-text="">复制</button><br/>'
|
|
+ '<b langtag="word-commandclient"></b>: ' + "<code>{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button><br/>"
|
|
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button>"
|
|
},
|
|
//表格的列
|
|
columns: [
|
|
{
|
|
checkbox: true,
|
|
align: 'center',
|
|
valign: 'middle'
|
|
},
|
|
{
|
|
field: 'Id',//域值
|
|
title: '<span langtag="word-id"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true//false表示不显示
|
|
},
|
|
{
|
|
field: 'Remark',//域值
|
|
title: '<span langtag="word-remark"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true//false表示不显示
|
|
},
|
|
{
|
|
field: 'Version',//域值
|
|
title: '<span langtag="word-version"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true//false表示不显示
|
|
},
|
|
{
|
|
field: 'VerifyKey',//域值
|
|
title: '<span langtag="word-verifykey"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true,//false表示不显示
|
|
formatter: function (value, row, index) {
|
|
if (!row.NoStore) {
|
|
return value
|
|
} else {
|
|
return '<span langtag="word-publicvkey"></span>'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
field: 'Addr',//域值
|
|
title: '<span langtag="word-address"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true//false表示不显示
|
|
},
|
|
{
|
|
field: 'LocalAddr',//域值
|
|
title: '<span langtag="word-localaddr"></span>',//标题
|
|
halign: 'center',
|
|
sortable: true,
|
|
visible: true//false表示不显示
|
|
},
|
|
{
|
|
field: 'InletFlow',//域值
|
|
title: '<span langtag="word-inletflow"></span>',//标题
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
sortable: true,//启用排序
|
|
formatter: function (value, row, index) {
|
|
return changeunit(row.Flow.InletFlow)
|
|
}
|
|
},
|
|
{
|
|
field: 'ExportFlow',//域值
|
|
title: '<span langtag="word-exportflow"></span>',//标题
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
sortable: true,//启用排序
|
|
formatter: function (value, row, index) {
|
|
return changeunit(row.Flow.ExportFlow)
|
|
}
|
|
},
|
|
{
|
|
field: 'NowRate',//域值
|
|
title: '<span langtag="word-speed"></span>',//内容
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
sortable: true,
|
|
formatter: function (value, row, index) {
|
|
return changeunit(row.Rate.NowRate) + "/S"
|
|
}
|
|
},
|
|
{
|
|
field: 'Status',//域值
|
|
title: '<span langtag="word-status"></span>',//内容
|
|
align: 'center',
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
sortable: true,
|
|
formatter: function (value, row, index) {
|
|
if (value) {
|
|
return '<span class="badge badge-primary" langtag="word-open"></span>'
|
|
} else {
|
|
return '<span class="badge badge-badge" langtag="word-close"></span>'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
field: 'IsConnect',//域值
|
|
title: '<span langtag="word-connect"></span>',//内容
|
|
align: 'center',
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
sortable: true,
|
|
formatter: function (value, row, index) {
|
|
if (value) {
|
|
return '<span class="badge badge-primary" langtag="word-online"></span>'
|
|
} else {
|
|
return '<span class="badge badge-badge" langtag="word-offline"></span>'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
field: 'option',//域值
|
|
title: '<span langtag="word-option"></span>',//内容
|
|
align: 'center',
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
formatter: function (value, row, index) {
|
|
btn_group = '<div class="btn-group">'
|
|
|
|
{{if eq true .isAdmin}}
|
|
if (row.Status) {
|
|
btn_group += '<a onclick="submitform(\'stop\', \'{{.web_base_url}}/client/changestatus\', {\'id\':' + row.Id
|
|
btn_group += ', \'status\': 0})" class="btn btn-outline btn-warning"><i class="fa fa-pause"></i></a>'
|
|
} else {
|
|
btn_group += '<a onclick="submitform(\'start\', \'{{.web_base_url}}/client/changestatus\', {\'id\':' + row.Id
|
|
btn_group += ', \'status\': 1})" class="btn btn-outline btn-primary"><i class="fa fa-play"></i></a>'
|
|
}
|
|
btn_group += '<a onclick="submitform(\'delete\', \'{{.web_base_url}}/client/del\', {\'id\':' + row.Id
|
|
btn_group += '})" class="btn btn-outline btn-danger"><i class="fa fa-trash"></i></a>'
|
|
{{end}}
|
|
|
|
btn_group += '<a href="{{.web_base_url}}/client/edit?id=' + row.Id
|
|
btn_group += '" class="btn btn-outline btn-success"><i class="fa fa-edit"></i></a></div>'
|
|
return btn_group
|
|
}
|
|
},
|
|
{
|
|
field: 'show',//域值
|
|
title: '<span langtag="word-show">',//内容
|
|
align: 'center',
|
|
halign: 'center',
|
|
visible: true,//false表示不显示
|
|
formatter: function (value, row, index) {
|
|
return '<div class="btn-group"><a href="{{.web_base_url}}/index/all?client_id=' + row.Id
|
|
+ '" class="btn btn-outline btn-primary" langtag="word-tunnel"></a>'
|
|
+ '<a href="{{.web_base_url}}/index/hostlist?client_id=' + row.Id
|
|
+ '" class="btn btn-outline btn-success" langtag="word-host"></a></div>'
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
function encodeToBase64(str){
|
|
const utf8Str = unescape(encodeURIComponent("nps:"+str));
|
|
return btoa(utf8Str);
|
|
}
|
|
|
|
function copyCommand(data) {
|
|
data.setAttribute("data-clipboard-text", data.previousElementSibling.innerHTML)
|
|
}
|
|
|
|
var clipboard = new ClipboardJS('.copy');
|
|
clipboard.on('success', function (e) {
|
|
// alert("复制成功"+e.text)
|
|
toastr.success('复制成功');
|
|
e.clearSelection();
|
|
});
|
|
|
|
clipboard.on('error', function (e) {
|
|
// alert("复制失败")
|
|
toastr.error('复制失败', '提示');
|
|
});
|
|
|
|
|
|
</script>
|