small-package/luci-app-oaf/luasrc/view/admin_network/dev_status.htm

393 lines
12 KiB
HTML
Raw Normal View History

2021-09-24 23:37:27 +08:00
<style type="text/css">
2022-08-12 20:21:57 +08:00
<% local dsp=require "luci.dispatcher"
-%>#display {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 20px;
}
#main {
min-width: 600px;
height: 300px;
display: inline-block;
flex: 2 2 10%;
}
#main2 {
min-width: 600px;
height: 300px;
display: inline-block;
flex: 2 2 10%;
}
table.imagetable {
font-family: verdana, arial, sans-serif;
font-size: 11px;
color: #333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
padding-top: 10px;
}
< !-- table.imagetable th {
background: #f5f5f5 border-width: 0px;
padding: 5px;
border-style: solid;
border-color: #999999;
}
table.imagetable td {
background: #ffffffff border-width: 0px;
padding: 5px;
border-style: solid;
border-color: #999999;
}
-->
2021-09-24 23:37:27 +08:00
</style>
2021-11-29 20:30:58 +08:00
<script type="text/javascript" src="<%=resource%>/echarts.min.js?v=5.0"></script>
2021-09-24 23:37:27 +08:00
<script type="text/javascript">//<![CDATA[
2022-08-12 20:21:57 +08:00
window.onload = function () {
2021-09-24 23:37:27 +08:00
}
var app_class_data;
var app_time_data;
2022-08-12 20:21:57 +08:00
var mac = '<%=self.mac%>';
function get_display_time(total_time) {
var hour = parseInt(total_time / 3600);
var seconds = total_time % 3600;
var min = parseInt(seconds / 60)
var seconds2 = seconds % 60;
2021-09-24 23:37:27 +08:00
var total_time_str;
if (hour > 0)
2022-08-12 20:21:57 +08:00
total_time_str = hour + "<%:h%>" + min + "<%:m%>"
else {
2021-09-24 23:37:27 +08:00
if (min == 0 && seconds2 != 0)
min = 1;
2022-08-12 20:21:57 +08:00
total_time_str = min + "<%:m%>"
2021-09-24 23:37:27 +08:00
}
return total_time_str;
}
2022-08-12 20:21:57 +08:00
function display_app_visit_view(data) {
2021-09-24 23:37:27 +08:00
var myChart = echarts.init(document.getElementById('main2'));
2022-08-12 20:21:57 +08:00
var dev_array = new Array();
var m2R2Data = new Array()
var total_time = 0
for (var i = 0; i < data.length; i++) {
2021-09-24 23:37:27 +08:00
var dev_obj = data[i];
2022-08-12 20:21:57 +08:00
var m2_obj = {};
m2_obj.value = dev_obj.visit_time;
m2_obj.legendname = dev_obj.app_id;
2021-09-24 23:37:27 +08:00
var tmp_time = get_display_time(dev_obj.visit_time);
2022-08-12 20:21:57 +08:00
m2_obj.name = dev_obj.app_id + " " + tmp_time;
total_time += dev_obj.visit_time
2021-09-24 23:37:27 +08:00
m2R2Data.push(m2_obj);
}
2022-08-12 20:21:57 +08:00
2021-09-24 23:37:27 +08:00
var total_time_str = get_display_time(total_time);
option = {
2022-08-12 20:21:57 +08:00
title: [
{
text: "<%:App Time Statistics%>",
textStyle: {
fontSize: 16,
color: "black"
},
left: "2%"
},
{
text: '',
subtext: total_time_str,
textStyle: {
fontSize: 15,
color: "black"
},
subtextStyle: {
fontSize: 15,
color: 'black'
},
textAlign: "center",
x: '34.5%',
y: '44%',
}],
tooltip: {
trigger: 'item',
formatter: function (parms) {
var total_time = get_display_time(parms.data.value);
var str = parms.seriesName + "</br>" +
parms.marker + "" + parms.data.legendname + "</br>" +
"<%:Visit Time%>: " + total_time + "</br>" +
"<%:Percentage%>: " + parms.percent + "%";
return str;
}
2021-09-24 23:37:27 +08:00
},
2022-08-12 20:21:57 +08:00
legend: {
type: "scroll",
orient: 'vertical',
left: '70%',
align: 'left',
top: 'middle',
textStyle: {
color: '#8C8C8C'
},
height: 250
2021-09-24 23:37:27 +08:00
},
2022-08-12 20:21:57 +08:00
series: [
{
name: "<%:Visit Time%>",
type: 'pie',
center: ['35%', '50%'],
2023-04-03 16:47:27 +08:00
radius: ['58%', '70%'],
2021-09-28 12:38:32 +08:00
clockwise: false,
2022-08-12 20:21:57 +08:00
avoidLabelOverlap: false,
2023-04-03 16:47:27 +08:00
itemStyle: {
borderRadius: 2,
borderColor: "#fff",
borderWidth: 1,
},
2022-08-12 20:21:57 +08:00
label: {
normal: {
show: true,
position: 'outter',
formatter: function (parms) {
2021-09-24 23:37:27 +08:00
return parms.data.legendname
}
2022-08-12 20:21:57 +08:00
}
},
labelLine: {
normal: {
length: 8,
length2: 7,
smooth: true,
}
},
data: m2R2Data
}
]
2021-09-24 23:37:27 +08:00
};
myChart.setOption(option);
}
2022-08-12 20:21:57 +08:00
function display_app_class_view(data) {
2021-09-24 23:37:27 +08:00
console.log("begin display.");
var myChart = echarts.init(document.getElementById('main'));
2022-08-12 20:21:57 +08:00
var dev_array = new Array();
var m2R2Data = new Array()
var total_time = 0
for (var i = 0; i < data.length; i++) {
2021-09-24 23:37:27 +08:00
var dev_obj = data[i];
if (dev_obj.visit_time == 0)
continue;
2022-08-12 20:21:57 +08:00
var m2_obj = {};
m2_obj.value = dev_obj.visit_time;
m2_obj.legendname = dev_obj.name;
2021-09-24 23:37:27 +08:00
var tmp_time = get_display_time(dev_obj.visit_time);
2022-08-12 20:21:57 +08:00
m2_obj.name = dev_obj.name + " " + tmp_time;
total_time += dev_obj.visit_time
2021-09-24 23:37:27 +08:00
m2R2Data.push(m2_obj);
}
2022-08-12 20:21:57 +08:00
2021-09-24 23:37:27 +08:00
var total_time_str = get_display_time(total_time);
2022-08-12 20:21:57 +08:00
2021-09-24 23:37:27 +08:00
option = {
title: [
2022-08-12 20:21:57 +08:00
{
text: "<%:App classification time statistics%>",
textStyle: {
fontSize: 16,
color: "black"
},
left: "2%"
2021-09-24 23:37:27 +08:00
},
2022-08-12 20:21:57 +08:00
{
text: '',
subtext: total_time_str,
textStyle: {
fontSize: 15,
color: "black"
},
subtextStyle: {
fontSize: 15,
color: 'black'
},
textAlign: "center",
x: '34.5%',
y: '44%',
}],
2021-09-24 23:37:27 +08:00
tooltip: {
trigger: 'item',
2022-08-12 20:21:57 +08:00
formatter: function (parms) {
2021-09-24 23:37:27 +08:00
var total_time = get_display_time(parms.data.value);
2022-08-12 20:21:57 +08:00
var str = parms.seriesName + "</br>" +
parms.marker + "" + parms.data.legendname + "</br>" + "<%:Visit Time%>: " + total_time + "</br>" +
"<%:Percentage%>: " + parms.percent + "%";
return str;
2021-09-24 23:37:27 +08:00
}
},
legend: {
2022-08-12 20:21:57 +08:00
type: "scroll",
2021-09-24 23:37:27 +08:00
orient: 'vertical',
2022-08-12 20:21:57 +08:00
left: '70%',
align: 'left',
top: 'middle',
2021-09-24 23:37:27 +08:00
textStyle: {
2022-08-12 20:21:57 +08:00
color: '#8C8C8C'
2021-09-24 23:37:27 +08:00
},
2022-08-12 20:21:57 +08:00
height: 250
2021-09-24 23:37:27 +08:00
},
series: [
{
2022-08-12 20:21:57 +08:00
name: "<%:Visit Time%>",
type: 'pie',
2021-09-24 23:37:27 +08:00
center: ['35%', '50%'],
2023-04-03 16:47:27 +08:00
radius: ['58%', '70%'],
2022-08-12 20:21:57 +08:00
clockwise: false,
2021-09-24 23:37:27 +08:00
avoidLabelOverlap: false,
2023-04-03 16:47:27 +08:00
itemStyle: {
borderRadius: 2,
borderColor: "#fff",
borderWidth: 1,
},
2021-09-24 23:37:27 +08:00
label: {
normal: {
show: true,
position: 'outter',
2022-08-12 20:21:57 +08:00
formatter: function (parms) {
2021-09-24 23:37:27 +08:00
return parms.data.legendname
}
}
},
labelLine: {
normal: {
2022-08-12 20:21:57 +08:00
length: 8,
length2: 7,
smooth: true,
2021-09-24 23:37:27 +08:00
}
},
2022-08-12 20:21:57 +08:00
data: m2R2Data
2021-09-24 23:37:27 +08:00
}
]
};
myChart.setOption(option);
}
2022-08-12 20:21:57 +08:00
new XHR().get('<%=url('admin/network/app_class_visit_time')%>/' + mac, null,
function (x, st) {
2021-09-24 23:37:27 +08:00
display_app_class_view(st);
2022-08-12 20:21:57 +08:00
}
);
2021-09-24 23:37:27 +08:00
new XHR().get('<%=url('admin/network/dev_visit_time')%>/' + mac, null,
2022-08-12 20:21:57 +08:00
function (x, st) {
2021-09-24 23:37:27 +08:00
display_app_visit_view(st);
2022-08-12 20:21:57 +08:00
}
);
new XHR().get('<%=url('admin/network/dev_visit_list')%>/' + mac, null,
function (x, st) {
var tb = document.getElementById('user_status_table');
var str = JSON.stringify(st);
if (st && tb) {
/* clear all rows */
while (tb.rows.length > 1)
tb.deleteRow(1);
for (var i = 0; i < st.length; i++) {
var action_status = ""
if (st[i].latest_action == 1)
action_status = "<%:Filtered%>"
else
action_status = "<%:Unfiltered%>"
var hostname = ""
if (st[i].hostname == "" || st[i].hostname == "*") {
hostname = "--";
}
else {
hostname = st[i].hostname;
}
var tr = tb.insertRow(-1);
tr.className = 'tr cbi-rowstyle-' + ((i % 2) + 1);
tr.insertCell(-1).innerHTML = st[i].appname;
tr.insertCell(-1).innerHTML = hostname;
tr.insertCell(-1).innerHTML = st[i].mac;
tr.insertCell(-1).innerHTML = st[i].first_time;
var hour = parseInt(st[i].total_time / 3600);
var seconds = st[i].total_time % 3600;
var min = parseInt(seconds / 60)
var total_time_str;
if (st[i].latest_action == 1)
total_time_str = "-"
else {
if (hour > 0)
total_time_str = hour + "<%:h%>" + min + "<%:m%>"
else {
if (min == 0)
min = 1;
total_time_str = min + "<%:m%>"
}
}
tr.insertCell(-1).innerHTML = total_time_str;
tr.insertCell(-1).innerHTML = action_status;
var childs = tr.childNodes;
Array.prototype.forEach.call(childs, function (child) {
child.className = 'td';
});
}
}
}
);
2021-09-24 23:37:27 +08:00
//]]></script>
2021-09-28 12:38:32 +08:00
2021-11-29 20:30:58 +08:00
<div class="cbi-section cbi-tblsection">
2021-09-24 23:37:27 +08:00
<div id="display">
2022-08-12 20:21:57 +08:00
<div id="main" class="main left"></div>
<div id="main2" class="main2 left"></div>
2021-09-24 23:37:27 +08:00
</div>
2022-08-12 20:21:57 +08:00
<table class="table cbi-section-table" id="user_status_table">
<tr class="tr table-titles">
<th class="th">
<%:App Name%>
</th>
<th class="th">
<%:Hostname%>
</th>
<th class="th">
<%:Mac%>
</th>
<th class="th">
<%:Start Time%>
</th>
<th class="th">
<%:Visit Time%>
</th>
<th class="th">
<%:Filter Status%>
</th>
</tr>
<tr class="tr table-titles">
<td class="td" colspan="8"><em><br />
<%:Collecting data...%>
</em></td>
</tr>
</table>
</div>