File manager - Edit - /usr/share/webmin/authentic-theme/extensions/stats/stats.min.js
Back
/*! * Authentic Theme (https://github.com/authentic-theme/authentic-theme) * Copyright Ilia Rostovtsev <ilia@virtualmin.com> * Licensed under MIT (https://github.com/authentic-theme/authentic-theme/blob/master/LICENSE) */ "use strict";const stats={sys:{error:0,tried:0,activating:0,requery:null,socket:null,_:{prefix:v___location_prefix,error:connection_error,language:theme_language,convert:{size:Convert.nice_size},chart:Chartist,dayjs,locale:{time:config_portable_theme_locale_format_time,offset:()=>get_utc_offset()},can_conn_ws,blocked:theme_updating,getHistoryData:function(){return vars.stats.history}},selector:{chart:{container:{parent:"live_stats",data:"data-chart"},loader:"data-charts-loader"},collapse:"collapse",dashboard:"system-status",slider:"info-container",piechart:"piechart",defaultClassLabel:"bg-semi-transparent",defaultSliderClassLabel:"bg-semi-transparent-dark"},isAllowed:function(){return theme.visibility.get()&&(plugins.dashboard.visible()||plugins.slider.visible())},getSocketDefs:function(){return{session:session.server.data("session-hash"),paused:this.canRender()?0:1,interval:this.getInterval(),disable:this.isEnabled()?0:1,shutdown:settings_sysinfo_real_time_shutdown_on_last?1:0}},graphsCanPreRender:function(){return document.querySelector(`[${this.selector.chart.loader}]`)?1:0},getInterval:function(){return settings_sysinfo_real_time_run_rate/1e3},getStoredDuration:function(){return settings_sysinfo_real_time_stored_duration},getRenderType:function(t){t=t.graphs;let e=!1;for(const s in t)if(t.hasOwnProperty(s)&&Array.isArray(t[s])&&t[s].length>1){e=!0;break}return e?3:null},canRender:function(){return theme.visibility.get()},isEnabled:function(){const t=settings_sysinfo_real_time_status?1:0,e=this._.can_conn_ws();return t&&e},restart:function(){this.shutdown(),setTimeout(()=>{this.enable()},1e3*this.getInterval()*4)},toggle:function(){setTimeout(()=>{this.isAllowed()?this.enable():this.disable()},200)},_toggleLimiter:(()=>{let t=null,e=null;return(s,i,a,n)=>{e=()=>s.apply(i,a),clearTimeout(t),t=setTimeout(()=>{e(),e=t=null},n)}})(),_disableFn:function(){if(this.socket&&1===this.socket.readyState&&!0!==this.socket.paused&&!this.isAllowed()){const t=this.getSocketDefs();t.paused=1,this.socket.paused=!0,this.socket.send(JSON.stringify(t))}},_enableFn:function(){this.isEnabled()&&this.isAllowed()&&(this.graphsCanPreRender()&&this.preRender(),this.socket&&!1!==this.socket.paused?(1===this.socket.readyState&&this.socket.send(JSON.stringify(this.getSocketDefs())),this.socket.paused=!1):this.activate())},enable:function(){this._toggleLimiter(this._enableFn,this,arguments,40)},disable:function(){this._toggleLimiter(this._disableFn,this,arguments,4e3)},shutdown:function(){if(this.socket&&1===this.socket.readyState){const t=this.getSocketDefs();t.disable=1,this.socket.send(JSON.stringify(t))}},activate:function(){this.activating++||this._.blocked()||this.socket||this.tried++>4||$.ajax({context:this,url:`${this._.prefix}/stats.cgi`,error:function(){this.activating=0,this.error++>3||!this.requery&&(this.requery=setTimeout(()=>{this.requery=null,this.activate()},1e3*this.getInterval()*4))},success:function(t){t.success?(this.socket=new WebSocket(t.socket),this.socket.onopen=()=>{this.tried=0,this.activating=0,this.socket.send(JSON.stringify(this.getSocketDefs()))},this.socket.onmessage=t=>{const e=JSON.parse(t.data),s=this.getRenderType(e);this.render(e,s)},this.socket.onclose=()=>{setTimeout(()=>{this.socket=null,this.activating=0,this.enable()},1e3*this.getInterval()*4)}):this.activating=0,this.error=0},dataType:"json"})},preRender:function(){this.render(this._.getHistoryData(),2)},render:function(t,e){Object.entries(t).map(([t,s])=>{let i=parseInt(s),a="object"==typeof s&&s[s.length-1],n=a||i,r=$(`#${this.selector.dashboard} .${this.selector.piechart}[data-charts*="${t}"]`),o=$(`.${this.selector.slider} .${t}_percent`),l=$(`#${this.selector.dashboard} span[data-id="sysinfo_${t}"], \n .${this.selector.slider} span[data-data="${t}"]`),h="graphs"===t?e?3===e?3:2:this.graphsCanPreRender()?2:1:0;if(Number.isInteger(i)){if(r.length){let t=r.data("easyPieChart");t&&t.update(i)}if(o.length){o.find(".bar").attr("style","width:"+i+"%");let e=o.find(".description"),s=e.text().split(":")[0]+": "+i+"% ("+a+")";"cpu"!==t&&(s=plugins.slider.update.stats.graphs.flatten(s),"virt"!==t&&(s=plugins.slider.update.stats.graphs.plunk(s))),e.attr("title",a).text(s)}l.length&&(l.find("a").length?l.find("a").text(n):l.text(n))}if("sensors"===t&&a&&Object.entries(a).forEach(([t,e])=>{let s=this,i=$(`#${this.selector.dashboard} span[data-stats="${t}"]`),a=$(`.${this.selector.slider} span[data-stats="${t}"]`);if(i&&i.length){let n=i.length,r=a.length;e.sort((e,s)=>"fans"===t?e.fan-s.fan:e.core-s.core);const o=function(e,i,a,n){if(!i)return;a?e.html(function(e,s){const a=s.includes("°F");return s.replace(/\d+/,"fans"===t?i.rpm:a?Math.round(9*i.temp/5+32):i.temp)}):e.html(function(e,s){const a=s.includes("°F");return s.replace(/: \d+/,`: ${"fans"===t?i.rpm:a?Math.round(9*i.temp/5+32):i.temp}`)});const r=e.text().replace(/.*?\d+:\s*/,"");let o=HTML.label.textMaxLevels(t,r)||(n?s.selector.defaultSliderClassLabel:s.selector.defaultClassLabel);n&&o===s.selector.defaultClassLabel&&(o=s.selector.defaultSliderClassLabel),e.removeClass((t,e)=>(e.match(/\bbg-\S+/g)||[]).join(" ")).addClass(o)};1===n?o(i,e[0],!0):i.each((t,s)=>{e[t]&&o($(s),e[t],!1)}),1===r?o(a,e[0],!0,!0):a.each((t,s)=>{e[t]&&o($(s),e[t],!1,!0)})}}),h){let t=`${this.selector.chart.container.parent}-${this.selector.collapse}`,e=$(`#${t}`).find(`[${this.selector.chart.loader}]`);Object.entries(s).map(([s,i])=>{let a={chart:{type:()=>"proc"===s||"disk"===s||"net"===s,bandwidth:()=>"disk"===s||"net"===s,fill:function(){return!this.type()},high:function(){return this.type()?void 0:100},threshold:function(){return this.type()?-1:80},height:"110px"}},n=this._.language(`${this.selector.chart.container.parent}_${s}`),r=$(`#${t}`).find(`[${this.selector.chart.container.data}=${s}]`),o=[{name:`series-${s}`,data:i}];if(r.length)if(i[0]&&"object"==typeof i[0].y&&(o=[],i[0].y.forEach(function(t,e){let a=[];i.forEach(function(t){a.push({data:{x:t.x,y:t.y[e]}})}),o.push({name:`series-${s}-${e}`,data:a})})),r[0]&&r[0].textContent&&3!==h){if(1===h){let t=parseInt(this.getStoredDuration(),10);(t<300||t>86400)&&(t=getStoredDuration());const e=this[`chart_${s}`],i=e.data.series;const a=t=>t&&(null!=t.x?t.x:t.data&&t.data.x)||0;o.forEach((e,s)=>{const n=i[s].data,r=e.data[0];n.push(r);const o=a(n[n.length-1])-t;let l=0,h=n.length-1,c=0;for(;l<=h;){const t=l+h>>1;a(n[t])<o?(l=t+1,c=l):h=t-1}c>0&&n.splice(0,c)});const n=Math.max.apply(null,i.map(t=>a(t.data[t.data.length-1]||t.data[0]||{x:0}))),r=Math.min.apply(null,i.map(t=>a(t.data[0]||{x:n}))),l=n,h=Math.max(l-t,r),c=this._.chart.extend({},e.options,{axisX:this._.chart.extend({},e.options.axisX,{low:h,high:l})});i.forEach(t=>{const e=t.data;let s=0,i=e.length-1,n=0;for(;s<=i;){const t=s+i>>1;a(e[t])<h?(s=t+1,n=s):i=t-1}n>0&&e.splice(0,n)}),e.update({series:i},c,!0)}}else 2!==h&&3!==h||(this[`chart_${s}`]=new this._.chart.Line(r[0],{series:o},{axisX:{type:this._.chart.FixedScaleAxis,divisor:6,labelInterpolationFnc:t=>this._.dayjs(1e3*t).utcOffset(this._.locale.offset()).format(this._.locale.time)},height:a.chart.height,showArea:a.chart.fill(),showPoint:!1,high:a.chart.high(),low:0,fullWidth:!0,chartPadding:{left:25},axisY:{onlyInteger:!0,labelInterpolationFnc:t=>a.chart.fill()?t?t+"%":t:a.chart.bandwidth(t)?"net"===s?t?this._.convert.size(t,{fixed:0,bits:1,round:1}):t:t?this._.convert.size(1024*t,{fixed:0,round:1}):t:t},plugins:[this._.chart.plugins.ctAxisTitle({axisY:{axisTitle:n,axisClass:"ct-axis-title",offset:{x:0,y:9},flipTitle:!0}}),this._.chart.plugins.ctThreshold({threshold:a.chart.threshold()})]}),this[`chart_${s}`].on("created",t=>{const i=t.svg.getNode().querySelector("foreignObject");if(i){const t=this._.language(`dashboard_chart_${s}_read`),e=this._.language(`dashboard_chart_${s}_write`);t&&e&&(i.setAttribute("data-label-read",`▪ ${t}`),i.setAttribute("data-label-write",`▪ ${e}`))}e.remove()}))})}})}}};
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.5 |
proxy
|
phpinfo
|
Settings