BOWERDEPS="undefined"==typeof BOWERDEPS?{}:BOWERDEPS,function(){var t,e,r=function(t,e){return function(){return t.apply(e,arguments)}},i=[].indexOf||function(t){for(var e=0,r=this.length;r>e;e++)if(e in this&&this[e]===t)return e;return-1};e=function(){function t(){return["ui.router","ngAnimate","guanlecoja.ui","bbData"]}return t}(),t=function(){function t(t,i,n,a,s,l,o,c,u,d,h,p,g){var f,m;this.$rootElement=t,this.$scope=i,this.$window=s,this.$log=l,this.$uibModal=o,this.dataProcessorService=d,this.bbSettingsService=p,this.renderNewData=r(this.renderNewData,this),this.zoomMinus=r(this.zoomMinus,this),this.zoomPlus=r(this.zoomPlus,this),e=this,f=[{caption:"",icon:"search-plus",action:this.zoomPlus},{caption:"",icon:"search-minus",action:this.zoomMinus}],m=this.$rootElement.find("body"),m.addClass("hundredpercent"),this.$scope.$on("$destroy",function(t){return function(){return m.removeClass("hundredpercent")}}(this)),g.setContextualActions(f),this.loading=!0,this.dataAccessor=c.open().closeOnDestroy(this.$scope),this.s=this.bbSettingsService.getSettingsGroup("Waterfall"),this.c={margin:{top:15,right:20,bottom:20,left:70},gap:30,scaling:this.s.scaling_waterfall.value,minColumnWidth:this.s.min_column_width_waterfall.value,timeFormat:"%x^%H:%M",limit:this.s.lazy_limit_waterfall.value,threshold:this.s.idle_threshold_waterfall.value,buildidBackground:this.s.number_background_waterfall.value},this.all_builders=this.dataAccessor.getBuilders({order:"name"}),this.$scope.builders=this.builders=[],this.buildLimit=this.c.limit,this.$scope.builds=this.builds=this.dataAccessor.getBuilds({limit:this.buildLimit,order:"-started_at"}),u.get().then(function(t){return function(e){var r,i,n,a,s;return t.d3=e,t.scale=new h(t.d3),t.groups=t.dataProcessorService.getGroups(t.all_builders,t.builds,t.c.threshold),t.$scope.builders=t.builders=t.dataProcessorService.filterBuilders(t.all_builders),t.dataProcessorService.addStatus(t.builders),t.waterfall=t.d3.select(".waterfall"),t.container=t.waterfall.select(".svg-container"),t.header=t.waterfall.select(".header-content"),t.createElements(),t.render(),t.loading=!1,t.$scope.$watch(function(){return t.waterfall.style("width")},function(e,r){return e!==r?t.render():void 0},!0),t.loadingMore=!1,t.builds.onChange=t.all_builders.onChange=t.renderNewData,r=t.container.node().parentNode,n=function(){return!t.loadingMore&&t.getHeight()-r.scrollTop<1e3?(t.loadingMore=!0,t.loadMore()):void 0},angular.element(r).bind("scroll",n),a=function(){return t.render()},s=angular.element(t.$window),s.bind("resize",a),i=function(e){return"+"===e.key&&(e.preventDefault(),t.zoomPlus()),"-"===e.key?(e.preventDefault(),t.zoomMinus()):void 0},s.bind("keypress",i),t.$scope.$on("$destroy",function(){return s.unbind("keypress",i),s.unbind("resize",a)})}}(this))}var e;return e=null,t.prototype.zoomPlus=function(){return this.incrementScaleFactor(),this.render()},t.prototype.zoomMinus=function(){return this.decrementScaleFactor(),this.render()},t.prototype.incrementScaleFactor=function(){return this.c.scaling*=1.5,this.s.scaling_waterfall.value*=1.5,this.bbSettingsService.save()},t.prototype.decrementScaleFactor=function(){return this.c.scaling/=1.5,this.s.scaling_waterfall.value/=1.5,this.bbSettingsService.save()},t.prototype.loadMore=function(){var t;if(!(this.builds.length0?(t=(this.$window.innerWidth-this.c.margin.right-this.c.margin.left)/this.builders.length,e=this.c.minColumnWidth<=t,r=e?"100%":this.builders.length*this.c.minColumnWidth+this.c.margin.right+this.c.margin.left+"px",this.waterfall.select(".inner-content").style("width",r),this.waterfall.select(".header-content").style("width",r)):this.$log.error("Bad column width configuration\n min: "+this.c.minColumnWidth)},t.prototype.getHeight=function(){return parseInt(this.container.style("height").replace("px",""),10)},t.prototype.setHeight=function(){var t,e,r,i,n,a;for(e=-this.c.gap,a=this.groups,i=0,n=a.length;n>i;i++)t=a[i],e+=t.max-t.min+this.c.gap;return r=e*this.c.scaling+this.c.margin.top+this.c.margin.bottom,re;e++)t=n[e],i=Math.max(t.name.length,i);return Math.max(100,3*i)},t.prototype.getResultClassFromThing=function(t){var e;if(!t.complete&&t.started_at>=0)e="pending";else switch(t.results){case 0:e="success";break;case 1:e="warnings";break;case 2:e="failure";break;case 3:e="skipped";break;case 4:e="exception";break;case 5:e="cancelled";break;default:e="unknown"}return e},t.prototype.drawXAxis=function(){var t,r,i,n,a,s;return n=this.scale.getX(this.builders,this.getInnerWidth()),r=this.scale.getBuilderName(this.builders),this.header.select(".axis.x").remove(),t=this.header.append("g").attr("class","axis x"),t.selectAll("*").remove(),a=this.d3.svg.axis().scale(n).orient("top").tickFormat(r),s=t.call(a),i=function(t){var r,i;return i=e.d3.select(this.parentNode),r=i.append("a").attr("xlink:href","#/builders/"+t),r.node().appendChild(this)},s.selectAll("text").style("text-anchor","start").attr("transform","translate(0, -16) rotate(-25)").attr("dy","0.75em").each(i),s.selectAll("line").data(this.builders).attr("transform","rotate(90)").attr("x1",0).attr("x2",0).attr("y1",n.rangeBand(1)/2).attr("y2",-n.rangeBand(1)/2).attr("class",e.getResultClassFromThing).classed("stroke",!0)},t.prototype.ticks=[],t.prototype.addTicks=function(t){var e;return e=this.scale.getY(this.groups,this.c.gap,this.getInnerHeight()),this.ticks=this.ticks.concat([e(t.complete_at),e(t.started_at)])},t.prototype.removeTicks=function(){return this.ticks=[]},t.prototype.drawYAxis=function(){var t,r,n,a,s,l,o,c,u,d,h,p;for(a=this.d3.scale.linear(),h=this.scale.getY(this.groups,this.c.gap,this.getInnerHeight()),this.chart.select(".axis.y").remove(),t=this.chart.append("g").attr("class","axis y"),t.attr("transform","translate("+this.waterfall.node().scrollLeft+", 0)"),this.waterfall.on("scroll",function(){return p.attr("transform","translate("+this.scrollLeft+", 0)")}),t.append("rect").attr("x",-this.c.margin.left).attr("y",-this.c.margin.top).attr("width",this.c.margin.left).attr("height",this.getHeight()).style("fill","#fff"),d=this.ticks,c=this.groups,s=0,l=c.length;l>s;s++)n=c[s],d=d.concat([h(n.min),h(n.max)]);return u=function(t){return function(e){var r,i,n;return n=h.invert(e),r=new Date(1e3*n),(i=t.d3.time.format(t.c.timeFormat))(r)}}(this),p=this.d3.svg.axis().scale(a).orient("left").tickValues(d).tickFormat(u),p=t.call(p),o=function(){var t,r,i,n,s,l,o,c;for(t=e.d3.select(this),o=t.text().split("^"),t.text(""),n=[],a=r=0,i=o.length;i>r;a=++r)l=o[a],s=t.append("tspan").text(l),0!==a?(c=t.attr("x"),n.push(s.attr("x",c).attr("dy",10*a))):n.push(void 0);return n},p.selectAll("text").each(o),r=function(t){return function(e){return i.call(t.ticks,e)>=0?"2, 5":"2, 1"}}(this),p.selectAll(".tick").append("line").attr("x2",this.getInnerWidth()).attr("stroke-dasharray",r)},t.prototype.drawBuilds=function(){var t,r,i,n,a,s,l,o;return l=this.scale.getX(this.builders,this.getInnerWidth()),o=this.scale.getY(this.groups,this.c.gap,this.getInnerHeight()),this.chart.selectAll(".builder").remove(),t=this.chart.selectAll(".builder").data(this.builders).enter().append("g").attr("class","builder").attr("transform",function(t){return"translate("+l(t.builderid)+", 0)"}),i=function(t){return t.builds},a=function(t){return t.buildid},r=t.selectAll(".build").data(i,a).enter().append("g").attr("class","build").attr("transform",function(t){return"translate(0, "+o(t.complete_at)+")"}),s=function(t,e){return t>e?t:e},n=function(t){return s(10,Math.abs(o(t.started_at)-o(t.complete_at)))},r.append("rect").attr("class",e.getResultClassFromThing).attr("width",l.rangeBand(1)).attr("height",n).classed("fill",!0),this.c.buildidBackground&&r.append("rect").attr("y",-15).attr("width",l.rangeBand(1)).attr("height",15).style("fill","#ccc"),r.append("text").attr("class","id").attr("x",l.rangeBand(1)/2).attr("y",-3).text(function(t){return t.number}),r.on("mouseover",this.mouseOver).on("mousemove",this.mouseMove).on("mouseout",this.mouseOut).on("click",this.click)},t.prototype.mouseOver=function(t){var r,i,n,a,s,l,o;return r=e.d3.select(this),n=e.d3.mouse(this),e.addTicks(t),e.drawYAxis(),a=e.d3.select(this.parentNode),this.parentNode.appendChild(this),a.each(function(){return this.parentNode.appendChild(this)}),l=t.builderid0?"("+e/1e3+"s)":""},o.selectAll(".buildstep").data(t).enter().append("g").attr("class","buildstep").append("text").attr("y",function(t,e){return 15*(e+1)}).attr("x",l?30:10).attr("class",e.getResultClassFromThing).classed("fill",!0).transition().delay(100).text(function(t,e){return e+1+". "+t.name+" "+r(t)})}},t.prototype.mouseMove=function(t){var r,i;return r=e.d3.select(this),i=e.d3.mouse(this),r.select(".svg-tooltip").attr("transform","translate("+i[0]+", "+i[1]+")")},t.prototype.mouseOut=function(t){var r;return r=e.d3.select(this),e.removeTicks(),e.drawYAxis(),r.selectAll(".svg-tooltip").remove()},t.prototype.click=function(t){var r;return r=e.$uibModal.open({templateUrl:"waterfall_view/views/modal.html",controller:"waterfallModalController as modal",windowClass:"modal-small",resolve:{selectedBuild:function(){return t}}})},t.prototype.renderNewData=function(){return this.groups=this.dataProcessorService.getGroups(this.all_builders,this.builds,this.c.threshold),this.$scope.builders=this.builders=this.dataProcessorService.filterBuilders(this.all_builders),this.dataProcessorService.addStatus(this.builders),this.render(),this.loadingMore=!1},t.prototype.render=function(){var t,e,r;return t=this.container.node().parentNode,r=this.scale.getY(this.groups,this.c.gap,this.getInnerHeight()),e=r.invert(t.scrollTop),this.setWidth(),this.setHeight(),this.drawBuilds(),this.drawXAxis(),this.drawYAxis()},t}(),angular.module("waterfall_view",new e).controller("waterfallController",["$rootElement","$scope","$q","$timeout","$window","$log","$uibModal","dataService","d3Service","dataProcessorService","scaleService","bbSettingsService","glTopbarContextualActionsService",t])}.call(this),function(){var t;t=function(){function t(t){t.addSettingsGroup({name:"Waterfall",caption:"Waterfall related settings",items:[{type:"integer",name:"scaling_waterfall",caption:"Scaling factor",default_value:1},{type:"integer",name:"min_column_width_waterfall",caption:"Minimum column width (px)",default_value:40},{type:"integer",name:"lazy_limit_waterfall",caption:"Lazy loading limit",default_value:40},{type:"integer",name:"idle_threshold_waterfall",caption:"Idle time threshold in unix time stamp (eg. 300 = 5 min)",default_value:300},{type:"bool",name:"number_background_waterfall",caption:"Build number background",default_value:!1}]})}return t}(),angular.module("waterfall_view").config(["bbSettingsServiceProvider",t])}.call(this),function(){var t;t=function(){function t(t,e){var r,i,n;i="waterfall",e.addGroup({name:i,caption:"Waterfall View",icon:"bar-chart-o",order:5}),r={group:i,caption:"Waterfall View"},n={controller:i+"Controller",controllerAs:"w",templateUrl:"waterfall_view/views/"+i+".html",name:i,url:"/"+i,data:r},t.state(n)}return t}(),angular.module("waterfall_view").config(["$stateProvider","glMenuServiceProvider",t])}.call(this),function(){var t;t=function(){function t(){}return t.prototype.getGroups=function(t,e,r){var i,n,a,s,l,o,c,u,d;for(e.sort(function(t,e){return t.buildid-e.buildid}),s=[],a=-1,c={groupid:0,time:0},l=0,u=t.length;u>l;l++)n=t[l],n.builds=[];for(o=0,d=e.length;d>o;o++)i=e[o],n=t.get(i.builderid),null!=n&&n.builds&&(i.started_at-c.time>r&&++a,null==s[a]&&(s[a]={min:i.started_at}),c.groupid!==a&&(s[c.groupid].max=c.time),i.complete||(i.complete_at=Math.round(new Date/1e3)),i.groupid=c.groupid=a,n=t.get(i.builderid),n.builds.push(i),i.complete_at>c.time&&(c.time=i.complete_at));return s[c.groupid]&&(s[c.groupid].max=c.time),s},t.prototype.addStatus=function(t){var e,r,i,n,a,s,l,o,c;for(c=[],i=0,s=t.length;s>i;i++){for(r=t[i],a=null,o=r.builds,n=0,l=o.length;l>n;n++)e=o[n],a=e,e.number>a.number&&(a=e);r.started_at=null!=a?a.started_at:void 0,r.complete=(null!=a?a.complete:void 0)||!1,c.push(r.results=null!=a?a.results:void 0)}return c},t.prototype.filterBuilders=function(t){var e,r,i,n,a;for(a=[],r=0,i=t.length;i>r;r++)e=t[r],(null!=(n=e.builds)?n.length:void 0)&&a.push(e);return a},t}(),angular.module("waterfall_view").service("dataProcessorService",[t])}.call(this),function(){var t;t=function(){function t(t,e,r){this.$uibModalInstance=e,this.selectedBuild=r,t.$on("$stateChangeStart",function(t){return function(){return t.close()}}(this))}return t.prototype.close=function(){return this.$uibModalInstance.close()},t}(),angular.module("waterfall_view").controller("waterfallModalController",["$scope","$uibModalInstance","selectedBuild",t])}.call(this),function(){var t;t=function(){function t(){var t;return t=function(){function t(t){this.d3=t}return t.prototype.getX=function(t,e){return t.map(function(t){return t.builderid}),this.d3.scale.ordinal().domain(t.map(function(t){return t.builderid})).rangeRoundBands([0,e],.05)},t.prototype.getY=function(t,e,r){var i,n,a,s,l,o,c;for(i=r,n=i-(t.length-1)*e,a=0,o=0,c=t.length;c>o;o++)l=t[o],a+=l.max-l.min;return s=function(){function r(r){var s,o,c,u,d,h,p,g;for(p=[],s=o=0,u=t.length;u>o;s=++o){if(l=t[s],l.min<=r&&r<=l.max){for(p.push(r-l.min),g=0,c=0,d=p.length;d>c;c++)h=p[c],g+=h;return i-n/a*g-s*e}p.push(l.max-l.min)}return void 0}return r.invert=function(r){var s,o,c,u,d,h,p,g,f;for(g=[],o=c=0,d=t.length;d>c;o=++c){for(l=t[o],f=0,u=0,h=g.length;h>u;u++)p=g[u],f+=p;if(s=(i-r-o*e)*(a/n)-f+l.min,l.min<=s&&s<=l.max)return s;g.push(l.max-l.min)}return void 0},r}()},t.prototype.getBuilderName=function(t){return this.d3.scale.ordinal().domain(t.map(function(t){return t.builderid})).range(t.map(function(t){return t.name}))},t}()}return t}(),angular.module("waterfall_view").factory("scaleService",[t])}.call(this),angular.module("waterfall_view").run(["$templateCache",function(t){t.put("waterfall_view/views/waterfall.html",'

loading

'),t.put("waterfall_view/views/modal.html",'')}]);