From 9b5439a467a36c37d37293ef6796bf350b867c74 Mon Sep 17 00:00:00 2001
From: aaajiulong <525763728@qq.com>
Date: Wed, 24 Mar 2021 13:48:17 +0800
Subject: [PATCH] chore: Package front-end files
---
packages/cjs/flask-state.js | 4 +++-
packages/cjs/flask-state.min.js | 2 +-
packages/umd/flask-state.js | 4 +++-
packages/umd/flask-state.min.js | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/packages/cjs/flask-state.js b/packages/cjs/flask-state.js
index 003ae20..88b2206 100644
--- a/packages/cjs/flask-state.js
+++ b/packages/cjs/flask-state.js
@@ -333,7 +333,9 @@
initialCPUOptions(cpuCount, data) {
this.cpuOption.legend.data = [];
- this.cpuOption.color = ["#42a5f5", "#26c6da", "#26a69a", "#66bb6a", "#9ccc65", "#d4e157", "#ffee58", "#ffca28", "#ffa726"];
+ this.cpuOption.color = ["#42a5f5", '#F75B81', '#8083E5', '#FBA364',
+ "#A1887F", "#89E8E0", "#FFDE99", "#87EE84",
+ "#EDA8FF", "#FFF176"];
this.cpuOption.legend.selected = {};
this.cpuOption.series = [];
for (let i = 0; i < cpuCount + 1; i++) {
diff --git a/packages/cjs/flask-state.min.js b/packages/cjs/flask-state.min.js
index 56a5e32..ba4e526 100644
--- a/packages/cjs/flask-state.min.js
+++ b/packages/cjs/flask-state.min.js
@@ -10,4 +10,4 @@
'use strict';
-module.exports=function(e){var t={};function s(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)s.d(n,a,function(t){return e[t]}.bind(null,a));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";const n=85,a=75,i=10,o=5,r=1048576;class d{constructor(e){this.language=e,this.mobile=d.isMobile(),this.index=0,this.initFlaskStateContainer(this.mobile),this.setEventListener(),this.initFlaskStateLanguage(this.language),this.setInitParams(),this.mobile&&this.setTagChangeEventListener(this.consoleCpuChart,this.consoleMemoryChart,this.consoleLoadavgChart,this.networkIOChart),window.addEventListener("resize",(()=>{d.resizeChartTimer([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])}))}setFlaskStateData(){document.getElementById("fs-background").style.display="block",document.getElementById("fs-info-container").style.display="block",document.getElementsByTagName("body")[0].style.overflowX="hidden",document.getElementsByTagName("body")[0].style.overflowY="hidden",document.getElementById("fs-select-days").value="1",this.setCharts("1")}initFlaskStateContainer(){let e='
Host Status
Memory
CPU
Disk Usage
Load Avg
Disk IO
Network IO
Uptime
Redis Status
Used Mem
Mem Fragmentation Ratio
Cache Hits Ratio
24h Hits Ratio
Uptime
Connections
'+(this.mobile?'
':"
")+"
";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e)}setEventListener(){if(window.addEventListener){document.getElementById("fs-info-close").addEventListener("click",(function(){document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out")})),document.getElementById("fs-background").addEventListener("click",(function(e){"fs-background"===String(e.target.id)&&(document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out"))}));let e=document.getElementById("fs-select-days");e.addEventListener("change",(()=>{this.setCharts(e.value)}))}}setTagChangeEventListener(...e){if(document.getElementById("fs-info-tab")){let t=document.getElementById("fs-info-tab").getElementsByTagName("li"),s=document.getElementById("fs-info-tab-memory"),n=t[0],a=0;const i={0:"fs-info-tab-memory",1:"fs-info-tab-cpu",2:"fs-info-network-io",3:"fs-info-tab-loadavg"};for(let o of t){let t=document.getElementById(i[a]);o.children[0].addEventListener("click",(()=>{o.classList.add("active"),n.classList.remove("active"),s.classList.remove("fs-show"),t.classList.add("fs-show"),d.resizeChart(e),s=t,n=o})),a++}}}initFlaskStateLanguage(){0!==Object.keys(this.language).length&&(document.getElementById("fs-host-status-title").innerHTML=this.language.host_status,document.getElementById("fs-redis-status-title").innerHTML=this.language.redis_status,document.getElementById("fs-cpu").innerHTML=this.language.cpu,document.getElementById("fs-memory").innerHTML=this.language.memory,document.getElementById("fs-disk-usage").innerHTML=this.language.disk_usage,document.getElementById("fs-load-avg").innerHTML=this.language.load_avg,document.getElementById("fs-disk-io").innerHTML=this.language.disk_io,document.getElementById("fs-network-io").innerHTML=this.language.network_io,document.getElementById("fs-boot-seconds").innerHTML=this.language.boot_seconds,document.getElementById("fs-used-memory").innerHTML=this.language.used_memory,document.getElementById("fs-used-memory-rss").innerHTML=this.language.used_memory_rss,document.getElementById("fs-mem-fragmentation-ratio").innerHTML=this.language.mem_fragmentation_ratio,document.getElementById("fs-hits-ratio").innerHTML=this.language.hits_ratio,document.getElementById("fs-delta-hits-ratio").innerHTML=this.language.delta_hits_ratio,document.getElementById("fs-uptime-in-seconds").innerHTML=this.language.uptime_in_seconds,document.getElementById("fs-connected-clients").innerHTML=this.language.connected_clients,document.getElementById("fs-days").innerHTML=this.language.days)}setInitParams(){this.consoleCpuChart=echarts.init(document.getElementById("fs-info-cpu-chart"),null,{renderer:"svg"}),this.consoleMemoryChart=echarts.init(document.getElementById("fs-info-memory-chart"),null,{renderer:"svg"}),this.consoleLoadavgChart=echarts.init(document.getElementById("fs-info-loadavg-chart"),null,{renderer:"svg"}),this.networkIOChart=echarts.init(document.getElementById("fs-info-networkio-chart"),null,{renderer:"svg"}),this.cpuOption=d.generateChatOption(this.mobile,this.language.cpu||"CPU","cpu",this.language.today||"Today"),this.memoryOption=d.generateChatOption(this.mobile,this.language.memory||"Memory","memory",this.language.today||"Today"),this.networkIOOption=d.generateChatOption(this.mobile,this.language.network_io||"Network IO","networkIO",this.language.today||"Today"),this.loadavgOption=d.generateChatOption(this.mobile,"Load Avg","loadavg",this.language.minutes||"min")}setCharts(e){this.consoleCpuChart.showLoading(),this.consoleMemoryChart.showLoading(),this.consoleLoadavgChart.showLoading(),this.networkIOChart.showLoading(),fetch("/v0/state/hoststatus",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify({timeQuantum:e})}).then((e=>{e.ok&&e.json().then((e=>{if(200!==e.code)return;const t=e.data;let s=t.currentStatistic;if(Object.keys(s).length){let e=document.getElementById("fs-host-status").getElementsByClassName("fs-badge-content");e[0].innerHTML=s.memory+"%",e[1].innerHTML=s.cpu+"%",e[2].innerHTML=s.disk_usage+"%",e[3].innerHTML=s.load_avg[0]+","+s.load_avg[1]+","+s.load_avg[2],e[4].innerHTML="R "+d.getFormatBit(s.disk_read)+" | W "+d.getFormatBit(s.disk_write)+"",e[5].innerHTML="⬇ "+d.getFormatBit(s.net_recv)+" | ⬆ "+d.getFormatBit(s.net_sent)+"",e[6].innerHTML=d.getFormatSeconds(s.boot_seconds||0,this.language.days,this.language.hours,this.language.minutes,this.language.seconds);["memory","cpu","disk_usage","load_avg"].forEach((function(t,r){let d;if("load_avg"===t){let e=(s.load_avg[0]+s.load_avg[1]+s.load_avg[2])/3;d=e>=o?e>=i?"background-red":"background-orange":"background-green"}else d=s[t]>=a?s.memory>=n?"background-red":"background-orange":"background-green";let l=e[r].classList;l.remove("background-green","background-orange","background-red"),l.add(d)}));let t=document.getElementById("fs-redis-status").getElementsByClassName("fs-badge-content"),l=["used_memory","used_memory_rss","mem_fragmentation_ratio","hits_ratio","delta_hits_ratio","uptime_in_seconds","connected_clients"],c=!0;for(let e of l)if(s[e]){c=!1;break}c?(document.getElementById("fs-redis-status-title").innerHTML="",document.getElementById("fs-redis-status-title").style.marginTop="0",document.getElementById("fs-redis-status").style.display="none"):l.forEach(((e,n)=>{switch(e){case"used_memory":case"used_memory_rss":t[n].innerHTML=Math.ceil(s[e]/r)+" M";break;case"mem_fragmentation_ratio":let a=s[e];if(t[n].innerHTML=s[e],null!=a&&a>1){let e=t[n].classList;e.remove("background-green"),e.add("background-red")}break;case"hits_ratio":case"delta_hits_ratio":t[n].innerHTML=s[e]+"%";break;case"uptime_in_seconds":t[n].innerHTML=d.getFormatSeconds(s[e],this.language.days,this.language.hours,this.language.minutes,this.language.seconds);break;case"connected_clients":t[n].innerHTML=s[e]}}))}const l=s.cpu_count;this.initialCPUOptions(l,t),this.cpuOption.xAxis.data=t.host.ts,this.consoleCpuChart.setOption(this.cpuOption),this.networkIOOption.xAxis.data=t.io.ts,this.networkIOOption.series[0].data=t.io.net_recv,this.networkIOOption.series[1].data=t.io.net_sent,this.networkIOChart.setOption(this.networkIOOption),this.memoryOption.xAxis.data=t.host.ts,this.memoryOption.series[0].data=t.host.memory,this.consoleMemoryChart.setOption(this.memoryOption),this.loadavgOption.xAxis.data=t.host.ts,this.loadavgOption.series[0].data=t.host.loadavg,this.loadavgOption.series[1].data=t.host.loadavg5,this.loadavgOption.series[2].data=t.host.loadavg15,this.consoleLoadavgChart.setOption(this.loadavgOption),d.resizeChart([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])})).then((()=>{this.consoleMemoryChart.hideLoading(),this.consoleCpuChart.hideLoading(),this.consoleLoadavgChart.hideLoading(),this.networkIOChart.hideLoading()}))})).catch((function(e){}))}static isMobile(){let e=navigator.userAgent,t={trident:e.indexOf("Trident")>-1,presto:e.indexOf("Presto")>-1,webKit:e.indexOf("AppleWebKit")>-1,gecko:e.indexOf("Gecko")>-1&&-1===e.indexOf("KHTML"),mobile:e.match(/AppleWebKit.*Mobile.*/)&&!0,ios:e.match(/\(i[^;]+;( U;)? CPU.Mac OS X/)&&!0,android:e.indexOf("Android")>-1||e.indexOf("Linux")>-1,iPhone:e.indexOf("iPhone")>-1,iPad:e.indexOf("iPad")>-1,webApp:-1===e.indexOf("Safari"),wechat:e.indexOf("MicroMessenger")>-1,qq:e.match(/\sQQ/i)&&" qq"===e.match(/\sQQ/i)[0]};return t.iPhone||t.iPad||t.webApp||t.wechat||t.qq||t.ios||t.mobile||!1}static resizeChartTimer(e,t){clearTimeout(this.clearId),this.clearId=setTimeout((function(){d.resizeChart(e)}),t||200)}static resizeChart(e){e.forEach((e=>e.resize()))}initialCPUOptions(e,t){this.cpuOption.legend.data=[],this.cpuOption.color=["#42a5f5","#26c6da","#26a69a","#66bb6a","#9ccc65","#d4e157","#ffee58","#ffca28","#ffa726"],this.cpuOption.legend.selected={},this.cpuOption.series=[];for(let s=0;s{let t=echarts.format.formatTime("yyyy-MM-dd hh:mm:ss",new Date(parseInt(1e3*e[0].axisValue)),!1)+"
";if("networkIO"===s){for(let s=0;s";return t}for(let n=0;n";return t}},legend:{textStyle:{fontSize:14},show:"memory"!==s},series:[],grid:{left:"3%",right:"4%",bottom:"3%",top:e?30:60,containLabel:!0},toolbox:{show:!e,feature:{saveAsImage:{title:" "}}},xAxis:{type:"category",boundaryGap:!1,axisLabel:{formatter:function(e){return echarts.format.formatTime("hh:mm",new Date(parseInt(1e3*e)),!1)}}},yAxis:{type:"value",axisLabel:{formatter:e=>{if("networkIO"===s){let t=d.getFormatBit(e,0);return t.substring(0,t.length-2)}return e+("Load Avg"===t?"":"%")}}}};switch(s){case"loadavg":a.color=["#ffa726","#42a5f5","#66bb6a"],a.legend.data=["1 "+n,"5 "+n,"15 "+n],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"networkIO":a.color=["#ffa726","#42a5f5"],a.legend.data=["recv","sent"],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"memory":a.color=["#42a5f5"],a.legend.data=[n],a.series.push({name:n,type:"line",symbol:"none",hoverAnimation:!1})}return a}static getFormatBit(e,t=2){let s,n=e/8;return n>=1e12?(n=(n/1e12).toFixed(t),s="TB/s"):n>=1e9?(n=(n/1e9).toFixed(t),s="GB/s"):n>=1e6?(n=(n/1e6).toFixed(t),s="MB/s"):n>=1e3?(n=(n/1e3).toFixed(t),s="KB/s"):(s="B/s",n=n.toFixed(2)),n+" "+s}static getFormatSeconds(e,t="days",s="hours",n="min",a="seconds"){let i=parseInt(e),o=0,r=0,d=0,l="";return i>=60?(o=i/60,o>=60&&(r=o/60,o%=60),r>=24&&(d=r/24,r%=24)):l=i+a,o>0&&(l=Math.floor(o)+" "+n),r>0&&(l=Math.floor(r)+" "+s),d>0&&(l=Math.floor(d)+" "+t),l}}const l=function(){let e=null;return function(t){return e||(e=new d(t))}}();t.init=function(e){let t=null,s={};if(null!==e&&"object"==typeof e&&(t=e.hasOwnProperty("dom")?e.dom:null,s=e.hasOwnProperty("lang")&&e.lang.hasOwnProperty("language")?e.lang:{}),t instanceof HTMLElement){if(t.getAttribute("flaskState"))return;t.setAttribute("flaskState","true"),t.addEventListener("click",(()=>l(s).setFlaskStateData()))}else{if(document.getElementById("fs-state-circular"))return;let e="";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e);let t,a=document.getElementById("fs-state-circular");function n(e){a.style.top=e.clientY-t+300+"px"}a.onclick=function(){this.classList.add("fs-circular-out"),l(s).setFlaskStateData()},a.onmousedown=function(e){t=t||e.clientY,document.addEventListener("mousemove",n)},document.onmouseup=function(){document.removeEventListener("mousemove",n);const e=parseInt(a.style.top);a.classList.add("fs-circular-animation"),a.style.top=Math.min(Math.max(e,50),window.screen.height-200)+"px",setTimeout((()=>a.classList.remove("fs-circular-animation")),500)}}}}]);
\ No newline at end of file
+module.exports=function(e){var t={};function s(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)s.d(n,a,function(t){return e[t]}.bind(null,a));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";const n=85,a=75,i=10,o=5,r=1048576;class d{constructor(e){this.language=e,this.mobile=d.isMobile(),this.index=0,this.initFlaskStateContainer(this.mobile),this.setEventListener(),this.initFlaskStateLanguage(this.language),this.setInitParams(),this.mobile&&this.setTagChangeEventListener(this.consoleCpuChart,this.consoleMemoryChart,this.consoleLoadavgChart,this.networkIOChart),window.addEventListener("resize",(()=>{d.resizeChartTimer([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])}))}setFlaskStateData(){document.getElementById("fs-background").style.display="block",document.getElementById("fs-info-container").style.display="block",document.getElementsByTagName("body")[0].style.overflowX="hidden",document.getElementsByTagName("body")[0].style.overflowY="hidden",document.getElementById("fs-select-days").value="1",this.setCharts("1")}initFlaskStateContainer(){let e='Host Status
Memory
CPU
Disk Usage
Load Avg
Disk IO
Network IO
Uptime
Redis Status
Used Mem
Mem Fragmentation Ratio
Cache Hits Ratio
24h Hits Ratio
Uptime
Connections
'+(this.mobile?'
':"
")+"
";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e)}setEventListener(){if(window.addEventListener){document.getElementById("fs-info-close").addEventListener("click",(function(){document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out")})),document.getElementById("fs-background").addEventListener("click",(function(e){"fs-background"===String(e.target.id)&&(document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out"))}));let e=document.getElementById("fs-select-days");e.addEventListener("change",(()=>{this.setCharts(e.value)}))}}setTagChangeEventListener(...e){if(document.getElementById("fs-info-tab")){let t=document.getElementById("fs-info-tab").getElementsByTagName("li"),s=document.getElementById("fs-info-tab-memory"),n=t[0],a=0;const i={0:"fs-info-tab-memory",1:"fs-info-tab-cpu",2:"fs-info-network-io",3:"fs-info-tab-loadavg"};for(let o of t){let t=document.getElementById(i[a]);o.children[0].addEventListener("click",(()=>{o.classList.add("active"),n.classList.remove("active"),s.classList.remove("fs-show"),t.classList.add("fs-show"),d.resizeChart(e),s=t,n=o})),a++}}}initFlaskStateLanguage(){0!==Object.keys(this.language).length&&(document.getElementById("fs-host-status-title").innerHTML=this.language.host_status,document.getElementById("fs-redis-status-title").innerHTML=this.language.redis_status,document.getElementById("fs-cpu").innerHTML=this.language.cpu,document.getElementById("fs-memory").innerHTML=this.language.memory,document.getElementById("fs-disk-usage").innerHTML=this.language.disk_usage,document.getElementById("fs-load-avg").innerHTML=this.language.load_avg,document.getElementById("fs-disk-io").innerHTML=this.language.disk_io,document.getElementById("fs-network-io").innerHTML=this.language.network_io,document.getElementById("fs-boot-seconds").innerHTML=this.language.boot_seconds,document.getElementById("fs-used-memory").innerHTML=this.language.used_memory,document.getElementById("fs-used-memory-rss").innerHTML=this.language.used_memory_rss,document.getElementById("fs-mem-fragmentation-ratio").innerHTML=this.language.mem_fragmentation_ratio,document.getElementById("fs-hits-ratio").innerHTML=this.language.hits_ratio,document.getElementById("fs-delta-hits-ratio").innerHTML=this.language.delta_hits_ratio,document.getElementById("fs-uptime-in-seconds").innerHTML=this.language.uptime_in_seconds,document.getElementById("fs-connected-clients").innerHTML=this.language.connected_clients,document.getElementById("fs-days").innerHTML=this.language.days)}setInitParams(){this.consoleCpuChart=echarts.init(document.getElementById("fs-info-cpu-chart"),null,{renderer:"svg"}),this.consoleMemoryChart=echarts.init(document.getElementById("fs-info-memory-chart"),null,{renderer:"svg"}),this.consoleLoadavgChart=echarts.init(document.getElementById("fs-info-loadavg-chart"),null,{renderer:"svg"}),this.networkIOChart=echarts.init(document.getElementById("fs-info-networkio-chart"),null,{renderer:"svg"}),this.cpuOption=d.generateChatOption(this.mobile,this.language.cpu||"CPU","cpu",this.language.today||"Today"),this.memoryOption=d.generateChatOption(this.mobile,this.language.memory||"Memory","memory",this.language.today||"Today"),this.networkIOOption=d.generateChatOption(this.mobile,this.language.network_io||"Network IO","networkIO",this.language.today||"Today"),this.loadavgOption=d.generateChatOption(this.mobile,"Load Avg","loadavg",this.language.minutes||"min")}setCharts(e){this.consoleCpuChart.showLoading(),this.consoleMemoryChart.showLoading(),this.consoleLoadavgChart.showLoading(),this.networkIOChart.showLoading(),fetch("/v0/state/hoststatus",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify({timeQuantum:e})}).then((e=>{e.ok&&e.json().then((e=>{if(200!==e.code)return;const t=e.data;let s=t.currentStatistic;if(Object.keys(s).length){let e=document.getElementById("fs-host-status").getElementsByClassName("fs-badge-content");e[0].innerHTML=s.memory+"%",e[1].innerHTML=s.cpu+"%",e[2].innerHTML=s.disk_usage+"%",e[3].innerHTML=s.load_avg[0]+","+s.load_avg[1]+","+s.load_avg[2],e[4].innerHTML="R "+d.getFormatBit(s.disk_read)+" | W "+d.getFormatBit(s.disk_write)+"",e[5].innerHTML="⬇ "+d.getFormatBit(s.net_recv)+" | ⬆ "+d.getFormatBit(s.net_sent)+"",e[6].innerHTML=d.getFormatSeconds(s.boot_seconds||0,this.language.days,this.language.hours,this.language.minutes,this.language.seconds);["memory","cpu","disk_usage","load_avg"].forEach((function(t,r){let d;if("load_avg"===t){let e=(s.load_avg[0]+s.load_avg[1]+s.load_avg[2])/3;d=e>=o?e>=i?"background-red":"background-orange":"background-green"}else d=s[t]>=a?s.memory>=n?"background-red":"background-orange":"background-green";let l=e[r].classList;l.remove("background-green","background-orange","background-red"),l.add(d)}));let t=document.getElementById("fs-redis-status").getElementsByClassName("fs-badge-content"),l=["used_memory","used_memory_rss","mem_fragmentation_ratio","hits_ratio","delta_hits_ratio","uptime_in_seconds","connected_clients"],c=!0;for(let e of l)if(s[e]){c=!1;break}c?(document.getElementById("fs-redis-status-title").innerHTML="",document.getElementById("fs-redis-status-title").style.marginTop="0",document.getElementById("fs-redis-status").style.display="none"):l.forEach(((e,n)=>{switch(e){case"used_memory":case"used_memory_rss":t[n].innerHTML=Math.ceil(s[e]/r)+" M";break;case"mem_fragmentation_ratio":let a=s[e];if(t[n].innerHTML=s[e],null!=a&&a>1){let e=t[n].classList;e.remove("background-green"),e.add("background-red")}break;case"hits_ratio":case"delta_hits_ratio":t[n].innerHTML=s[e]+"%";break;case"uptime_in_seconds":t[n].innerHTML=d.getFormatSeconds(s[e],this.language.days,this.language.hours,this.language.minutes,this.language.seconds);break;case"connected_clients":t[n].innerHTML=s[e]}}))}const l=s.cpu_count;this.initialCPUOptions(l,t),this.cpuOption.xAxis.data=t.host.ts,this.consoleCpuChart.setOption(this.cpuOption),this.networkIOOption.xAxis.data=t.io.ts,this.networkIOOption.series[0].data=t.io.net_recv,this.networkIOOption.series[1].data=t.io.net_sent,this.networkIOChart.setOption(this.networkIOOption),this.memoryOption.xAxis.data=t.host.ts,this.memoryOption.series[0].data=t.host.memory,this.consoleMemoryChart.setOption(this.memoryOption),this.loadavgOption.xAxis.data=t.host.ts,this.loadavgOption.series[0].data=t.host.loadavg,this.loadavgOption.series[1].data=t.host.loadavg5,this.loadavgOption.series[2].data=t.host.loadavg15,this.consoleLoadavgChart.setOption(this.loadavgOption),d.resizeChart([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])})).then((()=>{this.consoleMemoryChart.hideLoading(),this.consoleCpuChart.hideLoading(),this.consoleLoadavgChart.hideLoading(),this.networkIOChart.hideLoading()}))})).catch((function(e){}))}static isMobile(){let e=navigator.userAgent,t={trident:e.indexOf("Trident")>-1,presto:e.indexOf("Presto")>-1,webKit:e.indexOf("AppleWebKit")>-1,gecko:e.indexOf("Gecko")>-1&&-1===e.indexOf("KHTML"),mobile:e.match(/AppleWebKit.*Mobile.*/)&&!0,ios:e.match(/\(i[^;]+;( U;)? CPU.Mac OS X/)&&!0,android:e.indexOf("Android")>-1||e.indexOf("Linux")>-1,iPhone:e.indexOf("iPhone")>-1,iPad:e.indexOf("iPad")>-1,webApp:-1===e.indexOf("Safari"),wechat:e.indexOf("MicroMessenger")>-1,qq:e.match(/\sQQ/i)&&" qq"===e.match(/\sQQ/i)[0]};return t.iPhone||t.iPad||t.webApp||t.wechat||t.qq||t.ios||t.mobile||!1}static resizeChartTimer(e,t){clearTimeout(this.clearId),this.clearId=setTimeout((function(){d.resizeChart(e)}),t||200)}static resizeChart(e){e.forEach((e=>e.resize()))}initialCPUOptions(e,t){this.cpuOption.legend.data=[],this.cpuOption.color=["#42a5f5","#F75B81","#8083E5","#FBA364","#A1887F","#89E8E0","#FFDE99","#87EE84","#EDA8FF","#FFF176"],this.cpuOption.legend.selected={},this.cpuOption.series=[];for(let s=0;s{let t=echarts.format.formatTime("yyyy-MM-dd hh:mm:ss",new Date(parseInt(1e3*e[0].axisValue)),!1)+"
";if("networkIO"===s){for(let s=0;s";return t}for(let n=0;n";return t}},legend:{textStyle:{fontSize:14},show:"memory"!==s},series:[],grid:{left:"3%",right:"4%",bottom:"3%",top:e?30:60,containLabel:!0},toolbox:{show:!e,feature:{saveAsImage:{title:" "}}},xAxis:{type:"category",boundaryGap:!1,axisLabel:{formatter:function(e){return echarts.format.formatTime("hh:mm",new Date(parseInt(1e3*e)),!1)}}},yAxis:{type:"value",axisLabel:{formatter:e=>{if("networkIO"===s){let t=d.getFormatBit(e,0);return t.substring(0,t.length-2)}return e+("Load Avg"===t?"":"%")}}}};switch(s){case"loadavg":a.color=["#ffa726","#42a5f5","#66bb6a"],a.legend.data=["1 "+n,"5 "+n,"15 "+n],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"networkIO":a.color=["#ffa726","#42a5f5"],a.legend.data=["recv","sent"],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"memory":a.color=["#42a5f5"],a.legend.data=[n],a.series.push({name:n,type:"line",symbol:"none",hoverAnimation:!1})}return a}static getFormatBit(e,t=2){let s,n=e/8;return n>=1e12?(n=(n/1e12).toFixed(t),s="TB/s"):n>=1e9?(n=(n/1e9).toFixed(t),s="GB/s"):n>=1e6?(n=(n/1e6).toFixed(t),s="MB/s"):n>=1e3?(n=(n/1e3).toFixed(t),s="KB/s"):(s="B/s",n=n.toFixed(2)),n+" "+s}static getFormatSeconds(e,t="days",s="hours",n="min",a="seconds"){let i=parseInt(e),o=0,r=0,d=0,l="";return i>=60?(o=i/60,o>=60&&(r=o/60,o%=60),r>=24&&(d=r/24,r%=24)):l=i+a,o>0&&(l=Math.floor(o)+" "+n),r>0&&(l=Math.floor(r)+" "+s),d>0&&(l=Math.floor(d)+" "+t),l}}const l=function(){let e=null;return function(t){return e||(e=new d(t))}}();t.init=function(e){let t=null,s={};if(null!==e&&"object"==typeof e&&(t=e.hasOwnProperty("dom")?e.dom:null,s=e.hasOwnProperty("lang")&&e.lang.hasOwnProperty("language")?e.lang:{}),t instanceof HTMLElement){if(t.getAttribute("flaskState"))return;t.setAttribute("flaskState","true"),t.addEventListener("click",(()=>l(s).setFlaskStateData()))}else{if(document.getElementById("fs-state-circular"))return;let e="";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e);let t,a=document.getElementById("fs-state-circular");function n(e){a.style.top=e.clientY-t+300+"px"}a.onclick=function(){this.classList.add("fs-circular-out"),l(s).setFlaskStateData()},a.onmousedown=function(e){t=t||e.clientY,document.addEventListener("mousemove",n)},document.onmouseup=function(){document.removeEventListener("mousemove",n);const e=parseInt(a.style.top);a.classList.add("fs-circular-animation"),a.style.top=Math.min(Math.max(e,50),window.screen.height-200)+"px",setTimeout((()=>a.classList.remove("fs-circular-animation")),500)}}}}]);
\ No newline at end of file
diff --git a/packages/umd/flask-state.js b/packages/umd/flask-state.js
index cb26acd..12a2a67 100644
--- a/packages/umd/flask-state.js
+++ b/packages/umd/flask-state.js
@@ -337,7 +337,9 @@
initialCPUOptions(cpuCount, data) {
this.cpuOption.legend.data = [];
- this.cpuOption.color = ["#42a5f5", "#26c6da", "#26a69a", "#66bb6a", "#9ccc65", "#d4e157", "#ffee58", "#ffca28", "#ffa726"];
+ this.cpuOption.color = ["#42a5f5", '#F75B81', '#8083E5', '#FBA364',
+ "#A1887F", "#89E8E0", "#FFDE99", "#87EE84",
+ "#EDA8FF", "#FFF176"];
this.cpuOption.legend.selected = {};
this.cpuOption.series = [];
for (let i = 0; i < cpuCount + 1; i++) {
diff --git a/packages/umd/flask-state.min.js b/packages/umd/flask-state.min.js
index a2703d5..9d4730b 100644
--- a/packages/umd/flask-state.min.js
+++ b/packages/umd/flask-state.min.js
@@ -10,4 +10,4 @@
'use strict';
-!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.flaskState=t():e.flaskState=t()}(window,(function(){return function(e){var t={};function s(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)s.d(n,a,function(t){return e[t]}.bind(null,a));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";const n=85,a=75,i=10,o=5,r=1048576;class d{constructor(e){this.language=e,this.mobile=d.isMobile(),this.index=0,this.initFlaskStateContainer(this.mobile),this.setEventListener(),this.initFlaskStateLanguage(this.language),this.setInitParams(),this.mobile&&this.setTagChangeEventListener(this.consoleCpuChart,this.consoleMemoryChart,this.consoleLoadavgChart,this.networkIOChart),window.addEventListener("resize",(()=>{d.resizeChartTimer([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])}))}setFlaskStateData(){document.getElementById("fs-background").style.display="block",document.getElementById("fs-info-container").style.display="block",document.getElementsByTagName("body")[0].style.overflowX="hidden",document.getElementsByTagName("body")[0].style.overflowY="hidden",document.getElementById("fs-select-days").value="1",this.setCharts("1")}initFlaskStateContainer(){let e='Host Status
Memory
CPU
Disk Usage
Load Avg
Disk IO
Network IO
Uptime
Redis Status
Used Mem
Mem Fragmentation Ratio
Cache Hits Ratio
24h Hits Ratio
Uptime
Connections
'+(this.mobile?'
':"
")+"
";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e)}setEventListener(){if(window.addEventListener){document.getElementById("fs-info-close").addEventListener("click",(function(){document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out")})),document.getElementById("fs-background").addEventListener("click",(function(e){"fs-background"===String(e.target.id)&&(document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out"))}));let e=document.getElementById("fs-select-days");e.addEventListener("change",(()=>{this.setCharts(e.value)}))}}setTagChangeEventListener(...e){if(document.getElementById("fs-info-tab")){let t=document.getElementById("fs-info-tab").getElementsByTagName("li"),s=document.getElementById("fs-info-tab-memory"),n=t[0],a=0;const i={0:"fs-info-tab-memory",1:"fs-info-tab-cpu",2:"fs-info-network-io",3:"fs-info-tab-loadavg"};for(let o of t){let t=document.getElementById(i[a]);o.children[0].addEventListener("click",(()=>{o.classList.add("active"),n.classList.remove("active"),s.classList.remove("fs-show"),t.classList.add("fs-show"),d.resizeChart(e),s=t,n=o})),a++}}}initFlaskStateLanguage(){0!==Object.keys(this.language).length&&(document.getElementById("fs-host-status-title").innerHTML=this.language.host_status,document.getElementById("fs-redis-status-title").innerHTML=this.language.redis_status,document.getElementById("fs-cpu").innerHTML=this.language.cpu,document.getElementById("fs-memory").innerHTML=this.language.memory,document.getElementById("fs-disk-usage").innerHTML=this.language.disk_usage,document.getElementById("fs-load-avg").innerHTML=this.language.load_avg,document.getElementById("fs-disk-io").innerHTML=this.language.disk_io,document.getElementById("fs-network-io").innerHTML=this.language.network_io,document.getElementById("fs-boot-seconds").innerHTML=this.language.boot_seconds,document.getElementById("fs-used-memory").innerHTML=this.language.used_memory,document.getElementById("fs-used-memory-rss").innerHTML=this.language.used_memory_rss,document.getElementById("fs-mem-fragmentation-ratio").innerHTML=this.language.mem_fragmentation_ratio,document.getElementById("fs-hits-ratio").innerHTML=this.language.hits_ratio,document.getElementById("fs-delta-hits-ratio").innerHTML=this.language.delta_hits_ratio,document.getElementById("fs-uptime-in-seconds").innerHTML=this.language.uptime_in_seconds,document.getElementById("fs-connected-clients").innerHTML=this.language.connected_clients,document.getElementById("fs-days").innerHTML=this.language.days)}setInitParams(){this.consoleCpuChart=echarts.init(document.getElementById("fs-info-cpu-chart"),null,{renderer:"svg"}),this.consoleMemoryChart=echarts.init(document.getElementById("fs-info-memory-chart"),null,{renderer:"svg"}),this.consoleLoadavgChart=echarts.init(document.getElementById("fs-info-loadavg-chart"),null,{renderer:"svg"}),this.networkIOChart=echarts.init(document.getElementById("fs-info-networkio-chart"),null,{renderer:"svg"}),this.cpuOption=d.generateChatOption(this.mobile,this.language.cpu||"CPU","cpu",this.language.today||"Today"),this.memoryOption=d.generateChatOption(this.mobile,this.language.memory||"Memory","memory",this.language.today||"Today"),this.networkIOOption=d.generateChatOption(this.mobile,this.language.network_io||"Network IO","networkIO",this.language.today||"Today"),this.loadavgOption=d.generateChatOption(this.mobile,"Load Avg","loadavg",this.language.minutes||"min")}setCharts(e){this.consoleCpuChart.showLoading(),this.consoleMemoryChart.showLoading(),this.consoleLoadavgChart.showLoading(),this.networkIOChart.showLoading(),fetch("/v0/state/hoststatus",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify({timeQuantum:e})}).then((e=>{e.ok&&e.json().then((e=>{if(200!==e.code)return;const t=e.data;let s=t.currentStatistic;if(Object.keys(s).length){let e=document.getElementById("fs-host-status").getElementsByClassName("fs-badge-content");e[0].innerHTML=s.memory+"%",e[1].innerHTML=s.cpu+"%",e[2].innerHTML=s.disk_usage+"%",e[3].innerHTML=s.load_avg[0]+","+s.load_avg[1]+","+s.load_avg[2],e[4].innerHTML="R "+d.getFormatBit(s.disk_read)+" | W "+d.getFormatBit(s.disk_write)+"",e[5].innerHTML="⬇ "+d.getFormatBit(s.net_recv)+" | ⬆ "+d.getFormatBit(s.net_sent)+"",e[6].innerHTML=d.getFormatSeconds(s.boot_seconds||0,this.language.days,this.language.hours,this.language.minutes,this.language.seconds);["memory","cpu","disk_usage","load_avg"].forEach((function(t,r){let d;if("load_avg"===t){let e=(s.load_avg[0]+s.load_avg[1]+s.load_avg[2])/3;d=e>=o?e>=i?"background-red":"background-orange":"background-green"}else d=s[t]>=a?s.memory>=n?"background-red":"background-orange":"background-green";let l=e[r].classList;l.remove("background-green","background-orange","background-red"),l.add(d)}));let t=document.getElementById("fs-redis-status").getElementsByClassName("fs-badge-content"),l=["used_memory","used_memory_rss","mem_fragmentation_ratio","hits_ratio","delta_hits_ratio","uptime_in_seconds","connected_clients"],c=!0;for(let e of l)if(s[e]){c=!1;break}c?(document.getElementById("fs-redis-status-title").innerHTML="",document.getElementById("fs-redis-status-title").style.marginTop="0",document.getElementById("fs-redis-status").style.display="none"):l.forEach(((e,n)=>{switch(e){case"used_memory":case"used_memory_rss":t[n].innerHTML=Math.ceil(s[e]/r)+" M";break;case"mem_fragmentation_ratio":let a=s[e];if(t[n].innerHTML=s[e],null!=a&&a>1){let e=t[n].classList;e.remove("background-green"),e.add("background-red")}break;case"hits_ratio":case"delta_hits_ratio":t[n].innerHTML=s[e]+"%";break;case"uptime_in_seconds":t[n].innerHTML=d.getFormatSeconds(s[e],this.language.days,this.language.hours,this.language.minutes,this.language.seconds);break;case"connected_clients":t[n].innerHTML=s[e]}}))}const l=s.cpu_count;this.initialCPUOptions(l,t),this.cpuOption.xAxis.data=t.host.ts,this.consoleCpuChart.setOption(this.cpuOption),this.networkIOOption.xAxis.data=t.io.ts,this.networkIOOption.series[0].data=t.io.net_recv,this.networkIOOption.series[1].data=t.io.net_sent,this.networkIOChart.setOption(this.networkIOOption),this.memoryOption.xAxis.data=t.host.ts,this.memoryOption.series[0].data=t.host.memory,this.consoleMemoryChart.setOption(this.memoryOption),this.loadavgOption.xAxis.data=t.host.ts,this.loadavgOption.series[0].data=t.host.loadavg,this.loadavgOption.series[1].data=t.host.loadavg5,this.loadavgOption.series[2].data=t.host.loadavg15,this.consoleLoadavgChart.setOption(this.loadavgOption),d.resizeChart([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])})).then((()=>{this.consoleMemoryChart.hideLoading(),this.consoleCpuChart.hideLoading(),this.consoleLoadavgChart.hideLoading(),this.networkIOChart.hideLoading()}))})).catch((function(e){}))}static isMobile(){let e=navigator.userAgent,t={trident:e.indexOf("Trident")>-1,presto:e.indexOf("Presto")>-1,webKit:e.indexOf("AppleWebKit")>-1,gecko:e.indexOf("Gecko")>-1&&-1===e.indexOf("KHTML"),mobile:e.match(/AppleWebKit.*Mobile.*/)&&!0,ios:e.match(/\(i[^;]+;( U;)? CPU.Mac OS X/)&&!0,android:e.indexOf("Android")>-1||e.indexOf("Linux")>-1,iPhone:e.indexOf("iPhone")>-1,iPad:e.indexOf("iPad")>-1,webApp:-1===e.indexOf("Safari"),wechat:e.indexOf("MicroMessenger")>-1,qq:e.match(/\sQQ/i)&&" qq"===e.match(/\sQQ/i)[0]};return t.iPhone||t.iPad||t.webApp||t.wechat||t.qq||t.ios||t.mobile||!1}static resizeChartTimer(e,t){clearTimeout(this.clearId),this.clearId=setTimeout((function(){d.resizeChart(e)}),t||200)}static resizeChart(e){e.forEach((e=>e.resize()))}initialCPUOptions(e,t){this.cpuOption.legend.data=[],this.cpuOption.color=["#42a5f5","#26c6da","#26a69a","#66bb6a","#9ccc65","#d4e157","#ffee58","#ffca28","#ffa726"],this.cpuOption.legend.selected={},this.cpuOption.series=[];for(let s=0;s{let t=echarts.format.formatTime("yyyy-MM-dd hh:mm:ss",new Date(parseInt(1e3*e[0].axisValue)),!1)+"
";if("networkIO"===s){for(let s=0;s";return t}for(let n=0;n";return t}},legend:{textStyle:{fontSize:14},show:"memory"!==s},series:[],grid:{left:"3%",right:"4%",bottom:"3%",top:e?30:60,containLabel:!0},toolbox:{show:!e,feature:{saveAsImage:{title:" "}}},xAxis:{type:"category",boundaryGap:!1,axisLabel:{formatter:function(e){return echarts.format.formatTime("hh:mm",new Date(parseInt(1e3*e)),!1)}}},yAxis:{type:"value",axisLabel:{formatter:e=>{if("networkIO"===s){let t=d.getFormatBit(e,0);return t.substring(0,t.length-2)}return e+("Load Avg"===t?"":"%")}}}};switch(s){case"loadavg":a.color=["#ffa726","#42a5f5","#66bb6a"],a.legend.data=["1 "+n,"5 "+n,"15 "+n],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"networkIO":a.color=["#ffa726","#42a5f5"],a.legend.data=["recv","sent"],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"memory":a.color=["#42a5f5"],a.legend.data=[n],a.series.push({name:n,type:"line",symbol:"none",hoverAnimation:!1})}return a}static getFormatBit(e,t=2){let s,n=e/8;return n>=1e12?(n=(n/1e12).toFixed(t),s="TB/s"):n>=1e9?(n=(n/1e9).toFixed(t),s="GB/s"):n>=1e6?(n=(n/1e6).toFixed(t),s="MB/s"):n>=1e3?(n=(n/1e3).toFixed(t),s="KB/s"):(s="B/s",n=n.toFixed(2)),n+" "+s}static getFormatSeconds(e,t="days",s="hours",n="min",a="seconds"){let i=parseInt(e),o=0,r=0,d=0,l="";return i>=60?(o=i/60,o>=60&&(r=o/60,o%=60),r>=24&&(d=r/24,r%=24)):l=i+a,o>0&&(l=Math.floor(o)+" "+n),r>0&&(l=Math.floor(r)+" "+s),d>0&&(l=Math.floor(d)+" "+t),l}}const l=function(){let e=null;return function(t){return e||(e=new d(t))}}();t.init=function(e){let t=null,s={};if(null!==e&&"object"==typeof e&&(t=e.hasOwnProperty("dom")?e.dom:null,s=e.hasOwnProperty("lang")&&e.lang.hasOwnProperty("language")?e.lang:{}),t instanceof HTMLElement){if(t.getAttribute("flaskState"))return;t.setAttribute("flaskState","true"),t.addEventListener("click",(()=>l(s).setFlaskStateData()))}else{if(document.getElementById("fs-state-circular"))return;let e="";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e);let t,a=document.getElementById("fs-state-circular");function n(e){a.style.top=e.clientY-t+300+"px"}a.onclick=function(){this.classList.add("fs-circular-out"),l(s).setFlaskStateData()},a.onmousedown=function(e){t=t||e.clientY,document.addEventListener("mousemove",n)},document.onmouseup=function(){document.removeEventListener("mousemove",n);const e=parseInt(a.style.top);a.classList.add("fs-circular-animation"),a.style.top=Math.min(Math.max(e,50),window.screen.height-200)+"px",setTimeout((()=>a.classList.remove("fs-circular-animation")),500)}}}}])}));
\ No newline at end of file
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.flaskState=t():e.flaskState=t()}(window,(function(){return function(e){var t={};function s(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)s.d(n,a,function(t){return e[t]}.bind(null,a));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";const n=85,a=75,i=10,o=5,r=1048576;class d{constructor(e){this.language=e,this.mobile=d.isMobile(),this.index=0,this.initFlaskStateContainer(this.mobile),this.setEventListener(),this.initFlaskStateLanguage(this.language),this.setInitParams(),this.mobile&&this.setTagChangeEventListener(this.consoleCpuChart,this.consoleMemoryChart,this.consoleLoadavgChart,this.networkIOChart),window.addEventListener("resize",(()=>{d.resizeChartTimer([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])}))}setFlaskStateData(){document.getElementById("fs-background").style.display="block",document.getElementById("fs-info-container").style.display="block",document.getElementsByTagName("body")[0].style.overflowX="hidden",document.getElementsByTagName("body")[0].style.overflowY="hidden",document.getElementById("fs-select-days").value="1",this.setCharts("1")}initFlaskStateContainer(){let e='Host Status
Memory
CPU
Disk Usage
Load Avg
Disk IO
Network IO
Uptime
Redis Status
Used Mem
Mem Fragmentation Ratio
Cache Hits Ratio
24h Hits Ratio
Uptime
Connections
'+(this.mobile?'
':"
")+"
";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e)}setEventListener(){if(window.addEventListener){document.getElementById("fs-info-close").addEventListener("click",(function(){document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out")})),document.getElementById("fs-background").addEventListener("click",(function(e){"fs-background"===String(e.target.id)&&(document.getElementById("fs-background").style.display="none",document.getElementById("fs-info-container").style.display="none",document.getElementsByTagName("body")[0].style.overflowX="auto",document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementById("fs-state-circular")&&document.getElementById("fs-state-circular").classList.remove("fs-circular-out"))}));let e=document.getElementById("fs-select-days");e.addEventListener("change",(()=>{this.setCharts(e.value)}))}}setTagChangeEventListener(...e){if(document.getElementById("fs-info-tab")){let t=document.getElementById("fs-info-tab").getElementsByTagName("li"),s=document.getElementById("fs-info-tab-memory"),n=t[0],a=0;const i={0:"fs-info-tab-memory",1:"fs-info-tab-cpu",2:"fs-info-network-io",3:"fs-info-tab-loadavg"};for(let o of t){let t=document.getElementById(i[a]);o.children[0].addEventListener("click",(()=>{o.classList.add("active"),n.classList.remove("active"),s.classList.remove("fs-show"),t.classList.add("fs-show"),d.resizeChart(e),s=t,n=o})),a++}}}initFlaskStateLanguage(){0!==Object.keys(this.language).length&&(document.getElementById("fs-host-status-title").innerHTML=this.language.host_status,document.getElementById("fs-redis-status-title").innerHTML=this.language.redis_status,document.getElementById("fs-cpu").innerHTML=this.language.cpu,document.getElementById("fs-memory").innerHTML=this.language.memory,document.getElementById("fs-disk-usage").innerHTML=this.language.disk_usage,document.getElementById("fs-load-avg").innerHTML=this.language.load_avg,document.getElementById("fs-disk-io").innerHTML=this.language.disk_io,document.getElementById("fs-network-io").innerHTML=this.language.network_io,document.getElementById("fs-boot-seconds").innerHTML=this.language.boot_seconds,document.getElementById("fs-used-memory").innerHTML=this.language.used_memory,document.getElementById("fs-used-memory-rss").innerHTML=this.language.used_memory_rss,document.getElementById("fs-mem-fragmentation-ratio").innerHTML=this.language.mem_fragmentation_ratio,document.getElementById("fs-hits-ratio").innerHTML=this.language.hits_ratio,document.getElementById("fs-delta-hits-ratio").innerHTML=this.language.delta_hits_ratio,document.getElementById("fs-uptime-in-seconds").innerHTML=this.language.uptime_in_seconds,document.getElementById("fs-connected-clients").innerHTML=this.language.connected_clients,document.getElementById("fs-days").innerHTML=this.language.days)}setInitParams(){this.consoleCpuChart=echarts.init(document.getElementById("fs-info-cpu-chart"),null,{renderer:"svg"}),this.consoleMemoryChart=echarts.init(document.getElementById("fs-info-memory-chart"),null,{renderer:"svg"}),this.consoleLoadavgChart=echarts.init(document.getElementById("fs-info-loadavg-chart"),null,{renderer:"svg"}),this.networkIOChart=echarts.init(document.getElementById("fs-info-networkio-chart"),null,{renderer:"svg"}),this.cpuOption=d.generateChatOption(this.mobile,this.language.cpu||"CPU","cpu",this.language.today||"Today"),this.memoryOption=d.generateChatOption(this.mobile,this.language.memory||"Memory","memory",this.language.today||"Today"),this.networkIOOption=d.generateChatOption(this.mobile,this.language.network_io||"Network IO","networkIO",this.language.today||"Today"),this.loadavgOption=d.generateChatOption(this.mobile,"Load Avg","loadavg",this.language.minutes||"min")}setCharts(e){this.consoleCpuChart.showLoading(),this.consoleMemoryChart.showLoading(),this.consoleLoadavgChart.showLoading(),this.networkIOChart.showLoading(),fetch("/v0/state/hoststatus",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json;charset=UTF-8"},body:JSON.stringify({timeQuantum:e})}).then((e=>{e.ok&&e.json().then((e=>{if(200!==e.code)return;const t=e.data;let s=t.currentStatistic;if(Object.keys(s).length){let e=document.getElementById("fs-host-status").getElementsByClassName("fs-badge-content");e[0].innerHTML=s.memory+"%",e[1].innerHTML=s.cpu+"%",e[2].innerHTML=s.disk_usage+"%",e[3].innerHTML=s.load_avg[0]+","+s.load_avg[1]+","+s.load_avg[2],e[4].innerHTML="R "+d.getFormatBit(s.disk_read)+" | W "+d.getFormatBit(s.disk_write)+"",e[5].innerHTML="⬇ "+d.getFormatBit(s.net_recv)+" | ⬆ "+d.getFormatBit(s.net_sent)+"",e[6].innerHTML=d.getFormatSeconds(s.boot_seconds||0,this.language.days,this.language.hours,this.language.minutes,this.language.seconds);["memory","cpu","disk_usage","load_avg"].forEach((function(t,r){let d;if("load_avg"===t){let e=(s.load_avg[0]+s.load_avg[1]+s.load_avg[2])/3;d=e>=o?e>=i?"background-red":"background-orange":"background-green"}else d=s[t]>=a?s.memory>=n?"background-red":"background-orange":"background-green";let l=e[r].classList;l.remove("background-green","background-orange","background-red"),l.add(d)}));let t=document.getElementById("fs-redis-status").getElementsByClassName("fs-badge-content"),l=["used_memory","used_memory_rss","mem_fragmentation_ratio","hits_ratio","delta_hits_ratio","uptime_in_seconds","connected_clients"],c=!0;for(let e of l)if(s[e]){c=!1;break}c?(document.getElementById("fs-redis-status-title").innerHTML="",document.getElementById("fs-redis-status-title").style.marginTop="0",document.getElementById("fs-redis-status").style.display="none"):l.forEach(((e,n)=>{switch(e){case"used_memory":case"used_memory_rss":t[n].innerHTML=Math.ceil(s[e]/r)+" M";break;case"mem_fragmentation_ratio":let a=s[e];if(t[n].innerHTML=s[e],null!=a&&a>1){let e=t[n].classList;e.remove("background-green"),e.add("background-red")}break;case"hits_ratio":case"delta_hits_ratio":t[n].innerHTML=s[e]+"%";break;case"uptime_in_seconds":t[n].innerHTML=d.getFormatSeconds(s[e],this.language.days,this.language.hours,this.language.minutes,this.language.seconds);break;case"connected_clients":t[n].innerHTML=s[e]}}))}const l=s.cpu_count;this.initialCPUOptions(l,t),this.cpuOption.xAxis.data=t.host.ts,this.consoleCpuChart.setOption(this.cpuOption),this.networkIOOption.xAxis.data=t.io.ts,this.networkIOOption.series[0].data=t.io.net_recv,this.networkIOOption.series[1].data=t.io.net_sent,this.networkIOChart.setOption(this.networkIOOption),this.memoryOption.xAxis.data=t.host.ts,this.memoryOption.series[0].data=t.host.memory,this.consoleMemoryChart.setOption(this.memoryOption),this.loadavgOption.xAxis.data=t.host.ts,this.loadavgOption.series[0].data=t.host.loadavg,this.loadavgOption.series[1].data=t.host.loadavg5,this.loadavgOption.series[2].data=t.host.loadavg15,this.consoleLoadavgChart.setOption(this.loadavgOption),d.resizeChart([this.consoleMemoryChart,this.consoleCpuChart,this.consoleLoadavgChart,this.networkIOChart])})).then((()=>{this.consoleMemoryChart.hideLoading(),this.consoleCpuChart.hideLoading(),this.consoleLoadavgChart.hideLoading(),this.networkIOChart.hideLoading()}))})).catch((function(e){}))}static isMobile(){let e=navigator.userAgent,t={trident:e.indexOf("Trident")>-1,presto:e.indexOf("Presto")>-1,webKit:e.indexOf("AppleWebKit")>-1,gecko:e.indexOf("Gecko")>-1&&-1===e.indexOf("KHTML"),mobile:e.match(/AppleWebKit.*Mobile.*/)&&!0,ios:e.match(/\(i[^;]+;( U;)? CPU.Mac OS X/)&&!0,android:e.indexOf("Android")>-1||e.indexOf("Linux")>-1,iPhone:e.indexOf("iPhone")>-1,iPad:e.indexOf("iPad")>-1,webApp:-1===e.indexOf("Safari"),wechat:e.indexOf("MicroMessenger")>-1,qq:e.match(/\sQQ/i)&&" qq"===e.match(/\sQQ/i)[0]};return t.iPhone||t.iPad||t.webApp||t.wechat||t.qq||t.ios||t.mobile||!1}static resizeChartTimer(e,t){clearTimeout(this.clearId),this.clearId=setTimeout((function(){d.resizeChart(e)}),t||200)}static resizeChart(e){e.forEach((e=>e.resize()))}initialCPUOptions(e,t){this.cpuOption.legend.data=[],this.cpuOption.color=["#42a5f5","#F75B81","#8083E5","#FBA364","#A1887F","#89E8E0","#FFDE99","#87EE84","#EDA8FF","#FFF176"],this.cpuOption.legend.selected={},this.cpuOption.series=[];for(let s=0;s{let t=echarts.format.formatTime("yyyy-MM-dd hh:mm:ss",new Date(parseInt(1e3*e[0].axisValue)),!1)+"
";if("networkIO"===s){for(let s=0;s";return t}for(let n=0;n";return t}},legend:{textStyle:{fontSize:14},show:"memory"!==s},series:[],grid:{left:"3%",right:"4%",bottom:"3%",top:e?30:60,containLabel:!0},toolbox:{show:!e,feature:{saveAsImage:{title:" "}}},xAxis:{type:"category",boundaryGap:!1,axisLabel:{formatter:function(e){return echarts.format.formatTime("hh:mm",new Date(parseInt(1e3*e)),!1)}}},yAxis:{type:"value",axisLabel:{formatter:e=>{if("networkIO"===s){let t=d.getFormatBit(e,0);return t.substring(0,t.length-2)}return e+("Load Avg"===t?"":"%")}}}};switch(s){case"loadavg":a.color=["#ffa726","#42a5f5","#66bb6a"],a.legend.data=["1 "+n,"5 "+n,"15 "+n],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"networkIO":a.color=["#ffa726","#42a5f5"],a.legend.data=["recv","sent"],a.legend.data.forEach((e=>{a.series.push({name:e,type:"line",symbol:"none",hoverAnimation:!1})}));break;case"memory":a.color=["#42a5f5"],a.legend.data=[n],a.series.push({name:n,type:"line",symbol:"none",hoverAnimation:!1})}return a}static getFormatBit(e,t=2){let s,n=e/8;return n>=1e12?(n=(n/1e12).toFixed(t),s="TB/s"):n>=1e9?(n=(n/1e9).toFixed(t),s="GB/s"):n>=1e6?(n=(n/1e6).toFixed(t),s="MB/s"):n>=1e3?(n=(n/1e3).toFixed(t),s="KB/s"):(s="B/s",n=n.toFixed(2)),n+" "+s}static getFormatSeconds(e,t="days",s="hours",n="min",a="seconds"){let i=parseInt(e),o=0,r=0,d=0,l="";return i>=60?(o=i/60,o>=60&&(r=o/60,o%=60),r>=24&&(d=r/24,r%=24)):l=i+a,o>0&&(l=Math.floor(o)+" "+n),r>0&&(l=Math.floor(r)+" "+s),d>0&&(l=Math.floor(d)+" "+t),l}}const l=function(){let e=null;return function(t){return e||(e=new d(t))}}();t.init=function(e){let t=null,s={};if(null!==e&&"object"==typeof e&&(t=e.hasOwnProperty("dom")?e.dom:null,s=e.hasOwnProperty("lang")&&e.lang.hasOwnProperty("language")?e.lang:{}),t instanceof HTMLElement){if(t.getAttribute("flaskState"))return;t.setAttribute("flaskState","true"),t.addEventListener("click",(()=>l(s).setFlaskStateData()))}else{if(document.getElementById("fs-state-circular"))return;let e="";document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e);let t,a=document.getElementById("fs-state-circular");function n(e){a.style.top=e.clientY-t+300+"px"}a.onclick=function(){this.classList.add("fs-circular-out"),l(s).setFlaskStateData()},a.onmousedown=function(e){t=t||e.clientY,document.addEventListener("mousemove",n)},document.onmouseup=function(){document.removeEventListener("mousemove",n);const e=parseInt(a.style.top);a.classList.add("fs-circular-animation"),a.style.top=Math.min(Math.max(e,50),window.screen.height-200)+"px",setTimeout((()=>a.classList.remove("fs-circular-animation")),500)}}}}])}));
\ No newline at end of file