diff --git a/extensions/stats/stats.min.js b/extensions/stats/stats.min.js index 18213376f..21ff22df1 100644 --- a/extensions/stats/stats.min.js +++ b/extensions/stats/stats.min.js @@ -1 +1 @@ -"use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if(Symbol.iterator in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var 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:dayjs,locale:{time:config_portable_theme_locale_format_time,offset:function offset(){return get_utc_offset();}},can_conn_ws:can_conn_ws,blocked:theme_updating,getHistoryData:function getHistoryData(){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"},getSocketDefs:function getSocketDefs(){return{session:session.server.data("session-hash"),paused:!this.canRender()?1:0,interval:this.getInterval(),disable:!this.isEnabled()?1:0,shutdown:settings_sysinfo_real_time_shutdown_on_last?1:0};},graphsCanPreRender:function graphsCanPreRender(){return document.querySelector("["+this.selector.chart.loader+"]")?1:0;},getInterval:function getInterval(){return settings_sysinfo_real_time_run_rate/1000;},getStoredDuration:function getStoredDuration(){return settings_sysinfo_real_time_stored_duration;},getRenderType:function getRenderType(graphs){graphs=graphs.graphs;var hasMultipleDatasets=false;for(var key in graphs){if(graphs.hasOwnProperty(key)&&Array.isArray(graphs[key])){if(graphs[key].length>1){hasMultipleDatasets=true;break;}}}return hasMultipleDatasets?3:null;},canRender:function canRender(){return theme.visibility.get();},isEnabled:function isEnabled(){var stats_enabled=settings_sysinfo_real_time_status?1:0,stats_can=this._.can_conn_ws();return stats_enabled&&stats_can;},restart:function restart(){var _this=this;this.shutdown();setTimeout(function(){_this.enable();},this.getInterval()*1000*4);},disable:function disable(){if(this.socket&&this.socket.readyState===1){var socketData=this.getSocketDefs();socketData.paused=1;this.socket.send(JSON.stringify(socketData));}},enable:function enable(){if(this.isEnabled()){if(this.graphsCanPreRender()){this.preRender();}if(this.socket){this.socket.readyState===1&&this.socket.send(JSON.stringify(this.getSocketDefs()));}else{this.activate();}}},shutdown:function shutdown(){if(this.socket&&this.socket.readyState===1){var socketData=this.getSocketDefs();socketData.disable=1;this.socket.send(JSON.stringify(socketData));}},activate:function activate(){if(this.activating++||this._.blocked()||this.socket){return;}if(this.tried++>4){return;}$.ajax({context:this,url:this._.prefix+"/stats.cgi",error:function error(){var _this2=this;this.activating=0;if(this.error++>3){return;}!this.requery&&(this.requery=setTimeout(function(){_this2.requery=null;_this2.activate();},this.getInterval()*1000*4));},success:function success(data){var _this3=this;if(data.success){this.socket=new WebSocket(data.socket);this.socket.onopen=function(){_this3.tried=0;_this3.activating=0;_this3.socket.send(JSON.stringify(_this3.getSocketDefs()));};this.socket.onmessage=function(event){var message=JSON.parse(event.data),renderType=_this3.getRenderType(message);_this3.render(message,renderType);};this.socket.onclose=function(){setTimeout(function(){_this3.socket=null;_this3.activating=0;_this3.enable();},_this3.getInterval()*1000*4);};}else{this.activating=0;}this.error=0;},dataType:"json"});},preRender:function preRender(){this.render(this._.getHistoryData(),2);},render:function render(data,graphs){var _this4=this;Object.entries(data).map(function(_ref){var _ref2=_slicedToArray(_ref,2),target=_ref2[0],data=_ref2[1];var v=parseInt(data),vo=(typeof data==="undefined"?"undefined":_typeof(data))==="object"?data[data.length-1]:false,vt=vo?vo:v,$pc=$("#"+_this4.selector.dashboard+" ."+_this4.selector.piechart+"[data-charts*=\""+target+"\"]"),$lc=$("."+_this4.selector.slider+" ."+target+"_percent"),$od=$("#"+_this4.selector.dashboard+" span[data-id=\"sysinfo_"+target+"\"], \n ."+_this4.selector.slider+" span[data-data=\""+target+"\"]"),cached=target==="graphs"?graphs?graphs===3?3:2:_this4.graphsCanPreRender()?2:1:0;if(Number.isInteger(v)){if($pc.length){var piechart=$pc.data("easyPieChart");piechart&&piechart.update(v);}if($lc.length){$lc.find(".bar").attr("style","width:"+v+"%");var $dp=$lc.find(".description"),$lb=$dp.text().split(":")[0],uv=$lb+": "+v+"% ("+vo+")";if(target!=="cpu"){uv=plugins.slider.update.stats.graphs.flatten(uv);if(target!=="virt"){uv=plugins.slider.update.stats.graphs.plunk(uv);}}$dp.attr("title",vo).text(uv);}if($od.length){if($od.find("a").length){$od.find("a").text(vt);}else{$od.text(vt);}}}if(target==="sensors"&&vo){Object.entries(vo).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),sensor=_ref4[0],value=_ref4[1];var this_=_this4,$lb1=$("#"+_this4.selector.dashboard+" span[data-stats=\""+sensor+"\"]"),$lb2=$("."+_this4.selector.slider+" span[data-stats=\""+sensor+"\"]");if($lb1&&$lb1.length){var lb_count1=$lb1.length,lb_count2=$lb2.length;value.sort(function(a,b){return sensor==="fans"?a.fan-b.fan:a.core-b.core;});var updateLabel=function updateLabel($label,data,isSingleLabel,sideSlider){if(isSingleLabel){$label.html(function(_,html){var iSFahrenheit=html.includes("°F");return html.replace(/\d+/,sensor==="fans"?data.rpm:iSFahrenheit?Math.round(data.temp*9/5+32):data.temp);});}else{$label.html(function(_,html){var iSFahrenheit=html.includes("°F");return html.replace(/: \d+/,": "+(sensor==="fans"?data.rpm:iSFahrenheit?Math.round(data.temp*9/5+32):data.temp));});}var label_text=$label.text().replace(/.*?\d+:\s*/,"");var className=HTML.label.textMaxLevels(sensor,label_text)||(sideSlider?this_.selector.defaultSliderClassLabel:this_.selector.defaultClassLabel);if(sideSlider&&className===this_.selector.defaultClassLabel){className=this_.selector.defaultSliderClassLabel;}$label.removeClass(function(i,c){return(c.match(/\bbg-\S+/g)||[]).join(" ");}).addClass(className);};if(lb_count1===1){updateLabel($lb1,value[0],true);}else{$lb1.each(function(index,el){if(value[index]){updateLabel($(el),value[index],false);}});}if(lb_count2===1){updateLabel($lb2,value[0],true,true);}else{$lb2.each(function(index,el){if(value[index]){updateLabel($(el),value[index],false,true);}});}}});}if(cached){var lds=_this4.selector.chart.container.parent+"-"+_this4.selector.collapse,ld=$("#"+lds).find("["+_this4.selector.chart.loader+"]");Object.entries(data).map(function(_ref5){var _ref6=_slicedToArray(_ref5,2),_type=_ref6[0],array=_ref6[1];var options={chart:{type:function type(){return _type==="proc"||_type==="disk"||_type==="net";},bandwidth:function bandwidth(){return _type==="disk"||_type==="net";},fill:function fill(){return this.type()?false:true;},high:function high(){return this.type()?undefined:100;},threshold:function threshold(){return this.type()?-1:80;},height:"100px"}},lg=_this4._.language(_this4.selector.chart.container.parent+"_"+_type),tg=$("#"+lds).find("["+_this4.selector.chart.container.data+"="+_type+"]"),sr=[{name:"series-"+_type,data:array}];if(!tg.length){return;}if(array[0]&&_typeof(array[0].y)==="object"){sr=[];array[0].y.forEach(function(x,i){var data=[];array.forEach(function(n){data.push({data:{x:n.x,y:n.y[i]}});});sr.push({name:"series-"+_type+"-"+i,data:data});});}if(tg[0]&&tg[0].textContent&&cached!==3){if(cached===1){var lf=parseInt(_this4.getStoredDuration());if(lf<300||lf>3600){lf=600;}var tdata=sr,cdata=_this4["chart_"+_type].data.series,cdata_start=void 0,cdata_end=void 0,cdata_ready=new Promise(function(resolve){tdata.forEach(function(d,i,a){cdata_start=cdata[i].data[0].x||cdata[i].data[0].data.x;cdata_end=cdata[i].data[cdata[i].data.length-1].x||cdata[i].data[cdata[i].data.length-1].data.x;cdata[i].data.push(d.data[0]);if(cdata_end-cdata_start>lf){cdata[i].data.shift();}if(i===a.length-1){resolve();}});});cdata_ready.then(function(){_this4["chart_"+_type].update({series:cdata});});}}else if(cached===2||cached===3){_this4["chart_"+_type]=new _this4._.chart.Line(tg[0],{series:sr},{axisX:{type:_this4._.chart.FixedScaleAxis,divisor:12,labelInterpolationFnc:function labelInterpolationFnc(value){return _this4._.dayjs(value*1000).utcOffset(_this4._.locale.offset()).format(_this4._.locale.time);}},height:options.chart.height,showArea:options.chart.fill(),showPoint:!options.chart.fill(),high:options.chart.high(),low:0,fullWidth:true,chartPadding:{left:25},axisY:{onlyInteger:true,labelInterpolationFnc:function labelInterpolationFnc(value){if(options.chart.fill()){return value?value+"%":value;}else if(options.chart.bandwidth(value)){if(_type==="net"){return value?_this4._.convert.size(value,{fixed:0,bits:1,round:1}):value;}return value?_this4._.convert.size(value*1024,{fixed:0,round:1}):value;}else{return value;}}},plugins:[_this4._.chart.plugins.ctAxisTitle({axisY:{axisTitle:lg,axisClass:"ct-axis-title",offset:{x:0,y:9},flipTitle:true}}),_this4._.chart.plugins.ctThreshold({threshold:options.chart.threshold()})]});_this4["chart_"+_type].on("created",function(data){var ffObj=data.svg.getNode().querySelector('foreignObject');if(ffObj){var readLbl=_this4._.language("dashboard_chart_"+_type+"_read"),writeLbl=_this4._.language("dashboard_chart_"+_type+"_write");if(readLbl&&writeLbl){ffObj.setAttribute('data-label-read',"\u25AA "+readLbl);ffObj.setAttribute('data-label-write',"\u25AA "+writeLbl);}}ld.remove();});}});}});}}}; +"use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if(Symbol.iterator in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var 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:dayjs,locale:{time:config_portable_theme_locale_format_time,offset:function offset(){return get_utc_offset();}},can_conn_ws:can_conn_ws,blocked:theme_updating,getHistoryData:function getHistoryData(){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"},getSocketDefs:function getSocketDefs(){return{session:session.server.data("session-hash"),paused:!this.canRender()?1:0,interval:this.getInterval(),disable:!this.isEnabled()?1:0,shutdown:settings_sysinfo_real_time_shutdown_on_last?1:0};},graphsCanPreRender:function graphsCanPreRender(){return document.querySelector("["+this.selector.chart.loader+"]")?1:0;},getInterval:function getInterval(){return settings_sysinfo_real_time_run_rate/1000;},getStoredDuration:function getStoredDuration(){return settings_sysinfo_real_time_stored_duration;},getRenderType:function getRenderType(graphs){graphs=graphs.graphs;var hasMultipleDatasets=false;for(var key in graphs){if(graphs.hasOwnProperty(key)&&Array.isArray(graphs[key])){if(graphs[key].length>1){hasMultipleDatasets=true;break;}}}return hasMultipleDatasets?3:null;},canRender:function canRender(){return theme.visibility.get();},isEnabled:function isEnabled(){var stats_enabled=settings_sysinfo_real_time_status?1:0,stats_can=this._.can_conn_ws();return stats_enabled&&stats_can;},restart:function restart(){var _this=this;this.shutdown();setTimeout(function(){_this.enable();},this.getInterval()*1000*4);},disable:function disable(){if(this.socket&&this.socket.readyState===1){var socketData=this.getSocketDefs();socketData.paused=1;this.socket.send(JSON.stringify(socketData));}},enable:function enable(){if(this.isEnabled()){if(this.graphsCanPreRender()){this.preRender();}if(this.socket){this.socket.readyState===1&&this.socket.send(JSON.stringify(this.getSocketDefs()));}else{this.activate();}}},shutdown:function shutdown(){if(this.socket&&this.socket.readyState===1){var socketData=this.getSocketDefs();socketData.disable=1;this.socket.send(JSON.stringify(socketData));}},activate:function activate(){if(this.activating++||this._.blocked()||this.socket){return;}if(this.tried++>4){return;}$.ajax({context:this,url:this._.prefix+"/stats.cgi",error:function error(){var _this2=this;this.activating=0;if(this.error++>3){return;}!this.requery&&(this.requery=setTimeout(function(){_this2.requery=null;_this2.activate();},this.getInterval()*1000*4));},success:function success(data){var _this3=this;if(data.success){this.socket=new WebSocket(data.socket);this.socket.onopen=function(){_this3.tried=0;_this3.activating=0;_this3.socket.send(JSON.stringify(_this3.getSocketDefs()));};this.socket.onmessage=function(event){var message=JSON.parse(event.data),renderType=_this3.getRenderType(message);_this3.render(message,renderType);};this.socket.onclose=function(){setTimeout(function(){_this3.socket=null;_this3.activating=0;_this3.enable();},_this3.getInterval()*1000*4);};}else{this.activating=0;}this.error=0;},dataType:"json"});},preRender:function preRender(){this.render(this._.getHistoryData(),2);},render:function render(data,graphs){var _this4=this;Object.entries(data).map(function(_ref){var _ref2=_slicedToArray(_ref,2),target=_ref2[0],data=_ref2[1];var v=parseInt(data),vo=(typeof data==="undefined"?"undefined":_typeof(data))==="object"?data[data.length-1]:false,vt=vo?vo:v,$pc=$("#"+_this4.selector.dashboard+" ."+_this4.selector.piechart+"[data-charts*=\""+target+"\"]"),$lc=$("."+_this4.selector.slider+" ."+target+"_percent"),$od=$("#"+_this4.selector.dashboard+" span[data-id=\"sysinfo_"+target+"\"], \n ."+_this4.selector.slider+" span[data-data=\""+target+"\"]"),cached=target==="graphs"?graphs?graphs===3?3:2:_this4.graphsCanPreRender()?2:1:0;if(Number.isInteger(v)){if($pc.length){var piechart=$pc.data("easyPieChart");piechart&&piechart.update(v);}if($lc.length){$lc.find(".bar").attr("style","width:"+v+"%");var $dp=$lc.find(".description"),$lb=$dp.text().split(":")[0],uv=$lb+": "+v+"% ("+vo+")";if(target!=="cpu"){uv=plugins.slider.update.stats.graphs.flatten(uv);if(target!=="virt"){uv=plugins.slider.update.stats.graphs.plunk(uv);}}$dp.attr("title",vo).text(uv);}if($od.length){if($od.find("a").length){$od.find("a").text(vt);}else{$od.text(vt);}}}if(target==="sensors"&&vo){Object.entries(vo).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),sensor=_ref4[0],value=_ref4[1];var this_=_this4,$lb1=$("#"+_this4.selector.dashboard+" span[data-stats=\""+sensor+"\"]"),$lb2=$("."+_this4.selector.slider+" span[data-stats=\""+sensor+"\"]");if($lb1&&$lb1.length){var lb_count1=$lb1.length,lb_count2=$lb2.length;value.sort(function(a,b){return sensor==="fans"?a.fan-b.fan:a.core-b.core;});var updateLabel=function updateLabel($label,data,isSingleLabel,sideSlider){if(!data){return;}if(isSingleLabel){$label.html(function(_,html){var iSFahrenheit=html.includes("°F");return html.replace(/\d+/,sensor==="fans"?data.rpm:iSFahrenheit?Math.round(data.temp*9/5+32):data.temp);});}else{$label.html(function(_,html){var iSFahrenheit=html.includes("°F");return html.replace(/: \d+/,": "+(sensor==="fans"?data.rpm:iSFahrenheit?Math.round(data.temp*9/5+32):data.temp));});}var label_text=$label.text().replace(/.*?\d+:\s*/,"");var className=HTML.label.textMaxLevels(sensor,label_text)||(sideSlider?this_.selector.defaultSliderClassLabel:this_.selector.defaultClassLabel);if(sideSlider&&className===this_.selector.defaultClassLabel){className=this_.selector.defaultSliderClassLabel;}$label.removeClass(function(i,c){return(c.match(/\bbg-\S+/g)||[]).join(" ");}).addClass(className);};if(lb_count1===1){updateLabel($lb1,value[0],true);}else{$lb1.each(function(index,el){if(value[index]){updateLabel($(el),value[index],false);}});}if(lb_count2===1){updateLabel($lb2,value[0],true,true);}else{$lb2.each(function(index,el){if(value[index]){updateLabel($(el),value[index],false,true);}});}}});}if(cached){var lds=_this4.selector.chart.container.parent+"-"+_this4.selector.collapse,ld=$("#"+lds).find("["+_this4.selector.chart.loader+"]");Object.entries(data).map(function(_ref5){var _ref6=_slicedToArray(_ref5,2),_type=_ref6[0],array=_ref6[1];var options={chart:{type:function type(){return _type==="proc"||_type==="disk"||_type==="net";},bandwidth:function bandwidth(){return _type==="disk"||_type==="net";},fill:function fill(){return this.type()?false:true;},high:function high(){return this.type()?undefined:100;},threshold:function threshold(){return this.type()?-1:80;},height:"100px"}},lg=_this4._.language(_this4.selector.chart.container.parent+"_"+_type),tg=$("#"+lds).find("["+_this4.selector.chart.container.data+"="+_type+"]"),sr=[{name:"series-"+_type,data:array}];if(!tg.length){return;}if(array[0]&&_typeof(array[0].y)==="object"){sr=[];array[0].y.forEach(function(x,i){var data=[];array.forEach(function(n){data.push({data:{x:n.x,y:n.y[i]}});});sr.push({name:"series-"+_type+"-"+i,data:data});});}if(tg[0]&&tg[0].textContent&&cached!==3){if(cached===1){var lf=parseInt(_this4.getStoredDuration());if(lf<300||lf>3600){lf=600;}var tdata=sr,cdata=_this4["chart_"+_type].data.series,cdata_start=void 0,cdata_end=void 0,cdata_ready=new Promise(function(resolve){tdata.forEach(function(d,i,a){cdata_start=cdata[i].data[0].x||cdata[i].data[0].data.x;cdata_end=cdata[i].data[cdata[i].data.length-1].x||cdata[i].data[cdata[i].data.length-1].data.x;cdata[i].data.push(d.data[0]);if(cdata_end-cdata_start>lf){cdata[i].data.shift();}if(i===a.length-1){resolve();}});});cdata_ready.then(function(){_this4["chart_"+_type].update({series:cdata});});}}else if(cached===2||cached===3){_this4["chart_"+_type]=new _this4._.chart.Line(tg[0],{series:sr},{axisX:{type:_this4._.chart.FixedScaleAxis,divisor:12,labelInterpolationFnc:function labelInterpolationFnc(value){return _this4._.dayjs(value*1000).utcOffset(_this4._.locale.offset()).format(_this4._.locale.time);}},height:options.chart.height,showArea:options.chart.fill(),showPoint:!options.chart.fill(),high:options.chart.high(),low:0,fullWidth:true,chartPadding:{left:25},axisY:{onlyInteger:true,labelInterpolationFnc:function labelInterpolationFnc(value){if(options.chart.fill()){return value?value+"%":value;}else if(options.chart.bandwidth(value)){if(_type==="net"){return value?_this4._.convert.size(value,{fixed:0,bits:1,round:1}):value;}return value?_this4._.convert.size(value*1024,{fixed:0,round:1}):value;}else{return value;}}},plugins:[_this4._.chart.plugins.ctAxisTitle({axisY:{axisTitle:lg,axisClass:"ct-axis-title",offset:{x:0,y:9},flipTitle:true}}),_this4._.chart.plugins.ctThreshold({threshold:options.chart.threshold()})]});_this4["chart_"+_type].on("created",function(data){var ffObj=data.svg.getNode().querySelector('foreignObject');if(ffObj){var readLbl=_this4._.language("dashboard_chart_"+_type+"_read"),writeLbl=_this4._.language("dashboard_chart_"+_type+"_write");if(readLbl&&writeLbl){ffObj.setAttribute('data-label-read',"\u25AA "+readLbl);ffObj.setAttribute('data-label-write',"\u25AA "+writeLbl);}}ld.remove();});}});}});}}}; diff --git a/extensions/stats/stats.min.js.gz b/extensions/stats/stats.min.js.gz index 9e6620cb9..3673940af 100644 Binary files a/extensions/stats/stats.min.js.gz and b/extensions/stats/stats.min.js.gz differ diff --git a/extensions/stats/stats.src.js b/extensions/stats/stats.src.js index c65a3c1cc..bab9dd4ae 100644 --- a/extensions/stats/stats.src.js +++ b/extensions/stats/stats.src.js @@ -310,6 +310,9 @@ const stats = { // Function to update individual label const updateLabel = function ($label, data, isSingleLabel, sideSlider) { + if (!data) { + return; + } // Update the label text based on count condition if (isSingleLabel) { // Replace only the numeric part, preserving unit (°C or RPM) diff --git a/unauthenticated/js/bundle.min.js.gz b/unauthenticated/js/bundle.min.js.gz index 91277fc8f..0dacd18e0 100644 Binary files a/unauthenticated/js/bundle.min.js.gz and b/unauthenticated/js/bundle.min.js.gz differ