-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. fix swap non exist and throw exception "divided by zero"
2. update non ajax page style
- Loading branch information
1 parent
b294971
commit fc0a487
Showing
4 changed files
with
176 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,8 @@ | |
</head> | ||
<body> | ||
<style> | ||
.circle { | ||
margin: 20px; | ||
width: 150px; | ||
height: 70px; | ||
display: inline-block; | ||
} | ||
.full-circle { | ||
margin: 20px; | ||
width: 100px; | ||
height: 100px; | ||
position: relative; | ||
display: inline-block; | ||
} | ||
.line { | ||
margin: 20px; | ||
width: 70%; | ||
height: 8px; | ||
position: relative; | ||
} | ||
|
@@ -42,14 +28,15 @@ | |
<div class="mdui-panel" mdui-panel> | ||
<div class="mdui-panel-item mdui-panel-item-open"> | ||
<div class="mdui-panel-item-header"> | ||
<div class="mdui-panel-item-title">System Info</div> | ||
<div class="mdui-panel-item-summary">IP, System version, etc.</div> | ||
<i class="mdui-icon material-icons"></i> | ||
<div class="mdui-panel-item-title">{:lang("System Info")}</div> | ||
<div class="mdui-panel-item-summary">{:lang("System Info Description")}</div> | ||
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i> | ||
</div> | ||
<div class="mdui-panel-item-body"> | ||
<div class="mdui-col-xs-12 mdui-col-md-6"> | ||
{foreach $info as $k => $v} | ||
<h4>{$k}</h4> | ||
<h4>{:lang($k)}</h4> | ||
{if $k == 'Update Time'} | ||
<p>{$v|date="Y-m-d H:i:s"}</p> | ||
{else} | ||
|
@@ -58,149 +45,224 @@ <h4>{$k}</h4> | |
{/foreach} | ||
</div> | ||
<div class="mdui-col-xs-12 mdui-col-md-6"> | ||
<h4>Process</h4> | ||
<h4>{:lang("Process")}</h4> | ||
<p>{$json['Process']}</p> | ||
<h4>Connection</h4> | ||
<h4>{:lang("Connection")}</h4> | ||
<p>{$json['Connection']}</p> | ||
<h4>Uptime</h4> | ||
<h4>{:lang("Uptime")}</h4> | ||
<p>{$uptime}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mdui-panel-item mdui-panel-item-open"> | ||
<div class="mdui-panel-item-header"> | ||
<i class="mdui-icon material-icons"></i> | ||
<div class="mdui-panel-item-title">CPU Load</div> | ||
<div class="mdui-panel-item-title">{:lang("CPU Load")}</div> | ||
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i> | ||
</div> | ||
<div class="mdui-panel-item-body"> | ||
<div id="cpu_1_min" class="circle">1 Min</div> | ||
<div id="cpu_5_min" class="circle">5 Min</div> | ||
<div id="cpu_15_min" class="circle">15 Min</div> | ||
<div class="mdui-panel-item-body overflow"> | ||
<div class="mdui-row"> | ||
<div id="cpu_1_min" class="mdui-col-xs-12 mdui-col-md-4" style="height: 300px;"></div> | ||
<div id="cpu_5_min" class="mdui-col-xs-12 mdui-col-md-4" style="height: 300px;"></div> | ||
<div id="cpu_15_min" class="mdui-col-xs-12 mdui-col-md-4" style="height: 300px;"></div> | ||
</div> | ||
<div id="cpu-collection" class="mdui-col-xs-12" style="height: 300px;"></div> | ||
</div> | ||
</div> | ||
<div class="mdui-panel-item mdui-panel-item-open"> | ||
<div class="mdui-panel-item-header"> | ||
<i class="mdui-icon material-icons"></i> | ||
<div class="mdui-panel-item-title">Storage</div> | ||
<div class="mdui-panel-item-title">{:lang("Storage")}</div> | ||
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i> | ||
</div> | ||
<div class="mdui-panel-item-body"> | ||
<div> | ||
<div class="mdui-panel-item-body overflow"> | ||
<div class="mdui-col-lg-3"> | ||
<p>{$json['Disk']['used']} / {$json['Disk']['total']}</p> | ||
<div id="disk_status" class="full-circle"></div> | ||
<div id="disk_status" class="mdui-col-xs-12" style="height: 300px;"></div> | ||
</div> | ||
<div class="mdui-col-lg-9"> | ||
<div id="disk-collection" class="mdui-col-xs-12" style="height: 300px;"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mdui-panel-item mdui-panel-item-open"> | ||
<div class="mdui-panel-item-header"> | ||
<i class="mdui-icon material-icons"></i> | ||
<div class="mdui-panel-item-title">Memory</div> | ||
<div class="mdui-panel-item-summary">Including Physical and Swap.</div> | ||
<div class="mdui-panel-item-title">{:lang("Memory")}</div> | ||
<div class="mdui-panel-item-summary">{:lang("Memory Description")}</div> | ||
<i class="mdui-panel-item-arrow mdui-icon material-icons">keyboard_arrow_down</i> | ||
</div> | ||
<div class="mdui-panel-item-body"> | ||
<div class="mdui-panel-item-body overflow"> | ||
<div> | ||
<p><strong>Memory</strong> {$json['Memory']['Mem']['used']} MB / {$json['Memory']['Mem']['total']} MB</p> | ||
<h4>{:lang('Memory')}</h4> | ||
<p>{$json['Memory']['Mem']['used']} MB / {$json['Memory']['Mem']['total']} MB</p> | ||
<div id="memory_status" class="line"></div> | ||
<div id="memory-collection" class="mdui-col-xs-12" style="height: 300px;"></div> | ||
</div> | ||
<div> | ||
<p><strong>Swap</strong> {$json['Memory']['Swap']['used']} MB / {$json['Memory']['Swap']['total']} MB</p> | ||
<h4>{:lang('Swap')}</h4> | ||
<p>{$json['Memory']['Swap']['used']} MB / {$json['Memory']['Swap']['total']} MB</p> | ||
<div id="swap_status" class="line"></div> | ||
<div id="swap-collection" class="mdui-col-xs-12" style="height: 300px;"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/zdhxiong/[email protected]/dist/js/mdui.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/jquery/[email protected]/dist/jquery.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/kimmobrunfeldt/[email protected]/dist/progressbar.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script> | ||
<script> | ||
var memory_config = { | ||
strokeWidth: 4, | ||
easing: 'easeInOut', | ||
duration: 1400, | ||
color: '#dea4ff', | ||
trailColor: '#eee', | ||
trailWidth: 1, | ||
strokeWidth: 4, easing: 'easeInOut', duration: 1400, color: '#dea4ff', trailColor: '#eee', trailWidth: 1, | ||
svgStyle: {width: '100%', height: '100%'}, | ||
text: { | ||
style: { | ||
// Text color. | ||
// Default: same as stroke color (options.color) | ||
color: '#000', | ||
position: 'absolute', | ||
right: '0', | ||
top: '15px', | ||
padding: 0, | ||
margin: 0, | ||
transform: null | ||
}, | ||
style: {color: '#000', position: 'absolute', right: '0', top: '15px', padding: 0, margin: 0, transform: null}, | ||
autoStyleContainer: false | ||
}, | ||
from: {color: '#FFEA82'}, | ||
to: {color: '#ED6A5A'}, | ||
step: (state, bar) => { | ||
bar.setText(Math.round(bar.value() * 100) + ' %'); | ||
} | ||
from: {color: '#FFEA82'}, to: {color: '#ED6A5A'}, | ||
step: (state, bar) => {bar.setText(Math.round(bar.value() * 100) + ' %');} | ||
}; | ||
var cpu_config = { | ||
strokeWidth: 6, | ||
color: '#000', | ||
trailColor: '#eee', | ||
trailWidth: 1, | ||
easing: 'easeInOut', | ||
duration: 1400, | ||
svgStyle: null, | ||
text: { | ||
value: '', | ||
alignToBottom: false | ||
}, | ||
from: {color: '#42ff96'}, | ||
to: {color: '#ED6A5A'}, | ||
// Set default step function for all animate calls | ||
step: (state, bar) => { | ||
bar.path.setAttribute('stroke', state.color); | ||
var value = Math.round(bar.value() * 100); | ||
bar.setText(value + '%'); | ||
|
||
var common_config = {series: [{type: 'gauge', detail: {formatter: '{value}%'}, axisLine: {lineStyle: {width: 5}}, | ||
splitLine: {show: false}, axisLabel: {show: false}, data: [{}]}]}; | ||
|
||
var disk_config = common_config, cpu_config = common_config; | ||
disk_config.series[0].data[0].value = "{:doubleVal($json['Disk']['percent'])}"; | ||
|
||
echarts.init(document.getElementById('disk_status')).setOption(disk_config); | ||
cpu_config.series[0].data[0] = {value: Math.round("{$json['Load']['1min']}" * 100), name: "1 Min"}; | ||
echarts.init(document.getElementById('cpu_1_min')).setOption(cpu_config); | ||
cpu_config.series[0].data[0] = {value: Math.round("{$json['Load']['5min']}" * 100), name: "5 Min"}; | ||
echarts.init(document.getElementById('cpu_5_min')).setOption(cpu_config); | ||
cpu_config.series[0].data[0] = {value: Math.round("{$json['Load']['15min']}" * 100), name: "15 Min"}; | ||
echarts.init(document.getElementById('cpu_15_min')).setOption(cpu_config); | ||
|
||
new ProgressBar.Line(memory_status, memory_config) | ||
.animate(1-"{:doubleVal($json['Memory']['Mem']['free'])/ doubleVal($json['Memory']['Mem']['total'])}"); | ||
new ProgressBar.Line(swap_status, memory_config) | ||
.animate(1-"{if $json['Memory']['Swap']['total'] == 0}1{else}{:doubleVal($json['Memory']['Swap']['free'])/ doubleVal($json['Memory']['Swap']['total'])}{/if}"); | ||
|
||
$.ajax({ | ||
url: "{:url('api/disk/get', ['token' => $token])}", method: "get", | ||
success: function(e){ | ||
let ctx_disk = echarts.init(document.getElementById('disk-collection')), | ||
option = { | ||
tooltip: {trigger: 'axis', position: function (pt) {return [pt[0], '10%'];}}, | ||
title: {left: 'center', text: '{:lang("Storage")}',}, | ||
xAxis: {type: 'category', boundaryGap: false, data: e.time}, | ||
yAxis: {type: 'value', boundaryGap: [0, '100%']}, | ||
dataZoom: [{type: 'inside', start: 70, end: 100}, { | ||
start: 90, end: 100, handleSize: '80%', | ||
handleStyle: { | ||
color: '#fff', shadowBlur: 3, shadowColor: 'rgba(0, 0, 0, 0.6)', | ||
shadowOffsetX: 2, shadowOffsetY: 2 | ||
}}], | ||
series: [{ | ||
name: 'Disk Usage(GB)', type: 'line', smooth: true, symbol: 'none', sampling: 'average', | ||
itemStyle: {color: 'rgb(4,136,8)'}, | ||
areaStyle: { | ||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ | ||
offset: 0, color: 'rgb(251,220,135)'}, {offset: 1, color: 'rgb(101,255,70)'}]) | ||
}, | ||
data: e.load | ||
}] | ||
}; | ||
ctx_disk.setOption(option); | ||
} | ||
}; | ||
var disk_config = { | ||
color: '#555', | ||
strokeWidth: 4, | ||
trailWidth: 1, | ||
easing: 'easeInOut', | ||
duration: 1400, | ||
text: { | ||
autoStyleContainer: false | ||
}, | ||
from: { color: '#999', width: 1 }, | ||
to: { color: '#000', width: 4 }, | ||
// Set default step function for all animate calls | ||
step: function(state, circle) { | ||
circle.path.setAttribute('stroke', state.color); | ||
circle.path.setAttribute('stroke-width', state.width); | ||
}); | ||
$.ajax({ | ||
url: "{:url('api/memory/get', ['token' => $token])}", method: "get", | ||
success: function(e){ | ||
let ctx_mem = echarts.init(document.getElementById('memory-collection')), | ||
option = { | ||
tooltip: {trigger: 'axis', position: function (pt) {return [pt[0], '10%'];}}, | ||
title: {left: 'center', text: '{:lang("Memory")}',}, | ||
xAxis: {type: 'category', boundaryGap: false, data: e.time}, | ||
yAxis: {type: 'value', boundaryGap: [0, '100%']}, | ||
dataZoom: [{type: 'inside', start: 70, end: 100}, { | ||
start: 0, end: 10, handleSize: '80%', | ||
handleStyle: { | ||
color: '#fff', shadowBlur: 3, shadowColor: 'rgba(0, 0, 0, 0.6)', | ||
shadowOffsetX: 2, shadowOffsetY: 2 | ||
}}], | ||
series: [{ | ||
name: 'Memory Usage(MB)', type: 'line', smooth: true, symbol: 'none', sampling: 'average', | ||
itemStyle: {color: 'rgb(144,5,146)'}, | ||
areaStyle: { | ||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ | ||
offset: 0, color: 'rgb(68,162,255)'}, {offset: 1, color: 'rgb(181,70,255)'}]) | ||
}, | ||
data: e.load | ||
}] | ||
}; | ||
ctx_mem.setOption(option); | ||
} | ||
}); | ||
$.ajax({ | ||
url: "{:url('api/swap/get', ['token' => $token])}", method: "get", | ||
success: function(e){ | ||
let ctx_swap = echarts.init(document.getElementById('swap-collection')), | ||
option = { | ||
tooltip: {trigger: 'axis', position: function (pt) {return [pt[0], '10%'];}}, | ||
title: {left: 'center', text: '{:lang("Swap")}',}, | ||
xAxis: {type: 'category', boundaryGap: false, data: e.time}, | ||
yAxis: {type: 'value', boundaryGap: [0, '100%']}, | ||
dataZoom: [{type: 'inside', start: 70, end: 100}, { | ||
start: 0, end: 10, handleSize: '80%', | ||
handleStyle: { | ||
color: '#fff', shadowBlur: 3, shadowColor: 'rgba(0, 0, 0, 0.6)', | ||
shadowOffsetX: 2, shadowOffsetY: 2 | ||
}}], | ||
series: [ | ||
{ | ||
name: 'Swap Usage(MB)', type: 'line', smooth: true, symbol: 'none', sampling: 'average', | ||
itemStyle: {color: 'rgb(144,5,146)'}, | ||
areaStyle: { | ||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ | ||
offset: 0, color: 'rgb(68,162,255)'}, {offset: 1, color: 'rgb(181,70,255)'}]) | ||
}, | ||
data: e.load | ||
}] | ||
}; | ||
|
||
var value = Math.round(circle.value() * 100); | ||
circle.setText(value + " %"); | ||
ctx_swap.setOption(option); | ||
} | ||
}; | ||
var cpu_1 = new ProgressBar.SemiCircle(cpu_1_min, cpu_config); | ||
var cpu_5 = new ProgressBar.SemiCircle(cpu_5_min, cpu_config); | ||
var cpu_15 = new ProgressBar.SemiCircle(cpu_15_min, cpu_config); | ||
var disk = new ProgressBar.Circle(disk_status, disk_config); | ||
var mem = new ProgressBar.Line(memory_status, memory_config); | ||
var swap = new ProgressBar.Line(swap_status, memory_config); | ||
{if $json['Memory']['Mem']['total'] != 0} | ||
mem.animate(1-{:doubleVal($json['Memory']['Mem']['free'])/ doubleVal($json['Memory']['Mem']['total'])}); | ||
{/if} | ||
{if $json['Memory']['Swap']['total'] != 0} | ||
swap.animate(1-{:doubleVal($json['Memory']['Swap']['free'])/ doubleVal($json['Memory']['Swap']['total'])}); | ||
{/if} | ||
disk.animate({:doubleVal($json['Disk']['percent'])/100}); | ||
}); | ||
$.ajax({ | ||
url: "{:url('api/cpu/get', ['token' => $token])}", method: "get", | ||
success: function(e){ | ||
let ctx_cpu = echarts.init(document.getElementById('cpu-collection')), | ||
option = { | ||
tooltip: {trigger: 'axis', position: function (pt) {return [pt[0], '10%'];}}, | ||
title: {left: 'center', text: '{:lang("CPU Load")}',}, | ||
xAxis: {type: 'category', boundaryGap: false, data: e.time}, | ||
yAxis: {type: 'value', boundaryGap: [0, '100%']}, | ||
dataZoom: [{type: 'inside', start: 70, end: 100}, { | ||
start: 0, end: 10, handleSize: '80%', | ||
handleStyle: { | ||
color: '#fff', shadowBlur: 3, shadowColor: 'rgba(0, 0, 0, 0.6)', | ||
shadowOffsetX: 2, shadowOffsetY: 2 | ||
} | ||
}], | ||
series: [ | ||
{ | ||
name: 'CPU', type: 'line', smooth: true, symbol: 'none', | ||
sampling: 'average', itemStyle: {color: 'rgb(255,24,24)'}, | ||
areaStyle: { | ||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ | ||
offset: 0, color: 'rgb(255, 158, 68)'}, {offset: 1, color: 'rgb(255, 70, 131)'}]) | ||
}, | ||
data: e.load | ||
} | ||
] | ||
}; | ||
|
||
ctx_cpu.setOption(option); | ||
} | ||
}); | ||
|
||
cpu_1.animate({$json['Load']['1min']}); | ||
cpu_5.animate({$json['Load']['5min']}); | ||
cpu_15.animate({$json['Load']['15min']}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.