init
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<div class="layui-tab layui-tab-brief">
|
||||
<ul class="layui-tab-title site-demo-title">
|
||||
<li class="layui-this add-client-title"></li>
|
||||
</ul>
|
||||
<div class="main-content">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label i18n-client-name"></label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="name" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label i18n-client-key"></label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="clientKey" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid"><a class="layui-btn layui-btn-mini random-key random"></a></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn add"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(".add-client-title").html($.i18n.prop('client.add'));
|
||||
$(".i18n-client-name").html($.i18n.prop('client.name'));
|
||||
$(".i18n-client-key").html($.i18n.prop('client.key'));
|
||||
$("input[name='name']").attr("placeholder", $.i18n.prop('client.name.placeholder'));
|
||||
$("input[name='clientKey']").attr("placeholder", $.i18n.prop('client.key.placeholder'));
|
||||
$(".random").html($.i18n.prop('client.randomkey'));
|
||||
$(".add").html($.i18n.prop('public.submit'));
|
||||
$(".random").click(function(){
|
||||
$("input[name='clientKey']").val(uuid());
|
||||
});
|
||||
|
||||
$(".add").click(function(){
|
||||
var name = $("input[name='name']").val();
|
||||
if(name == ""){
|
||||
layer.alert($.i18n.prop('client.notice.inputname'), {
|
||||
title: $.i18n.prop('public.tips')
|
||||
});
|
||||
return;
|
||||
}
|
||||
var clientKey = $("input[name='clientKey']").val();
|
||||
if(clientKey == ""){
|
||||
layer.alert($.i18n.prop('client.notice.inputkey'), {
|
||||
title: $.i18n.prop('public.tips')
|
||||
});
|
||||
return;
|
||||
}
|
||||
clientList.push({
|
||||
name:name,
|
||||
clientKey:clientKey,
|
||||
proxyMappings:[]
|
||||
});
|
||||
|
||||
api_invoke("/config/update", clientList, function(data) {
|
||||
if (data.code == 20000) {
|
||||
layer.alert($.i18n.prop('client.notice.addsuccess'), {title: $.i18n.prop('public.tips')}, function(index){
|
||||
layer.close(index);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".back").click(function(){
|
||||
load_page("html/client/list.html");
|
||||
});
|
||||
|
||||
function uuid() {
|
||||
var s = [];
|
||||
var hexDigits = "0123456789abcdef";
|
||||
for (var i = 0; i < 36; i++) {
|
||||
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
||||
}
|
||||
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||
s[8] = s[13] = s[18] = s[23] = "";
|
||||
|
||||
var uuid = s.join("");
|
||||
return uuid;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,73 @@
|
||||
<div class="layui-tab layui-tab-brief">
|
||||
<ul class="layui-tab-title site-demo-title">
|
||||
<li class="layui-this edit-client-title"></li>
|
||||
</ul>
|
||||
<div class="main-content">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label i18n-client-name"></label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="name" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label i18n-client-key"></label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="clientKey" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid"><a class="layui-btn layui-btn-mini random-key random"></a></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn update"></button>
|
||||
<button class="layui-btn layui-btn-primary back"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(".edit-client-title").html($.i18n.prop('client.edit'));
|
||||
$(".i18n-client-name").html($.i18n.prop('client.name'));
|
||||
$(".i18n-client-key").html($.i18n.prop('client.key'));
|
||||
$("input[name='name']").attr("placeholder", $.i18n.prop('client.name.placeholder'));
|
||||
$("input[name='clientKey']").attr("placeholder", $.i18n.prop('client.key.placeholder'));
|
||||
$(".random").html($.i18n.prop('client.randomkey'));
|
||||
$(".update").html($.i18n.prop('public.submit'));
|
||||
$(".back").html($.i18n.prop('public.back'));
|
||||
$("input[name='name']").val(clientList[clientIndex].name);
|
||||
$("input[name='clientKey']").val(clientList[clientIndex].clientKey);
|
||||
|
||||
$(".random").click(function(){
|
||||
$("input[name='clientKey']").val(uuid());
|
||||
});
|
||||
|
||||
$(".update").click(function(){
|
||||
clientList[clientIndex]['name'] = $("input[name='name']").val();
|
||||
clientList[clientIndex]['clientKey'] = $("input[name='clientKey']").val();
|
||||
api_invoke("/config/update", clientList, function(data) {
|
||||
if (data.code == 20000) {
|
||||
layer.alert($.i18n.prop('public.notice.updatesuccess'), {title: $.i18n.prop('public.tips')}, function(index){
|
||||
layer.close(index);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".back").click(function(){
|
||||
load_page("html/client/list.html");
|
||||
});
|
||||
|
||||
function uuid() {
|
||||
var s = [];
|
||||
var hexDigits = "0123456789abcdef";
|
||||
for (var i = 0; i < 36; i++) {
|
||||
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
||||
}
|
||||
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||
s[8] = s[13] = s[18] = s[23] = "";
|
||||
|
||||
var uuid = s.join("");
|
||||
return uuid;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,75 @@
|
||||
<div class="layui-tab layui-tab-brief">
|
||||
<ul class="layui-tab-title site-demo-title">
|
||||
<li class="layui-this detail-page"></li>
|
||||
</ul>
|
||||
<div class="main-content"></div>
|
||||
</div>
|
||||
<script>
|
||||
$(".layui-this.detail-page").html($.i18n.prop('client.list'));
|
||||
window.clientList = [];
|
||||
api_invoke("/config/detail", {}, function(data) {
|
||||
if (data.code == 20000) {
|
||||
clientList = data.data;
|
||||
var html = template($("#client-tpl").html(), data);
|
||||
$(".main-content").html(html);
|
||||
$(".mapping-config").click(function() {
|
||||
window.clientIndex = $(this).attr("data-index");
|
||||
load_page("html/lan/list.html");
|
||||
});
|
||||
$(".client-edit").click(function() {
|
||||
window.clientIndex = $(this).attr("data-index");
|
||||
load_page("html/client/edit.html");
|
||||
});
|
||||
$(".client-delete").click(function() {
|
||||
window.clientIndex = $(this).attr("data-index");
|
||||
layer.confirm($.i18n.prop('public.confirm.delete'), {
|
||||
title: $.i18n.prop('public.tips'),
|
||||
btn : [ $.i18n.prop('public.ok'), $.i18n.prop('public.cancel') ]
|
||||
}, function(i) {
|
||||
layer.close(i);
|
||||
clientList.splice(clientIndex, 1);
|
||||
api_invoke("/config/update", clientList, function(data) {
|
||||
if (data.code != 20000) {
|
||||
layer.alert(data.message);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script id="client-tpl" type="text/html">
|
||||
<table class="layui-table" lay-skin="line">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="th-client-name"><%:=$.i18n.prop('client.name')%></th>
|
||||
<th class="th-client-key"><%:=$.i18n.prop('client.key')%></th>
|
||||
<th class="th-status"><%:=$.i18n.prop('client.status')%></th>
|
||||
<th class="th-options"><%:=$.i18n.prop('public.options')%></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%for(var i = 0; i < data.length; i++) {%>
|
||||
<tr>
|
||||
<td><%:=data[i].name%></td>
|
||||
<td><%:=data[i].clientKey%></td>
|
||||
<td>
|
||||
<% if(data[i].status == 1){ %>
|
||||
<span class="layui-badge layui-bg-green"><%:=$.i18n.prop('client.status.online')%></span>
|
||||
<% } else { %>
|
||||
<span class="layui-badge layui-bg-gray"><%:=$.i18n.prop('client.status.offline')%></span>
|
||||
<% }%>
|
||||
</td>
|
||||
<td>
|
||||
<a data-index="<%:=i%>" class="layui-btn layui-btn-mini client-edit"><%:=$.i18n.prop('public.edit')%></a>
|
||||
<a data-index="<%:=i%>" class="layui-btn layui-btn-danger layui-btn-mini client-delete"><%:=$.i18n.prop('public.delete')%></a>
|
||||
</td>
|
||||
</tr>
|
||||
<%}%>
|
||||
</tbody>
|
||||
</table>
|
||||
</script>
|
||||
Reference in New Issue
Block a user