91 lines
21 KiB
JavaScript
91 lines
21 KiB
JavaScript
import{c4 as ee,bI as de,bH as fe,c5 as ke,bE as Ie,bF as Me,c6 as Ee,c7 as we,g as Ne,r as j,_ as Ce,W as Ae,b1 as De,k as Le,m as Fe,n as D,t as q,az as ze,E as $e,F as Oe,p as K,J as _e,ak as Be,l as X,c8 as Pe}from"./vendor/index.CRpmXtWV.js";import{d as Te,R as ie,p as Re,_ as We}from"../index.D-NvtsOM.js";import{l as Ge,s as He}from"./neInfo.DNMxf4Rh.js";const{labelPropagation:gt,louvain:Ve,findShortestPath:ht}=we,{uniqueId:W}=ee,Ue="degree",Ze=12;let ue=Ze;const pe=30,je=56,qe=40;let v=null,F={nodes:[],edges:[]},P={},E={},te=[],O={},k,Y,N={type:"",instance:null,destroyed:!0},x=[],M=[],z=800,$=800;const G=2e3,H=.6,ge=.1,he=.1,V=.2,Ke="rgb(43, 47, 51)",Xe="#777",Ye="dark",Je=["#5F95FF","#61DDAA","#65789B","#F6BD16","#7262FD","#78D3F8","#9661BC","#F6903D","#008685","#F08BB4"],A=ee.getColorSetsBySubjectColors(Je,Ke,Ye,Xe),C={node:{style:{fill:"#2B384E"},labelCfg:{style:{fill:"#acaeaf",stroke:"#191b1c"}},stateStyles:{focus:{fill:"#2B384E"}}},edge:{style:{stroke:"#acaeaf",realEdgeStroke:"#acaeaf",realEdgeOpacity:V,strokeOpacity:V},labelCfg:{style:{fill:"#acaeaf",realEdgeStroke:"#acaeaf",realEdgeOpacity:.5,stroke:"#191b1c"}},stateStyles:{focus:{stroke:"#fff"}}}};de("aggregated-node",{draw(e,t){let o=53,a=27;const n=e.style||{},l=e.colorSet||A[0];t.addShape("rect",{attrs:{x:-o*.55,y:-a*.6,width:o*1.1,height:a*1.2,fill:l.mainFill,opacity:.9,lineWidth:0,radius:a/2*1.2},name:"halo-shape",visible:!1}),t.addShape("rect",{attrs:{x:-o*.55,y:-a*.6,width:o*1.1,height:a*1.2,fill:l.mainFill,stroke:"#AAB7C4",lineWidth:1,lineOpacty:.85,radius:a/2*1.2},name:"stroke-shape",visible:!1});const c=t.addShape("rect",{attrs:{x:-o/2,y:-a/2,width:o,height:a,fill:l.mainFill,stroke:l.mainStroke,lineWidth:2,cursor:"pointer",radius:a/2,lineDash:[2,2],...n},name:"aggregated-node-keyShape"});let u={};return e.labelCfg&&(u=Object.assign(u,e.labelCfg.style)),t.addShape("text",{attrs:{text:`${e.count}`,x:0,y:0,textAlign:"center",textBaseline:"middle",cursor:"pointer",fontSize:12,fill:"#fff",opacity:.85,fontWeight:400},name:"count-shape",className:"count-shape",draggable:!0}),c},setState:(e,t,o)=>{const a=o.get("group");if(e==="layoutEnd"&&t){const n=a.find(l=>l.get("name")==="text-shape");n&&n.set("visible",!0)}else if(e==="hover"){if(o.hasState("focus"))return;const n=a.find(u=>u.get("name")==="halo-shape"),l=o.getKeyShape(),c=o.getModel().colorSet||A[0];t?(n&&n.show(),l.attr("fill",c.activeFill)):(n&&n.hide(),l.attr("fill",c.mainFill))}else if(e==="focus"){const n=a.find(u=>u.get("name")==="stroke-shape"),l=o.getKeyShape(),c=o.getModel().colorSet||A[0];t?(n&&n.show(),l.attr("fill",c.selectedFill)):(n&&n.hide(),l.attr("fill",c.mainFill))}},update:void 0},"single-node");de("real-node",{draw(e,t){let o=30;typeof e.size=="number"?o=e.size/2:Array.isArray(e.size)&&(o=e.size[0]/2);const a=e.style||{},n=e.colorSet||A[0];t.addShape("circle",{attrs:{x:0,y:0,r:o+5,fill:a.fill||n.mainFill||"#2B384E",opacity:.9,lineWidth:0},name:"halo-shape",visible:!1}),t.addShape("circle",{attrs:{x:0,y:0,r:o+5,fill:a.fill||n.mainFill||"#2B384E",stroke:"#fff",strokeOpacity:.85,lineWidth:1},name:"stroke-shape",visible:!1});const l=t.addShape("circle",{attrs:{x:0,y:0,r:o,fill:n.mainFill,stroke:n.mainStroke,lineWidth:2,cursor:"pointer",...a},draggable:!0,name:"aggregated-node-keyShape"});if(e.info){const u=e.info.serverState.online;t.addShape("circle",{attrs:{x:o-3,y:-o+3,r:5,fill:u?"#6DD400":"red",lineWidth:.5,stroke:"#FFFFFF"},name:"ne-state"}).animate({r:5,opacity:.3},{duration:1e3,easing:"easeCubic",delay:0,repeat:!0})}if(e.label){const c=e.label;let u={textAlign:"center",textBaseLine:"alphabetic",cursor:"pointer",fontSize:8,fill:"#fff",opacity:.85,fontWeight:400},r=0;e.labelCfg&&(u=Object.assign(u,e.labelCfg.style),r+=e.labelCfg.offset||0),u.fontSize=u.fontSize<8?8:u.fontSize,t.addShape("text",{attrs:{text:c,x:0,y:o+r+15,...u},draggable:!0,name:"text-shape",className:"text-shape"})}return e.icon&&t.addShape("image",{attrs:{x:0,cursor:"pointer",...e.icon},draggable:!0,name:"icon-shape"}),l},setState:(e,t,o)=>{const a=o.get("group");if(e==="layoutEnd"&&t){const n=a.find(l=>l.get("name")==="text-shape");n&&n.set("visible",!0)}else if(e==="neState"){const n=a.find(l=>l.get("name")==="ne-state");t?n.attr("fill","#52c41a"):n.attr("fill","#f5222d")}else if(e==="hover"){if(o.hasState("focus"))return;const n=a.find(u=>u.get("name")==="halo-shape"),l=o.getKeyShape(),c=o.getModel().colorSet||A[0];t?(n&&n.show(),l.attr("fill",c.activeFill)):(n&&n.hide(),l.attr("fill",c.mainFill))}else if(e==="focus"){const n=a.find(r=>r.get("name")==="stroke-shape"),l=a.find(r=>r.get("name")==="text-shape"),c=o.getKeyShape(),u=o.getModel().colorSet||A[0];t?(n&&n.show(),c.attr("fill",u.selectedFill),l&&l.attr("fontWeight",800)):(n&&n.hide(),c.attr("fill",u.mainFill),l&&l.attr("fontWeight",400))}},update:void 0},"aggregated-node");fe("custom-quadratic",{setState:(e,t,o)=>{const a=o.get("group"),n=o.getModel();if(e==="focus"){const l=a.find(r=>r.get("name")==="back-line");l&&(l.stopAnimate(),l.remove(),l.destroy());const c=a.find(r=>r.get("name")==="edge-shape"),u=n.style.endArrow;if(t)if(c.cfg.animation&&c.stopAnimate(!0),c.attr({strokeOpacity:H,opacity:H,stroke:"#fff",endArrow:{...u,stroke:"#fff",fill:"#fff"}}),n.isReal){const{lineWidth:r,path:h,endArrow:s,stroke:p}=c.attr();a.addShape("path",{attrs:{lineWidth:r,path:h,stroke:p,endArrow:s,opacity:ge},name:"back-line"}).toBack();const f=c.getTotalLength();c.animate(d=>{const m=d*f;return{lineDash:[m,f-m]}},{repeat:!0,duration:G})}else{let r=0;const h=c.attr("lineDash"),s=h[0]+h[1];c.animate(()=>(r++,r>s&&(r=0),{lineDash:h,lineDashOffset:-r}),{repeat:!0,duration:G})}else{c.stopAnimate();const r="#acaeaf",h=n.isReal?V:he;c.attr({stroke:r,strokeOpacity:h,opacity:h,endArrow:{...u,stroke:r,fill:r}})}}}},"quadratic");fe("custom-line",{setState:(e,t,o)=>{const a=o.get("group"),n=o.getModel();if(e==="focus"){const l=a.find(r=>r.get("name")==="edge-shape"),c=a.find(r=>r.get("name")==="back-line");c&&(c.stopAnimate(),c.remove(),c.destroy());const u=n.style.endArrow;if(t)if(l.cfg.animation&&l.stopAnimate(!0),l.attr({strokeOpacity:H,opacity:H,stroke:"#fff",endArrow:{...u,stroke:"#fff",fill:"#fff"}}),n.isReal){const{path:r,stroke:h,lineWidth:s}=l.attr();a.addShape("path",{attrs:{path:r,stroke:h,lineWidth:s,opacity:ge},name:"back-line"}).toBack();const g=l.getTotalLength();l.animate(f=>{const d=f*g;return{lineDash:[d,g-d]}},{repeat:!0,duration:G})}else{const r=l.attr("lineDash"),h=r[0]+r[1];let s=0;l.animate(()=>(s++,s>h&&(s=0),{lineDash:r,lineDashOffset:-s}),{repeat:!0,duration:G})}else{l.stopAnimate();const r="#acaeaf",h=n.isReal?V:he;l.attr({stroke:r,strokeOpacity:h,opacity:h,endArrow:{...u,stroke:r,fill:r}})}}}},"single-edge");const Qe=e=>function(t,o){const a=t[e];return o[e]-a},R=e=>{e&&(et(e),tt(e))},et=e=>{e.findAllByState("node","focus").forEach(o=>{e.setItemState(o,"focus",!1)})},tt=e=>{e.findAllByState("edge","focus").forEach(o=>{e.setItemState(o,"focus",!1)})},ot=(e,t=5,o="...")=>e?e.length>t?`${e.substr(0,t)}${o}`:e:"",st=(e,t=10)=>e&&e.split("").length>t?`${e.substr(0,t)}...`:e,ye=(e,t,o,a,n,l)=>{if(!e||e.length===0)return{};const c={};let u=-1/0;const r=.3,h=r*o,s=r*a;e.forEach(i=>{i.type=i.level===0?"real-node":"aggregated-node",i.isReal=i.level===0,i.label=ot(i.label,ue,"..."),i.degree=0,i.inDegree=0,i.outDegree=0,c[i.id]&&(console.warn("node exists already!",i.id),i.id=`${i.id}${Math.random()}`),c[i.id]=i,i.count>u&&(u=i.count);const y=O?O[i.id]:void 0;y?(i.x=y.x,i.y=y.y):k&&!i.x&&!i.y&&(i.x=k.x+30*Math.cos(Math.random()*Math.PI*2),i.y=k.y+30*Math.sin(Math.random()*Math.PI*2))});let p=-1/0,g=1/0;t.forEach(i=>{if(i.id?i.id.split("-")[0]!=="edge"&&(i.id=`edge-${i.id}`):i.id=W("edge"),!c[i.source]||!c[i.target]){console.warn("edge source target does not exist",i.source,i.target,i.id);return}const y=c[i.source],I=c[i.target];(!y||!I)&&console.warn("source or target is not defined!!!",i,y,I),y.degree++,I.degree++,y.outDegree++,I.inDegree++,i.count>p&&(p=i.count),i.count<g&&(g=i.count)}),e.sort(Qe(Ue));const f=e[0].degree||1,d=[];e.forEach((i,y)=>{const I=i.count/u,L=i.level===0;i.size=L?i.size||pe:je,i.isReal=L,i.labelCfg=i.labelCfg||{position:"bottom",offset:5,style:{fill:C.node.labelCfg.style.fill,fontSize:6+I*6||12,stroke:C.node.labelCfg.style.stroke,lineWidth:3}},i.degree||d.push(i)});const m=p-g,S=1,ve=12-S;return t.forEach(i=>{const y=c[i.target],I=(i.count-g)/m*ve+S||1;i.size=I;const L=Math.max(I/2+2,3),_=10,U=y.size+_;let Z=`M ${U},0 L ${U+_},-${L} L ${U+_},${L} Z`,Se=y.size/2+_;i.source===i.target&&(i.type="loop",Z=void 0);const b=c[i.source],B=y.isReal&&b.isReal;i.isReal=B;const oe=B?C.edge.style.realEdgeStroke:C.edge.style.stroke,be=B?C.edge.style.realEdgeOpacity:C.edge.style.strokeOpacity,se=Math.max(I,2),xe=B?void 0:[se,se];i.style={stroke:oe,strokeOpacity:be,cursor:"pointer",lineAppendWidth:Math.max(i.size||5,5),fillOpacity:1,lineDash:xe,endArrow:Z?{path:Z,d:Se,fill:oe,strokeOpacity:0}:!1},i.labelCfg={autoRotate:!0,style:{stroke:C.edge.labelCfg.style.stroke,fill:C.edge.labelCfg.style.fill,lineWidth:4,fontSize:12,lineAppendWidth:10,opacity:1}},i.oriLabel||(i.oriLabel=i.label),i.label="";const ae=b.size/2+20,ne=y.size/2+20;b.x&&!y.x&&(y.x=b.x+ae*Math.cos(Math.random()*Math.PI*2)),b.y&&!y.y&&(y.y=b.y+ae*Math.sin(Math.random()*Math.PI*2)),y.x&&!b.x&&(b.x=y.x+ne*Math.cos(Math.random()*Math.PI*2)),y.y&&!b.y&&(b.y=y.y+ne*Math.sin(Math.random()*Math.PI*2)),!b.x&&!b.y&&k&&(b.x=k.x+30*Math.cos(Math.random()*Math.PI*2),b.y=k.y+30*Math.sin(Math.random()*Math.PI*2)),!y.x&&!y.y&&k&&(y.x=k.x+30*Math.cos(Math.random()*Math.PI*2),y.y=k.y+30*Math.sin(Math.random()*Math.PI*2))}),Y={x:o-h,y:a-s},d.forEach(i=>{!i.x&&!i.y&&(i.x=Y.x+30*Math.cos(Math.random()*Math.PI*2),i.y=Y.y+30*Math.sin(Math.random()*Math.PI*2))}),ee.processParallelEdges(t,12.5,"custom-quadratic","custom-line"),{maxDegree:f,edges:t}},at=(e,t,o)=>{let{linkDistance:a,edgeStrength:n,nodeStrength:l,nodeSpacing:c,preventOverlap:u,nodeSize:r,collideStrength:h,alpha:s,alphaDecay:p,alphaMin:g}={preventOverlap:!0};!a&&a!==0&&(a=525),!n&&n!==0&&(n=50),!l&&l!==0&&(l=200),!c&&c!==0&&(c=5);const f={type:"gForce",minMovement:.01,maxIteration:5e3,preventOverlap:u,damping:.99,linkDistance:d=>{let m=a;const S=P[d.source]||E[d.source],w=P[d.target]||E[d.target];return!S?.level&&!w?.level&&(m=a*.3),m},edgeStrength:d=>{const m=P[d.source]||E[d.source],S=P[d.target]||E[d.target];return m?.level&&S?.level?n/2:(m?.level||S?.level,n)},nodeStrength:d=>d.degree===0?-10:d.level?l*2:l,nodeSize:d=>!r&&d.size?d.size:50,nodeSpacing:d=>d.degree===0?c*2:(d.level,c),onLayoutEnd:()=>{e.getEdges().forEach(d=>{d.oriLabel&&d.update({label:st(d.oriLabel,ue)})})},tick:()=>{e.refreshPositions()}};return r&&(f.nodeSize=r),h&&(f.collideStrength=h),s&&(f.alpha=s),p&&(f.alphaDecay=p),g&&(f.alphaMin=g),f},nt=e=>{te.forEach(t=>{e.hideItem(t)})},it=e=>{e.getNodes().forEach(t=>{t.isVisible()||e.showItem(t)}),e.getEdges().forEach(t=>{t.isVisible()||t.showItem(t)}),te=[]},re=(e,t,o,a,n,l)=>{if(!t||!e)return;R(e),e.getNodes().forEach(h=>{h.isVisible()||h.show()}),e.getEdges().forEach(h=>{h.isVisible()||h.show()});let c=[],u=[];return c=t.nodes,u=ye(c,t.edges||[],o,a).edges,e.changeData({nodes:c,edges:u}),nt(e),e.getNodes().forEach(h=>{h.toFront()}),N.instance.init({nodes:t.nodes,edges:u}),N.instance.minMovement=1e-4,N.instance.getMass=h=>O[h.id]?5:1,N.instance.execute(),{nodes:c,edges:u}},T=(e,t,o,a,n,l)=>{let c=[],u=[];const r={},h={};return n.forEach(s=>{r[s.id]=!0}),l.forEach(s=>{h[s.id]=!0}),e.clusters.forEach((s,p)=>{r[s.id]?(c=c.concat(s.nodes),a[s.id].expanded=!0):(c.push(a[s.id]),a[s.id].expanded=!1)}),t.edges.forEach(s=>{const p=r[o[s.source].clusterId],g=r[o[s.target].clusterId];if(p&&g)u.push(s);else if(p){const f=o[s.target].clusterId,d={source:s.source,target:f,id:W("edge"),label:""};u.push(d)}else if(g){const f=o[s.source].clusterId,d={target:s.target,source:f,id:W("edge"),label:""};u.push(d)}}),e.clusterEdges.forEach(s=>{r[s.source]||r[s.target]||u.push(s)}),{nodes:c,edges:u}},me=(e,t,o,a)=>{for(let n=0;n<o;n++){const l=t[n];if(!a[n]&&e.parentId===l.id){a[n]=!0,me(l,t,o,a);break}}},le=(e,t,o,a)=>{if(k={x:t.x,y:t.y},e>qe){const l={},c=a.length;me(t,a,c,l);let u=-1;for(let r=0;r<c;r++)if(!l[r]){u=r;break}if(u!==-1){let r=a[u];if(r.level===2){let g=!1;for(let f=0;f<c;f++){const d=a[f];if(d.parentId===r.id&&d.level===1){g=!0,r=d,a.splice(f,1);break}}g||a.splice(u,1)}else a.splice(u,1);const h=r.id.split("-");let s;for(let g=0;g<h.length-1;g++){const f=h[g];s?s=`${s}-${f}`:s=f}const p={id:s,parentId:r.id,level:r.level-1};o.push(p)}}const n={id:t.id,level:t.level,parentId:t.parentId};return a.push(n),v.get("canvas").setCursor("default"),{expandArray:a,collapseArray:o}},ce=e=>{const t={},o=e.length;for(let a=0;a<o;a++){const n=e[a].getModel();t[n.id]={x:n.x,y:n.y,level:n.level}}return t},Q=()=>{N.instance.stop()},rt=e=>{e.on("node:mouseenter",t=>{const{item:o}=t;e.setItemState(o,"hover",!0),o.toFront()}),e.on("node:mouseleave",t=>{const{item:o}=t;e.setItemState(o,"hover",!1)}),e.on("edge:mouseenter",t=>{const{item:o}=t,a=o.getModel(),n=a.label;o.update({label:a.oriLabel}),a.oriLabel=n,o.toFront(),o.getSource().toFront(),o.getTarget().toFront()}),e.on("edge:mouseleave",t=>{const{item:o}=t,a=o.getModel(),n=a.label;o.update({label:a.oriLabel}),a.oriLabel=n}),e.on("node:click",t=>{Q(),R(e);const{item:o}=t;e.setItemState(o,"focus",!0),o.getEdges().forEach(n=>{e.setItemState(n,"focus",!0)})}),e.on("edge:click",t=>{Q(),R(e);const{item:o}=t;e.setItemState(o,"focus",!0)}),e.on("canvas:click",t=>{R(e)})};function lt(e,t,o){if(!t)return;z=t.scrollWidth,$=(t.scrollHeight||500)-30;const a={},n=Ve(o,!1,"weight"),l={nodes:[],edges:[]};n.clusters.forEach((s,p)=>{s.nodes.forEach(f=>{const d=o.nodes.find(m=>m.id===f.id);f=Object.assign(f,d),f.level=0,f.type="",f.colorSet=A[p],a[f.id]=f});const g={id:s.id,type:"aggregated-node",count:s.nodes.length,level:1,label:s.id,colorSet:A[p],idx:p};E[s.id]=g,l.nodes.push(g)}),n.clusterEdges.forEach(s=>{const p={...s,size:Math.log(s.count),id:W("edge")};p.source===p.target?(p.type="loop",p.loopCfg={dist:20}):p.type="line",l.edges.push(p)}),F=l;const c=new ke({shouldBegin(s){return!!(s.target&&s.target.isCanvas&&s.target.isCanvas()||s.item)},getContent(s){const{item:p}=s;if(s.target&&s.target.isCanvas&&s.target.isCanvas())return`
|
||
<div
|
||
style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 140px;
|
||
"
|
||
>
|
||
<div id="show" style="cursor: pointer; margin-bottom: 2px">
|
||
1. ${e("views.monitor.topology.showAllHide")}
|
||
</div>
|
||
<div id="collapseAll" style="cursor: pointer; margin-bottom: 2px">
|
||
2. ${e("views.monitor.topology.collapseAll")}
|
||
</div>
|
||
</div>`;if(!p)return"";const g=p.getType(),f=p.getModel();return g&&f?g==="node"?f.level!==0?`
|
||
<div
|
||
style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 100px;
|
||
background: #e6f7ff;
|
||
"
|
||
>
|
||
<div id="expand" style="cursor: pointer; margin-bottom: 2px">
|
||
1. ${e("views.monitor.topology.expandAll")}
|
||
</div>
|
||
<div id="hide" style="cursor: pointer; margin-bottom: 2px">
|
||
2. ${e("views.monitor.topology.hideNode")}
|
||
</div>
|
||
</div>
|
||
`:`
|
||
<div
|
||
style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 160px;
|
||
background: #e6f7ff;
|
||
"
|
||
>
|
||
<div id="collapse" style="cursor: pointer; margin-bottom: 2px">
|
||
1. ${e("views.monitor.topology.foldAll")}
|
||
</div>
|
||
<div id="hide" style="cursor: pointer; margin-bottom: 2px">
|
||
2. ${e("views.monitor.topology.hideNode")}
|
||
</div>
|
||
</div>
|
||
`:`
|
||
<div
|
||
style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 100px;
|
||
background: #e6f7ff;
|
||
"
|
||
>
|
||
<div id="hide" style="cursor: pointer; margin-bottom: 2px">
|
||
1. ${e("views.monitor.topology.hideEdge")}
|
||
</div>
|
||
</div>
|
||
`:""},handleMenuClick:(s,p)=>{const g=p&&p.getModel(),f=s.id.split("-");let d;switch(f[0]){case"hide":v.hideItem(p),te.push(g.id);break;case"expand":const m=le(v.getNodes().length,g,M,x);x=m.expandArray,M=m.collapseArray,d=T(n,o,a,E,x,M);break;case"collapse":const S=E[g.clusterId];k={x:S.x,y:S.y},M.push(S);for(let w=0;w<x.length;w++)if(x[w].id===g.clusterId){x.splice(w,1);break}d=T(n,o,a,E,x,M);break;case"collapseAll":x=[],M=[],d=T(n,o,a,E,x,M);break;case"show":it(v);break}d&&(O=ce(v.getNodes()),F=d,re(v,F,z,$))},offsetX:26,offsetY:0,itemTypes:["node","edge","canvas"]}),u=new Ie({offsetX:20,offsetY:20,getContent(s){const p=s.item.getModel(),g=p.info;if(!g)return`<div><span>ID:</span><span>${p.id}</span></div>`;const f=g.serverState;return`
|
||
<div
|
||
style="
|
||
display: flex;
|
||
flex-direction: column;
|
||
width: 200px;
|
||
"
|
||
>
|
||
<div><strong>${e("views.monitor.topology.state")}:</strong><span>
|
||
${g.serverState.online?e("views.monitor.topology.normalcy"):e("views.monitor.topology.exceptions")}
|
||
</span></div>
|
||
<div><strong>${e("views.monitor.topology.refreshTime")}:</strong><span>
|
||
${f.refreshTime??"--"}
|
||
</span></div>
|
||
<div>========================</div>
|
||
<div><strong>ID:</strong><span>${f.neId}</span></div>
|
||
<div><strong>${e("views.monitor.topology.name")}:</strong><span>
|
||
${f.neName??"--"}
|
||
</span></div>
|
||
<div><strong>IP:</strong><span>${f.neIP}</span></div>
|
||
<div><strong>${e("views.monitor.topology.version")}:</strong><span>
|
||
${f.version??"--"}
|
||
</span></div>
|
||
<div><strong>${e("views.monitor.topology.serialNum")}:</strong><span>
|
||
${f.sn??"--"}
|
||
</span></div>
|
||
<div><strong>${e("views.monitor.topology.expiryDate")}:</strong><span>
|
||
${f.expire??"--"}
|
||
</span></div>
|
||
</div>
|
||
`},itemTypes:["node"]}),{edges:r}=ye(F.nodes,F.edges,z,$);v=new Me({container:t,width:t?.clientWidth,height:t?.clientHeight,linkCenter:!0,minZoom:.1,groupByTypes:!1,modes:{default:[{type:"drag-canvas",enableOptimize:!0},{type:"zoom-canvas",enableOptimize:!0,optimizeZoom:.01},"drag-node"],lassoSelect:[{type:"zoom-canvas",enableOptimize:!0,optimizeZoom:.01},{type:"lasso-select",selectedState:"focus",trigger:"drag"}],fisheyeMode:[]},defaultNode:{type:"aggregated-node",size:pe},plugins:[c,u]}),v.get("canvas").set("localRefresh",!1);const h=at(v);h.center=[z/2,$/2],N.instance=new Ee.Layouts.gForce(h),N.instance.init({nodes:l.nodes,edges:r}),N.instance.execute(),rt(v),v.data({nodes:l.nodes,edges:r}),v.render();for(const s of l.nodes){const p=le(v.getNodes().length,s,M,x);x=p.expandArray,M=p.collapseArray;let g=T(n,o,a,E,x,M);g&&(O=ce(v.getNodes()),re(v,g,z,$))}return v}let J=!1;function ct(){J=!J,J?(Q(),v.updateLayout({type:"grid",begin:[20,20]})):N.instance.execute()}const dt=Ne({__name:"index",setup(e){const{t}=Te(),o=j(void 0),a=j(null),n=Ce({nodes:[],edges:[]});function l(){o.value&&(a.value=lt(t,o.value,n))}const c=j(null);async function u(){for(const h of n.nodes){const s=h.info,p=await He(s.neType,s.neId);if(p.code===ie){s.serverState=p.data,s.serverState.refreshTime=Re(s.serverState.refreshTime,"HH:mm:ss");const g=a.value.findById(s.neName);a.value.setItemState(g,"neState",s.serverState.online)}}}function r(h=!1){Ge({bandStatus:!1}).then(s=>{if(s.code===ie&&Array.isArray(s.data)&&s.data.length>0){let p={neName:"OMC_001"};const g=[],f=[];for(const d of s.data)d.serverState={},g.findIndex(S=>S.id===d.neName)===-1&&(d.neType==="OMC"?g.unshift({id:d.neName,label:d.neName,info:d,labelCfg:{position:"bottom",offset:8,style:{fill:"#fff",fontSize:14}},size:60,icon:{x:-30,y:-30,img:"/svg/service_db.svg",width:60,height:60}}):g.push({id:d.neName,label:d.neName,info:d,size:48,icon:{x:-24,y:-24,img:"/svg/service.svg",width:48,height:48}})),d.neType!=="OMC"?f.findIndex(w=>w.source===d.neName)===-1&&f.push({source:d.neName,target:p.neName,label:`${d.neName}-${p.neName}`}):f.unshift({source:d.neName,target:p.neName,label:`${d.neName}-${p.neName}`});return n.nodes=g,n.edges=f,!0}else return X.message.warning({content:t("common.noData"),duration:2}),!1}).then(s=>{s&&(h&&a.value.destroy(),l(),u(),c.value=setInterval(()=>{u()},1e4))})}return Ae(()=>{r()}),De(()=>{clearInterval(c.value)}),(h,s)=>{const p=Pe,g=X.Button,f=X.Card;return Le(),Fe(K(Be),null,{default:D(()=>[q(f,{bordered:!1,"body-style":{marginBottom:"24px"},size:"small"},{title:D(()=>[]),extra:D(()=>[q(g,{type:"default",onClick:s[0]||(s[0]=ze(d=>K(ct)(),["prevent"]))},{icon:D(()=>[q(p)]),default:D(()=>[$e(" "+Oe(K(t)("views.monitor.topology.switchLayout")),1)]),_:1})]),default:D(()=>[_e("div",{ref_key:"graphG6Dom",ref:o,class:"chart"},null,512)]),_:1})]),_:1})}}}),yt=We(dt,[["__scopeId","data-v-4f8ad69d"]]);export{yt as default};
|