frp/assets/index.html

311 lines
9.9 KiB
HTML
Raw Normal View History

2016-08-09 21:17:02 +08:00
<!DOCTYPE HTML>
<html>
<head>
2016-08-09 21:28:43 +08:00
<title>frp</title>
2016-08-09 21:17:02 +08:00
<link href="static/bootstrap.min.css" rel="stylesheet">
<script src="static/jquery.min.js"></script>
<script src="static/bootstrap.min.js"></script>
2016-08-09 21:28:43 +08:00
<link href="static/iconfont.css" rel="stylesheet">
2016-08-09 21:17:02 +08:00
</head>
<body>
<div class="container-fluid">
2016-08-09 21:28:43 +08:00
<!--div class="row">
<div class="col-sm-12 text-center">
<h1 class="logo">frp</h1>
</div>
</div-->
2016-08-09 21:17:02 +08:00
<div class="row">
<div class="col-md-5 col-sm-offset-1">
<div class="panel panel-default">
<div ng-app="myTable" class="panel-body">
<table class="table table-bordered" ng-app="myTable" ng-controller="myCtrl">
<thead>
<tr>
2016-08-09 21:28:43 +08:00
<th class="tab_info" ng-click="col='name';desc=!desc">Server<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='type';desc=!desc">Type<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='bind_addr';desc=!desc">Ip<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='listen_port';desc=!desc">Port<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='status';desc=!desc">Status<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='current_conns';desc=!desc">CurCon<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='daily[0].flow_out';desc=!desc">FlowOut<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='daily[0].flow_in';desc=!desc">FlowIn<i class="iconfont pull-right">&#xe66d;</i></th>
2016-08-09 21:17:02 +08:00
</tr>
</thead>
2016-08-09 21:28:43 +08:00
<tbody id="tab_body">
2016-08-09 21:17:02 +08:00
<tr ng-repeat="x in proxies|orderBy:col:desc">
<td>
<button class="btn btn-xs btn-block btn-success center-block" onclick="changeit(this)"><span ng-bind="x.name"></span></button>
</td>
<td><span ng-bind="x.type"></span></td>
<td><span ng-bind="x.bind_addr"></span></td>
<td><span ng-bind="x.listen_port"></span></td>
<td><span ng-bind="x.status"></span></td>
<td><span ng-bind="x.current_conns"></span></td>
<td><span ng-bind="x.daily[0].flow_out"></span></td>
<td><span ng-bind="x.daily[0].flow_in"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-5">
2016-08-09 21:28:43 +08:00
<div id="view1" style="height: 300pt"></div>
<div id="view2" style="height: 300pt"></div>
2016-08-09 21:17:02 +08:00
</div>
</div>
</div>
<script src="static/angular.min.js"></script>
<script type="text/javascript" src="static/echarts.min.js"></script>
<script>
var alldata = new Array();
var index = null;
2016-08-09 21:28:43 +08:00
<<< range .proxies >>>
2016-08-09 21:17:02 +08:00
alldata["<<< .name >>>"] = {
name: "<<< .name >>>",
type: "<<< .type >>>",
bind_addr: "<<< .bind_addr >>>",
listen_port: "<<< .listen_port >>>",
2016-08-09 21:28:43 +08:00
current_conns: <<< .current_conns >>> ,
2016-08-09 21:17:02 +08:00
domains: [ <<< range.custom_domains >>> "<<< . >>>", <<< end >>> ],
stat: "<<< .status >>>",
use_encryption: "<<< .use_encryption >>>",
use_gzip: "<<< .use_gzip >>>",
privilege_mode: "<<< .privilege_mode >>>",
2016-08-09 21:28:43 +08:00
times: [],
ins: [],
outs: [],
conns: [],
2016-08-09 21:17:02 +08:00
};
<<< end >>>
2016-08-09 21:28:43 +08:00
var newproxies = <<< . >>>;
2016-08-09 21:17:02 +08:00
var dom1 = document.getElementById("view1");
var dom2 = document.getElementById("view2");
var myChart1 = echarts.init(dom1);
var myChart2 = echarts.init(dom2);
var option1 = null;
var option2 = null;
var maxval = 0;
var dw = " B";
var step = 1;
function reloadview() {
2016-08-09 21:28:43 +08:00
console.log("in reloadview index:", index);
2016-08-09 21:17:02 +08:00
window.maxval = 0;
window.dw = " B";
window.step = 1;
for (var val1 in alldata[index].ins) {
if (maxval < alldata[index].ins[val1]) {
window.maxval = alldata[index].outs[val1];
}
}
for (var val2 in alldata[index].outs) {
if (maxval < alldata[index].outs[val2]) {
window.maxval = alldata[index].outs[val2]
}
}
if (maxval > 1024 * 1024) {
window.dw = " MB";
window.step = 1024 * 1024;
} else if (maxval > 1024) {
window.dw = " KB";
window.step = 1024;
}
2016-08-09 21:28:43 +08:00
window.option1 = {
2016-08-09 21:17:02 +08:00
title: {
text: alldata[index].name
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['flow_in', 'flow_out']
},
grid: {
left: '3%',
right: '6%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: alldata[index].times
},
yAxis: {
type: 'value',
axisLabel: {
formatter: function(value) {
var data = (value / step).toFixed(2);
return data + dw;
}
}
},
series: [{
name: 'flow_in',
type: 'line',
stack: '总量',
data: alldata[index].ins
}, {
name: 'flow_out',
type: 'line',
stack: '总量',
data: alldata[index].outs
}]
};
2016-08-09 21:28:43 +08:00
window.option2 = {
2016-08-09 21:17:02 +08:00
title: {
text: ""
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['total_accept_conns']
},
grid: {
left: '3%',
right: '6%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: alldata[index].times
},
yAxis: {
type: 'value'
},
series: [{
name: 'total_accept_conns',
type: 'line',
stack: '总量',
data: alldata[index].conns
}]
};
myChart1.setOption(option1, true);
myChart2.setOption(option2, true);
};;
var showdetail = false;
var newindex = 0;
function cleandetail() {
$(".info_detail").remove();
showdetail = false;
};
function changeit(id) {
newindex = id.firstElementChild.innerHTML;
if (index == newindex) {
if (showdetail) {
cleandetail();
return;
}
}
index = newindex;
cleandetail();
window.showdetail = true;
var newrow = "<tr class='info_detail'><th colspan='4'>Key</th><th colspan='4'>Val</th><tr>";
newrow += "<tr class='info_detail'><td colspan='4'>Domains</td><td colspan='4'>" + alldata[index].domains + "</td><tr>";
newrow += "<tr class='info_detail'><td colspan='4'>Status</td><td colspan='4'>" + alldata[index].stat + "</td><tr>";
newrow += "<tr class='info_detail'><td colspan='4'>Encryption</td><td colspan='4'>" + alldata[index].use_encryption + "</td><tr>";
newrow += "<tr class='info_detail'><td colspan='4'>Gzip</td><td colspan='4'>" + alldata[index].use_gzip + "</td><tr>";
newrow += "<tr class='info_detail'><td colspan='4'>Privilege</td><td colspan='4'>" + alldata[index].privilege_mode + "</td><tr>";
var hehe = $(id.parentNode.parentNode);
$(hehe).after(newrow);
reloadview();
};
2016-08-09 21:28:43 +08:00
// add somedata
{
var ttdy = new Date();
var today = ttdy.getFullYear() * 10000 + (1 + ttdy.getMonth()) * 100 + ttdy.getDate();
for (var inx in newproxies.proxies) {
console.log("now inx is ", inx);
if (newproxies.proxies[inx].current_conns == undefined) {
newproxies.proxies[inx].current_conns = 0;
alldata[newproxies.proxies[inx].name].current_conns = 0;
}
if (newproxies.proxies[inx].daily == undefined ) {
newproxies.proxies[inx].daily = [];
}
newproxies.proxies[inx].daily.sort(function (a, b) {
return a.time > b.time;
});
for (var iinnx in newproxies.proxies[inx].daily) {
alldata[newproxies.proxies[inx].name].times.push(newproxies.proxies[inx].daily[iinnx].time);
alldata[newproxies.proxies[inx].name].ins.push(newproxies.proxies[inx].daily[iinnx].flow_in);
alldata[newproxies.proxies[inx].name].outs.push(newproxies.proxies[inx].daily[iinnx].flow_out);
alldata[newproxies.proxies[inx].name].conns.push(newproxies.proxies[inx].daily[iinnx].total_accept_conns);
}
if (newproxies.proxies[inx].daily.length == 0 || newproxies.proxies[inx].daily[0].time != today) {
alldata[newproxies.proxies[inx].name].times.push(today);
alldata[newproxies.proxies[inx].name].ins.push(0);
alldata[newproxies.proxies[inx].name].outs.push(0);
alldata[newproxies.proxies[inx].name].conns.push(0);
newproxies.proxies[inx].daily.push({
time: today,
flow_in: 0,
flow_out: 0,
total_accept_conns: 0
});
}
}
}
2016-08-09 21:17:02 +08:00
var app = angular.module('myTable', []);
app.controller('myCtrl', function($scope) {
$scope.col = 'name';
$scope.desc = 0;
2016-08-09 21:28:43 +08:00
$scope.proxies = newproxies.proxies;
2016-08-09 21:17:02 +08:00
});
$(".tab_info").hover(
2016-08-09 21:28:43 +08:00
function() {
$(this).css("color", "orange");
},
function() {
$(this).css("color", "black");
});
// set default index
for (var inx in alldata) {
if (window.index == null || window.index > inx) {
window.index = inx;
}
}
reloadview();
2016-08-09 21:17:02 +08:00
</script>
</body>
</html>