diff --git a/assets/static/css/index-color.css b/assets/static/css/index-color.css
index f7e29e4..ef37b26 100644
--- a/assets/static/css/index-color.css
+++ b/assets/static/css/index-color.css
@@ -1,6 +1,5 @@
-header {
- background-color: #58b7ff;
- color: #fff;
+.layui-bg-blue {
+ background-color: #58b7ff !important;
}
.layui-btn {
@@ -60,13 +59,29 @@ header {
background-color: #d9ecff;
}
-.layui-table-cell-c:hover{
+.layui-table-cell-c:hover {
border-color: #79bbff;
}
+.layui-nav-tree .layui-nav-child dd.layui-this,
+.layui-nav-tree .layui-nav-child dd.layui-this a,
+.layui-nav-tree .layui-this,
+.layui-nav-tree .layui-this > a,
+.layui-nav-tree .layui-this > a:hover {
+ background-color: #409eff;
+}
+
+.layui-nav-tree .layui-nav-bar {
+ background-color: #409eff;
+}
+
+.proxy-expand .layui-row .layui-row > div:first-child {
+ color: #99a9bf;
+}
+
@media (prefers-color-scheme: dark) {
- header {
- background-color: #395c74;
+ .layui-bg-blue {
+ background-color: #395c74 !important;
}
.layui-btn {
@@ -122,7 +137,19 @@ header {
background-color: rgba(255, 255, 255, .08);
}
- .layui-table-cell-c:hover{
+ .layui-table-cell-c:hover {
border-color: #5f5f60;
}
+
+ .layui-nav-tree .layui-nav-child dd.layui-this,
+ .layui-nav-tree .layui-nav-child dd.layui-this a,
+ .layui-nav-tree .layui-this,
+ .layui-nav-tree .layui-this > a,
+ .layui-nav-tree .layui-this > a:hover {
+ background-color: #4f80a1;
+ }
+
+ .layui-nav-tree .layui-nav-bar {
+ background-color: #4f80a1;
+ }
}
\ No newline at end of file
diff --git a/assets/static/css/index.css b/assets/static/css/index.css
index 1a4b504..86ff1f4 100644
--- a/assets/static/css/index.css
+++ b/assets/static/css/index.css
@@ -9,19 +9,31 @@ section {
right: 0;
top: 0;
bottom: 0;
- padding: 15px 15px 0 15px;
- overflow: auto;
+ padding: 15px;
+ overflow: hidden;
box-sizing: border-box;
}
-.layui-header{
+.layui-header {
line-height: 60px;
font-size: 16px;
}
-.layui-title{
+.layui-layout-admin .layui-side {
+ width: 225px !important;
+}
+
+.layui-side-scroll {
+ width: 245px !important;
+}
+
+.layui-logo {
+ width: 225px !important;
+}
+
+.layui-title {
position: absolute;
- left: 200px;
+ left: 225px !important;
right: 0;
top: 0;
height: 100%;
@@ -30,6 +42,14 @@ section {
box-sizing: border-box;
}
+.layui-nav.layui-nav-tree {
+ width: 225px !important;
+}
+
+.layui-body {
+ left: 225px;
+}
+
#searchForm input {
height: 30px;
line-height: 28px;
@@ -92,6 +112,10 @@ section.server-info .chart-info {
flex: 1;
}
+section.server-info .text-info{
+ padding: 0 20px;
+}
+
section.server-info .text-row {
display: flex;
font-size: 14px;
@@ -125,4 +149,22 @@ section.server-info .chart-info #trafficChart,
section.server-info .chart-info #countChart {
width: 400px;
height: 250px;
-}
\ No newline at end of file
+}
+
+.toggle-proxy-info-arrow{
+ display: inline-block;
+ transition-duration: 0.2s;
+}
+
+.toggle-proxy-info-arrow.open{
+ transform: rotate(90deg);
+}
+
+.proxy-info .layui-row {
+ font-size: 14px !important;
+ padding: 10px;
+}
+
+.proxy-info .layui-col-xs6 .layui-row{
+ padding: 0;
+}
diff --git a/assets/static/js/index-proxy-list.js b/assets/static/js/index-proxy-list.js
new file mode 100644
index 0000000..20085cb
--- /dev/null
+++ b/assets/static/js/index-proxy-list.js
@@ -0,0 +1,95 @@
+var loadProxyInfo = (function ($) {
+ var size = filesize.partial({base: 2, standard: "jedec"});
+ var i18n = {};
+
+ /**
+ * get proxy info
+ * @param lang {{}} language json
+ * @param title page title
+ * @param proxyType proxy type
+ */
+ function loadProxyInfo(lang, title, proxyType) {
+ i18n = lang;
+ $("#title").text(title);
+ $('#content').empty();
+ var loading = layui.layer.load();
+
+ $.getJSON('/proxy/api/proxy/' + proxyType).done(function (result) {
+ if (result.success) {
+ $('#content').html($('#proxyListTableTemplate').html());
+ renderProxyListTable(JSON.parse(result.data)['proxies'], proxyType);
+ } else {
+ layui.layer.msg(result.message);
+ }
+ }).always(function () {
+ layui.layer.close(loading);
+ });
+ }
+
+ /**
+ * render proxy list table
+ * @param data proxy data
+ * @param proxyType proxy type
+ */
+ function renderProxyListTable(data, proxyType) {
+ data = data.concat(data)
+ data = data.concat(data)
+ var $section = $('#content > section');
+ var cols = [
+ {field: 'id', title: '', width: 30, templet: '#toggleProxyInfoArrowTemplate'},
+ {field: 'name', title: 'Name', sort: true},
+ {
+ field: 'port', title: 'Port', sort: true, templet: '{{ d.conf.remote_port }}'
+ },
+ {field: 'cur_conns', title: 'Connections', sort: true},
+ {
+ field: 'today_traffic_in', title: 'Traffic In', sort: true, templet: function (d) {
+ return size(d.today_traffic_in);
+ }
+ },
+ {
+ field: 'today_traffic_out', title: 'Traffic Out', sort: true, templet: function (d) {
+ return size(d.today_traffic_out);
+ }
+ },
+ {field: 'client_version', title: 'ClientVersion', sort: true},
+ {field: 'status', title: 'Status', sort: true}
+ ];
+ var proxyListTable = layui.table.render({
+ elem: '#proxyListTable',
+ height: $section.height(),
+ text: {none: i18n['EmptyData']},
+ cols: [cols],
+ page: navigator.language.indexOf("zh") !== -1,
+ data: data,
+ done: function (res, curr, count, origin) {
+ //向每一行tr后面追加显示子table的tr
+ var $tr = $('.layui-table-view[lay-id=' + this.id + '] tbody tr');
+ var expandTrTemplateHtml = $('#expandTrTemplate').html();
+ for (var i = 0; i < $tr.length; i++) {
+ var html = layui.laytpl(expandTrTemplateHtml).render({
+ index: i,
+ colspan: cols.length - 1,
+ proxyType: proxyType,
+ data: res.data[i]
+ });
+ $($tr[i]).after(html);
+ }
+ }
+ });
+
+ layui.table.on('tool(proxyListTable)', function (obj) {
+ var index = obj.index;
+ $(this).toggleClass('open');
+ var open = $(this).hasClass('open');
+ $('#childTr_' + index).toggleClass('layui-hide', !open);
+ proxyListTable.resize();
+ });
+
+ window.onresize = function () {
+ proxyListTable.resize();
+ }
+ }
+
+ return loadProxyInfo;
+})(layui.$);
\ No newline at end of file
diff --git a/assets/static/js/index-server-info.js b/assets/static/js/index-server-info.js
index 04301cd..3ca5303 100644
--- a/assets/static/js/index-server-info.js
+++ b/assets/static/js/index-server-info.js
@@ -1,19 +1,26 @@
var loadServerInfo = (function ($) {
var size = filesize.partial({base: 2, standard: "jedec"});
+ var i18n = {};
/**
* get server info
* @param lang {{}} language json
+ * @param title page title
*/
function loadServerInfo(lang, title) {
- console.log(title)
+ i18n = lang;
$("#title").text(title);
$('#content').empty();
var loading = layui.layer.load();
$.getJSON('/proxy/api/serverinfo').done(function (result) {
if (result.success) {
- renderServerInfo(JSON.parse(result.data));
+ var data = JSON.parse(result.data);
+ data.proxy_counts = 0;
+ for (var proxy in data.proxy_type_count) {
+ data.proxy_counts = data.proxy_counts + data.proxy_type_count[proxy];
+ }
+ renderServerInfo(data);
} else {
layui.layer.msg(result.message);
}
@@ -22,6 +29,10 @@ var loadServerInfo = (function ($) {
});
}
+ /**
+ * render server info page
+ * @param data server info data
+ */
function renderServerInfo(data) {
var html = layui.laytpl($('#serverInfoTemplate').html()).render(data);
$('#content').html(html);
@@ -30,10 +41,14 @@ var loadServerInfo = (function ($) {
renderCountChart(data);
}
+ /**
+ * render traffic chart with echarts
+ * @param data traffic data
+ */
function renderTrafficChart(data) {
var chartData = [
- {value: data.total_traffic_in, name: 'total_traffic_in'},
- {value: data.total_traffic_out, name: 'total_traffic_out'}
+ {value: data.total_traffic_in, name: 'Traffic In'},
+ {value: data.total_traffic_out, name: 'Traffic Out'}
];
var chartDom = document.getElementById('trafficChart');
var chart = echarts.init(chartDom);
@@ -74,6 +89,10 @@ var loadServerInfo = (function ($) {
option && chart.setOption(option);
}
+ /**
+ * render proxy count chat with echarts
+ * @param data proxy count data
+ */
function renderCountChart(data) {
var proxies = data.proxy_type_count;
var charLegend = [];
@@ -81,7 +100,7 @@ var loadServerInfo = (function ($) {
for (var type in proxies) {
var temp = {
- name: type,
+ name: type.toUpperCase(),
value: proxies[type]
};
charLegend.push(type);
diff --git a/assets/static/js/index-user-list.js b/assets/static/js/index-user-list.js
index 6027eb1..3e5f280 100644
--- a/assets/static/js/index-user-list.js
+++ b/assets/static/js/index-user-list.js
@@ -139,6 +139,7 @@ var loadUserList = (function ($) {
/**
* load i18n language
* @param lang {{}} language json
+ * @param title page title
*/
function loadUserList(lang, title) {
$("#title").text(title);
@@ -245,8 +246,8 @@ var loadUserList = (function ($) {
where: {},
dataType: 'json',
editTrigger: 'dblclick',
- page: navigator.language.indexOf("zh") === 0,
- toolbar: '#toolbarTemplate',
+ page: navigator.language.indexOf("zh") !== -1,
+ toolbar: '#userListToolbarTemplate',
defaultToolbar: false,
text: {none: lang['EmptyData']},
cols: [[
@@ -264,7 +265,7 @@ var loadUserList = (function ($) {
templet: '{{d.status? "' + lang['Enable'] + '":"' + lang['Disable'] + '"}}',
sort: true
},
- {title: lang['Operation'], width: 150, toolbar: '#operationTemplate'}
+ {title: lang['Operation'], width: 150, toolbar: '#userListOperationTemplate'}
]]
});
@@ -388,7 +389,7 @@ var loadUserList = (function ($) {
type: 1,
title: lang['NewUser'],
area: ['500px'],
- content: layui.laytpl(document.getElementById('addTemplate').innerHTML).render(),
+ content: layui.laytpl(document.getElementById('addUserTemplate').innerHTML).render(),
btn: [lang['Confirm'], lang['Cancel']],
btn1: function (index) {
if (layui.form.validate('#addUserForm')) {
diff --git a/assets/static/js/index.js b/assets/static/js/index.js
index eabc37a..c4d4175 100644
--- a/assets/static/js/index.js
+++ b/assets/static/js/index.js
@@ -3,10 +3,17 @@
var langLoading = layui.layer.load()
$.getJSON('/lang').done(function (lang) {
layui.element.on('nav(leftNav)', function (elem) {
- if (elem.attr('id') === 'serverInfo') {
- loadServerInfo(lang, elem.text().trim());
- } else if (elem.attr('id') === 'userList') {
- loadUserList(lang, elem.text().trim());
+ var id = elem.attr('id');
+ var title = elem.text();
+ if (id === 'serverInfo') {
+ loadServerInfo(lang, title.trim());
+ } else if (id === 'userList') {
+ loadUserList(lang, title.trim());
+ } else if (elem.closest('.layui-nav-item').attr('id') === 'proxyList') {
+ if (id != null && id.trim() !== '') {
+ var suffix = elem.closest('.layui-nav-item').children('a').text().trim();
+ loadProxyInfo(lang, title + " " + suffix, id);
+ }
}
});
diff --git a/assets/templates/index.html b/assets/templates/index.html
index 8e55e1e..d981da6 100644
--- a/assets/templates/index.html
+++ b/assets/templates/index.html
@@ -11,9 +11,10 @@
+