graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 8.87 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{82:function(t,e,n){"use strict";n.r(e);n(4);const r=240,o=70;let a=r;const i=24,s=28,l=["#0CB0A0","#F04E23","#003663","#ffcc99","#99ccff","#ccff99","#ff99cc","#99ffcc"];function d(t){return t.weight>0}function c(t){return t.weight>0}angular.module("graphdb.framework.clustermanagement.directives",["graphdb.framework.utils.localstorageadapter"]).directive("clusterGraphicalView",["$window","$timeout","LocalStorageAdapter","LSKeys",function(t,e,n,u){return{restrict:"A",link:function(f,p){function h(){var e="collapsedMenu"===n.get(u.MENU_STATE);return a=e?o:r,Math.max(Math.floor(.95*(t.innerWidth-a)),600)}function g(){return Math.max(t.innerHeight-120,600)}var v=h(),y=g(),x=function(t){return l[t%l.length]};f.width=function(){return v},f.height=function(){return y};var m=d3.select(p[0]).append("svg").attr("width",v).attr("height",y),w=m.append("svg:path").attr("class","link dragline").attr("visibility","hidden").attr("d","M0,0L0,0"),M=null,b=0,k=null,E=null,T=null,A=null;function N(){E=null,A=null,k=null}m.on("mousedown",(function(){d3.event.preventDefault(),m.classed("active",!0),d3.event.ctrlKey||E||k||f.selectNode(null)})).on("mousemove",(function(){E&&w.attr("d","M"+E.x+","+E.y+"L"+d3.mouse(this)[0]+","+d3.mouse(this)[1])})).on("mouseup",(function(){E&&w.attr("visibility","hidden").style("marker-end",""),m.classed("active",!1),d3.select(T).classed("dragged",!1),N()}));var L=1200;function H(){!function(){var t=_.filter(f.nodes,(function(t){return"worker"===t.repositoryType&&!d(t)}));console.log(Math.floor((y-50)/110));for(var e=Math.max(Math.min(Math.floor(y/110),6),3),n=Math.ceil(t.length/e),r=0;r<t.length;r++){var o=r%e,a=n-Math.floor(r/e)-1,i=Math.min(L,f.width()),s=f.width()-i;t[r].px=t[r].x=f.width()-s/2-64*a-35,t[r].py=t[r].y=110*o+50,t[r].fixed=!0}}(),function(){for(var t=_.filter(f.nodes,(function(t){return"master"===t.repositoryType&&!c(t)})),e=Math.max(Math.min(Math.floor((y-200)/110),6),3),n=Math.ceil(t.length/e),r=0;r<t.length;r++){var o=r%e,a=n-Math.floor(r/e)-1,i=Math.min(L,f.width()),s=f.width()-i;t[r].px=t[r].x=s/2+64*a+35,t[r].py=t[r].y=110*o+50,t[r].fixed=!0}}(),function(){var t=[],e=[];_.each(f.nodes,(function(n){"master"===n.repositoryType&&c(n)?t.push(n):"worker"===n.repositoryType&&d(n)&&e.push(n)}));for(var n=f.width()/3,r=f.height()/(t.length+1),o=0;o<t.length;o++)t[o].px=t[o].x=n,t[o].py=t[o].y=r*(o+1),t[o].fixed=!1;var a=f.height()/(e.length+1);for(o=0;o<e.length;o++)e[o].px=e[o].x=2*n,e[o].py=e[o].y=a*(o+1),e[o].fixed=!1}()}f.render=function(){if(void 0!==f.nodes){null!==M&&M.stop(),m.selectAll("g").remove(),M=d3.layout.force().nodes(f.nodes).links(f.links).gravity(0).charge(-50).size([v,y]).linkStrength(.05).linkDistance((function(t){return"master"===t.source.repositoryType&&"master"===t.target.repositoryType?.208*Math.min(v,1200):.375*Math.min(v,1200)})).on("tick",(function(){t.attr("d",(function(t){var e=t.target.x-t.source.x,n=t.target.y-t.source.y,r=Math.sqrt(e*e+n*n),o=e/r,a=n/r,i=t.left?17:12,s=t.right?17:12;return"M"+(t.source.x+i*o)+","+(t.source.y+i*a)+"L"+(t.target.x-s*o)+","+(t.target.y-s*a)})),n.attr("transform",(function(t){var e=t.target.x-t.source.x,n=t.target.y-t.source.y,r=Math.sqrt(e*e+n*n),o=e/r,a=n/r;return"translate("+(t.target.x-70*o)+" "+(t.target.y-70*a)+")"})),o.attr("transform",(function(t){return t.fixed||(t.x>v-50?t.x-=50:t.x<50&&(t.x=50),t.y>y-50?t.y-=50:t.y<50&&(t.y=50)),"translate("+t.x+","+t.y+")"}))}));var t,n,r=m.append("svg:g").selectAll("g"),o=m.append("svg:g").selectAll("g");f.updateStatuses=function(){r.select(".link").attr("class",(function(t){return t.status+" link"}))},f.restart=c,f.updateWarnings=function(){r.select("g").classed("link-warning-visible",(function(t){return t.reversePeerMissing&&!("disabledReason"in t.target)}))},f.updateColors=function(){++b>=f.clusters.length&&(b=0);for(var t=b;!f.clusters[b].hasWorkers;)if(++b>=f.clusters.length&&(b=0),b===t)return;o.selectAll(".repo").style("fill",a)},f.refreshMastersIcons=function(){d3.selectAll(".repo").text(d)},f.resize=function(){v=h(),y=g(),m.attr("width",v),m.attr("height",y),M.size([v,y]).resume(),f.restart()},c()}function a(t){return void 0===t.cluster||0===t.cluster.length?"#888":"worker"===t.repositoryType?t.cluster.indexOf(b)>=0?x(b):x(t.cluster[0]):x(t.cluster)}function l(t){return"master"===t.repositoryType?t.readonly&&"MUTE"===t.mode?"":t.readonly?"":"MUTE"===t.mode?"":"":"worker"===t.repositoryType?"":void 0}function d(t){return"master"===t.repositoryType?t.readonly&&"MUTE"===t.mode?"":t.readonly?"":"MUTE"===t.mode?"":"":"worker"===t.repositoryType?"":void 0}function c(){var u=(r=r.data(f.links)).enter().append("svg:g");u.append("svg:path").attr("class",(function(t){return t.status+" link"})).on("mousedown",(function(t){0===d3.event.button&&(d3.event.stopPropagation(),f.disconnectLinkConfirm(t,c))})).on("mouseover",(function(){$(".node-default-tip").hide(),$(".node-disconnect-tip").show()})).on("mouseout",(function(){$(".node-default-tip").show(),$(".node-disconnect-tip").hide()})),t=r.select("path"),(n=u.append("svg:g").classed("link-warning",!0).on("mouseover",(function(){$(".node-default-tip").hide(),$(".node-warning-tip").show()})).on("mouseout",(function(){$(".node-default-tip").show(),$(".node-warning-tip").hide()}))).append("svg:polygon").attr("points","0 -16.6666, 14.4337 8.3333, -14.4337 8.3333").attr("fill","white"),n.append("svg:text").text("").attr("text-anchor","middle").attr("alignment-baseline","baseline").classed("icon-any",!0),n=r.select("g"),r.exit().remove(),(o=o.data(f.nodes)).selectAll(".repo").style("fill",a).classed("reflexive",(function(t){return t.reflexive}));var p=o.enter().append("svg:g");p.append("svg:g").attr("class","node").attr("title","Drag and drop node to connect to other nodes").classed("reflexive",(function(t){return t.reflexive})).on("mouseover",(function(t){E&&t!==E?d3.select(this).classed("dragged",!0):($(".node-default-tip").hide(),$(".node-connect-tip").show())})).on("mouseout",(function(t){E&&t!==E?d3.select(this).classed("dragged",!1):($(".node-default-tip").show(),$(".node-connect-tip").hide())})).on("mousedown",(function(t){d3.event.ctrlKey||0!==d3.event.button||(E=t,T=this,w.style("marker-end","url(#end-arrow)").attr("visibility","visible").attr("d","M"+E.x+","+E.y+"L"+E.x+","+E.y),d3.select(this).classed("dragged",!0))})).on("click",(function(t){d3.select(this).classed("dragged",!0),f.selectNode(t);var e=d3.select(".nodetooltip"),n=$(window).width();d3.event.pageX<n/2?(e.style("left",d3.event.pageX+"px"),e.style("right","")):(e.style("left",""),e.style("right",n-d3.event.pageX+"px")),e.style("top",d3.event.pageY-28+"px"),console.log(angular.copy(d3.event))})).on("mouseup",(function(t){E&&(w.attr("visibility","hidden").style("marker-end",""),(A=t)!==E?(d3.select(this).classed("dragged",!1),f.connectNodes(E,A,c),f.selectNode(null)):N())})).append("svg:circle").attr("r",i+10);var h=document.createElement("a");p.append("svg:text").attr("y",25).attr("text-anchor","middle").attr("class","icon-any").attr("fill","white").text(l),p.append("svg:text").attr("y",25).attr("text-anchor","middle").attr("class","icon-any repo").attr("fill",a).text(d);var g=p.append("svg:g"),v=g.append("svg:rect");g.append("svg:text").attr("x",0).attr("y",(function(t){return 53})).attr("class","id id-host").text((function(t){if(t.local)return"local";h.href=t.location;var e=h.hostname;return function(t){for(var e=t.split("."),n=0,r=0;n<e.length;n++)if(parseInt(e[n],10)>=0&&parseInt(e[n],10)<=255?r++:r=0,4===r)return!0;return!1}(h.hostname)||(e=h.hostname.split(".")[0]),e+":"+h.port})).each((function(t){t.labelHost=this}));var y=p.append("svg:g"),x=y.append("svg:rect");y.append("svg:text").attr("x",0).attr("y",38).attr("class","id").text((function(t){return t.name})).each((function(t){t.labelNode=this})),p.append("svg:line").attr("x1",-s-5).attr("x2",s+5).attr("y1",0).attr("y2",0).attr("stroke","red").attr("stroke-width",4).attr("transform","rotate(-45)").attr("class","disabled-bar").attr("visibility",(function(t){return"disabledReason"in t?"visible":"hidden"})),o.exit().remove(),M.start(),H(),e((function(){function t(t){try{return t.getBBox()}catch(t){return{x:0,y:0,width:0,height:0}}}v.attr("width",(function(e){return t(e.labelHost).width+4})).attr("height",(function(e){return t(e.labelHost).height})).attr("x",(function(e){return t(e.labelHost).x-2})).attr("y",(function(e){return t(e.labelHost).y})).attr("fill","#EEEEEE"),x.attr("width",(function(e){return t(e.labelNode).width+4})).attr("height",(function(e){return t(e.labelNode).height})).attr("x",(function(e){return t(e.labelNode).x-2})).attr("y",(function(e){return t(e.labelNode).y})).attr("fill","#EEEEEE")}),100),f.needsToRestart=!1,f.updating=!1}}}}}])}}]);
//# sourceMappingURL=8.40e2c91636ed46607383.bundle.js.map