mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
remove unused sturct;
add new user popup
This commit is contained in:
@@ -55,7 +55,7 @@ section {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.layui-title #logout{
|
||||
.layui-title #logout {
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
@@ -154,3 +154,26 @@ section.common-info .text-row {
|
||||
section.common-info .text-row .text-col {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#addProxyForm {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#addProxyForm .layui-tab {
|
||||
margin: 15px 15px 0 15px;
|
||||
}
|
||||
|
||||
#addProxyForm .layui-tab .layui-tab-content {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
#addProxyForm .layui-textarea {
|
||||
min-height: 80px;
|
||||
padding: 9px 10px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
#addProxyForm .layui-row .layui-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ var loadProxyInfo = (function ($) {
|
||||
text: {none: i18n['EmptyData']},
|
||||
cols: [cols],
|
||||
page: navigator.language.indexOf("zh") !== -1,
|
||||
toolbar: '#proxyListToolbarTemplate',
|
||||
defaultToolbar: false,
|
||||
data: dataList,
|
||||
initSort: {
|
||||
field: 'name',
|
||||
@@ -75,6 +77,21 @@ var loadProxyInfo = (function ($) {
|
||||
* bind event of {{@link layui.form}}
|
||||
*/
|
||||
function bindFormEvent() {
|
||||
layui.table.on('toolbar(proxyListTable)', function (obj) {
|
||||
var id = obj.config.id;
|
||||
var checkStatus = layui.table.checkStatus(id);
|
||||
var data = checkStatus.data;
|
||||
|
||||
switch (obj.event) {
|
||||
case 'add':
|
||||
addPopup();
|
||||
break
|
||||
case 'remove':
|
||||
// batchRemovePopup(data);
|
||||
break
|
||||
}
|
||||
});
|
||||
|
||||
layui.table.on('tool(proxyListTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
|
||||
@@ -89,5 +106,115 @@ var loadProxyInfo = (function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add proxy popup
|
||||
*/
|
||||
function addPopup() {
|
||||
layui.layer.open({
|
||||
type: 1,
|
||||
title: 'NewProxy',
|
||||
area: ['500px'],
|
||||
content: layui.laytpl(document.getElementById('addProxyTemplate').innerHTML).render(),
|
||||
btn: ['Confirm', 'Cancel'],
|
||||
btn1: function (index) {
|
||||
if (layui.form.validate('#addProxyTemplate')) {
|
||||
var formData = layui.form.val('addProxyTemplate');
|
||||
add(formData, index);
|
||||
}
|
||||
},
|
||||
btn2: function (index) {
|
||||
layui.layer.close(index);
|
||||
},
|
||||
success: function (layero, index, that) {
|
||||
layero.find('.layui-layer-content').css('overflow', 'visible');
|
||||
layui.form.render(null, 'addProxyForm');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add proxy action
|
||||
* @param data {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} user data
|
||||
* @param index popup index
|
||||
*/
|
||||
function add(data, index) {
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/add',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
success: function (result) {
|
||||
// if (result.success) {
|
||||
// reloadTable();
|
||||
// layui.layer.close(index);
|
||||
// layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||
// layui.layer.close(index);
|
||||
// });
|
||||
// } else {
|
||||
// errorMsg(result);
|
||||
// }
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* update proxy action
|
||||
* @param before {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} data before update
|
||||
* @param after {{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}} data after update
|
||||
*/
|
||||
function update(before, after) {
|
||||
before.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port))) {
|
||||
before.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
after.ports.forEach(function (port, index) {
|
||||
if (/^\d+$/.test(String(port)) && typeof port === "string") {
|
||||
after.ports[index] = parseInt(String(port));
|
||||
}
|
||||
});
|
||||
var loading = layui.layer.load();
|
||||
$.ajax({
|
||||
url: '/update',
|
||||
type: 'post',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
before: before,
|
||||
after: after,
|
||||
}),
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layui.layer.msg(i18n['OperateSuccess']);
|
||||
} else {
|
||||
errorMsg(result);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
layui.layer.close(loading);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* batch remove proxy popup
|
||||
* @param data {[{user:string, token:string, comment:string, enable:boolean, ports:[string|number], domains:[string], subdomains:[string]}]} user data list
|
||||
*/
|
||||
function batchRemovePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg(i18n['ShouldCheckUser']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm(i18n['ConfirmRemoveUser'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
operate(apiType.Remove, data, index);
|
||||
});
|
||||
}
|
||||
|
||||
return loadProxyInfo;
|
||||
})(layui.$);
|
||||
@@ -143,6 +143,89 @@
|
||||
</section>
|
||||
</script>
|
||||
|
||||
<!--用户列表-添加用户表单模板-->
|
||||
<script type="text/html" id="addProxyTemplate">
|
||||
<form class="layui-form" id="addProxyForm" lay-filter="addProxyForm">
|
||||
<div class="layui-tab layui-tab-brief">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">Basic</li>
|
||||
<li>Extra</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">ProxyType</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="type" id="type">
|
||||
<option value="http">HTTP</option>
|
||||
<option value="https">HTTPS</option>
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="udp">UDP</option>
|
||||
<option value="stcp">STCP</option>
|
||||
<option value="sudp">SUDP</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">LocalIp</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="local_ip" placeholder="LocalIp"
|
||||
autocomplete="off" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">LocalPort</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="local_port" placeholder="LocalPort"
|
||||
autocomplete="off" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide http https">
|
||||
<label class="layui-form-label">CustomizeDomains</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="custom_domains" placeholder="CustomDomains" autocomplete="off"
|
||||
class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text layui-hide http https">
|
||||
<label class="layui-form-label">Subdomain</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="subdomain" placeholder="Subdomain" autocomplete="off"
|
||||
class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide tcp udp">
|
||||
<label class="layui-form-label">RemotePort</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="remote_port" placeholder="RemotePort"
|
||||
autocomplete="off" class="layui-input"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">UseEncryption</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="use_encryption" value="true" title="ON">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">UseCompression</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="use_compression" value="true" title="ON">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">内容-2</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<!--代理列表-代理表格模板-->
|
||||
<script type="text/html" id="proxyListTableTemplate">
|
||||
<section class="proxy-list">
|
||||
@@ -150,6 +233,14 @@
|
||||
</section>
|
||||
</script>
|
||||
|
||||
<!--代理列表-表格工具条按钮模板-->
|
||||
<script type="text/html" id="proxyListToolbarTemplate">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="add">NewProxy</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="remove">RemoveProxy</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!--代理列表-操作按钮模板-->
|
||||
<script type="text/html" id="proxyListOperationTemplate">
|
||||
<div class="layui-clear-space">
|
||||
|
||||
Reference in New Issue
Block a user