/* * Constants.js * This avoids the hassle of constantly creating new strings. * These are common strings. */function Histogram(e){Metric.call(this,e);var t=this.n;this.data=d3.range(e.points.length).map(function(t,n){return{name:e.points[n].stackName,values:[{time:+e.now,value:null}]}}),this.mostRecent=e.points.map(function(t){return{name:t.stackName,values:{time:+e.now,value:null}}})}function Line(e){Metric.call(this,e),this.data=[{time:+e.now,value:null}],this.mostRecent=[{time:+e.now,value:null}]}var C=function(){return{WIDTH:"width",HEIGHT:"height",G:"g",TRANSFORM:"transform",CLASS:"class",ID:"id",RECT:"rect",TEXT:"text",X:"x",Y:"y",D:"d",PATH:"path",LINE:"line",AREA:"area",PERIOD:".",HASH:"#",TRANSLATE:"translate",OPENPAREN:"(",CLOSEPAREN:")",DASH:"-",COMMA:",",CLIP:"clip",URL:"url",ZERO:"0",HIDDEN:"hidden",TIME:"time",VALUE:"value",NAME:"name",TIME:"time"}}(),allTags=[],metricId=0,PupController,Metric=function(e){this.n=PupController.n(),this.createdAt=new Date,this.uuid=metricId++,this.name=e.metric,this.type=e.type,this.freq=e.freq*1e3,this.tags=e.tags,this.max=0,this.data=[],this.timedOut={at:+e.now,is:!1};for(var t=0;tn&&(n=t[1]),e.stackName==="avg"&&(r=t[1]),{time:t[0]*1e3,value:t[1]}})[0]}}),this.max=n,this.average=r},Histogram.prototype.pushRecent=function(){for(var e=0;ethis.freq*2?!0:!1,this.timedOut.is&&(this.timedOut.at=+e)},Histogram.prototype.hasNewData=function(){return d3.min(this.mostRecent,function(e){return e.values.time})>d3.min(this.data,function(e){return e.values[e.values.length-1].time})},Histogram.prototype.resetMax=function(){var e=this.max;this.data.map(function(t){t.values.map(function(t){t.value>e&&(e=t.value)})}),this.max=e},Histogram.prototype.toCSV=function(){var e="time,",t=this.data[0];a=t;for(var n=-1,r=t.values.length;n"}return e},Line.prototype.updateMostRecent=function(e,t){var n=this.max;this.mostRecent[0]=e.points.map(function(e){return e[1]>n&&(n=e[1]),{time:e[0]*1e3,value:e[1]}})[0],this.max=n},Line.prototype.pushNull=function(e){this.data[this.data.length]={time:+e,value:null}},Line.prototype.pushRecent=function(){var e={time:this.mostRecent[0].time,value:this.mostRecent[0].value};this.data[this.data.length]=e},Line.prototype.shiftOld=function(e){while(this.data[0].timethis.freq*2?!0:!1,this.timedOut.is&&(this.timedOut.at=+e)},Line.prototype.hasNewData=function(){return this.mostRecent[0].time>this.data[this.data.length-1].time},Line.prototype.resetMax=function(){var e=this.max;this.data.map(function(t,n){t.value>e&&n>0&&(e=t.value)}),this.max=e},Line.prototype.toCSV=function(){var e="",t=this.data;for(var n=-1,r=t.length;n"}return e};var Store=function(){var e={},t=20,n=!1,r=function(e,t){var n;return e[t].type==="histogram"?n=Histogram:e[t].type!=="histogram"&&(n=Line),new n({now:new Date,metric:t,type:e[t].type,tags:e[t].tags||[],freq:e[t].freq,points:e[t].points})},i=function(e){return"Waiting"in e?!1:!0},s=function(e){return e.type&&e.freq&&e.points?!0:!1},o={};return o.save=function(o){if(i(o)){for(var u in o){if(!o.hasOwnProperty(u)||!s(o[u]))return 1;if(!(u in e))if(Object.keys(e).lengthf.freq*2?(d3.select("#progress-wrapper"+f.uuid).classed("hidden",!0),this.finishedProgress=!0):d3.select("#progress"+f.uuid).transition().duration(100).ease("linear").attr(C.WIDTH,t*20/f.freq)}}},LineGraph=function(e){MetricGraph.call(this,e);var t=this,n=this.metric;t.element.select(".type-symbol").append("img").attr("src","/pup-line.png"),t.path=t.svg.append(C.G).attr("clip-path",function(e,t){return"url(#clip"+n.uuid+C.DASH+t+C.CLOSEPAREN}).append(C.PATH).data([n.data]).attr(C.CLASS,C.AREA).attr(C.ID,C.AREA+n.uuid).attr(C.D,t.area),t.stroke=t.svg.append(C.G).attr("clip-path",function(e,t){return"url(#clip"+n.uuid+C.DASH+t+C.CLOSEPAREN}).append(C.PATH).data([n.data]).attr(C.CLASS,C.LINE).attr(C.ID,C.LINE+n.uuid).attr(C.D,t.line),t.updateLatestVal=function(e){n.timedOut.is||+e-n.timedOut.at-1)break;g||(u[l].style.display="",a[l].style.display="")}}var y=n("#query").val();y.length&&o.filterBy(y),o.updatePlotCount(),e