dagDependencies.478426a72ac265caf37d.js 3.4 KB

12
  1. /*! For license information please see dagDependencies.478426a72ac265caf37d.js.LICENSE.txt */
  2. !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Airflow=t():(e.Airflow=e.Airflow||{},e.Airflow.dagDependencies=t())}(self,(()=>(()=>{const e="#000000",t="#2020A0",s="#0000FF",l="3px",n="5px",o=500;let r=dagNodes;const d=r,a=r.filter((e=>edges.some((t=>t.u===e.id||t.v===e.id))));let c=(new dagreD3.graphlib.Graph).setGraph({nodesep:15,ranksep:15,rankdir:arrange}).setDefaultEdgeLabel((()=>({lineInterpolate:"basis"})));const i=dagreD3.render(),g=d3.select("#graph-svg"),h=d3.select("#graph-svg g");function u(e,t,s){e.forEach((e=>{const l=c.node(e).elem;d3.select(l).selectAll("rect,circle").style("stroke",t).style("stroke-width",s)}))}let p=null;d3.select("#searchbox").on("keyup",(()=>{!function(e){let t=null;if(d3.selectAll("g.nodes g.node").filter((function(s){var r;return""===e?(d3.select("g.edgePaths").transition().duration(o).style("opacity",1),d3.select(this).transition().duration(o).style("opacity",1).selectAll("rect").style("stroke-width",l)):(d3.select("g.edgePaths").transition().duration(o).style("opacity",.2),r=e,s.indexOf(r)>-1?(t||(t=this),d3.select(this).transition().duration(o).style("opacity",1).selectAll("rect").style("stroke-width",n)):d3.select(this).transition().style("opacity",.2).duration(o).selectAll("rect").style("stroke-width",l)),null})),t){const e=d3.transform(d3.select(t).attr("transform")),s=g.node().getBoundingClientRect();e.translate=[s.width/2-e.translate[0],s.height/2-e.translate[1]],e.scale=[1,1],null!==p&&(p.translate(e.translate),p.scale(1),p.event(h))}}(document.getElementById("searchbox").value)}));const f=()=>{c=(new dagreD3.graphlib.Graph).setGraph({nodesep:15,ranksep:15,rankdir:arrange}).setDefaultEdgeLabel((()=>({lineInterpolate:"basis"}))),r.forEach((e=>{c.setNode(e.id,e.value)}));edges.filter((e=>2===r.filter((t=>t.id===e.u||t.id===e.v)).length)).forEach((e=>{c.setEdge(e.u,e.v,{curve:d3.curveBasis,arrowheadClass:"arrowhead"})})),h.call(i,c),function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;d3.selectAll("g.node").on("mouseover",(function(l){d3.select(this).selectAll("rect").style("stroke",e),u(c.predecessors(l),t,n),u(c.successors(l),s,n);const o=[l,...c.predecessors(l),...c.successors(l)];d3.selectAll("g.nodes g.node").filter((e=>!o.includes(e))).style("opacity",.2);const r=c.nodeEdges(l);d3.selectAll("g.edgePath")[0].filter((e=>!r.includes(e.__data__))).forEach((e=>{d3.select(e).style("opacity",.2)}))})),d3.selectAll("g.node").on("mouseout",(function(e){d3.select(this).selectAll("rect,circle").style("stroke",null),u(c.predecessors(e),null,l),u(c.successors(e),null,l),d3.selectAll("g.node").style("opacity",1),d3.selectAll("g.node rect").style("stroke-width",l),d3.selectAll("g.edgePath").style("opacity",1),o&&localStorage.removeItem(o)}))}(),function(){p=d3.behavior.zoom().on("zoom",(()=>{h.attr("transform",`translate(${d3.event.translate})scale(${d3.event.scale})`)})),g.call(p);const e=c.graph().width,t=c.graph().height,s=g.node().getBoundingClientRect(),l=s.width-40,n=s.height-20,o=Math.min(Math.min(l/e,n/t),1.5);p.translate([l/2-e*o/2+20,20]),p.scale(o),p.event(h)}()};return document.getElementById("deps-filter").addEventListener("change",(function(){document.getElementById("searchbox").value="",r=this.checked?a:d,f()})),document.getElementById("deps-filter").checked&&(r=a),f(),{}})()));