UNPKG

graphdb-workbench

Version:
2 lines 14.6 kB
export const __webpack_esm_id__=94519;export const __webpack_esm_ids__=[48184,48581,53174,57952,70962,94519];export const __webpack_esm_modules__={48184(t,e,n){n.d(e,{U:()=>s});const s={LEADER:"LEADER",FOLLOWER:"FOLLOWER",CANDIDATE:"CANDIDATE",OUT_OF_SYNC_BLANK:"OUT_OF_SYNC_BLANK"}},53174(t,e,n){n.d(e,{N:()=>r});var s=n(48184),a=n(70962);const r={getLegendNodes:function(){const t=[];return t.push({nodeState:s.U.LEADER,customText:"node_state_leader"}),t.push({nodeState:s.U.FOLLOWER,customText:"node_state_follower"}),t.push({nodeState:s.U.OUT_OF_SYNC_BLANK,customText:"node_state_out_of_sync"}),t.forEach((t,e)=>t.id=e),t},getSyncStatuses:()=>[{labelKey:"node_state_candidate",classes:"remixicon",icon:""},{labelKey:"node_state_no_cluster",classes:"remixicon",icon:""},{labelKey:"link_state_out_of_sync",classes:"remixicon",icon:""},{labelKey:"node_state_no_connection",classes:"remixicon",icon:""},{labelKey:"node_state_read_only",classes:"remixicon",icon:""},{labelKey:"node_state_restricted",classes:"remixicon",icon:""},{labelKey:"recovery_state.searching_for_node",classes:"remixicon",icon:""},{labelKey:"recovery_state.waiting_for_snapshot",classes:"remixicon",icon:""},{labelKey:"recovery_state.building_snapshot",classes:"remixicon",icon:""},{labelKey:"recovery_state.sending_snapshot",classes:"remixicon",icon:""},{labelKey:"recovery_state.receiving_snapshot",classes:"remixicon",icon:""},{labelKey:"recovery_state.applying_snapshot",classes:"remixicon",icon:""}],getLegendLinks:function(){const t=[];return t.push({status:a.gC.IN_SYNC,linkTypeKey:"link_state_in_sync"}),t.push({status:a.gC.SYNCING,linkTypeKey:"link_state_syncing"}),t.push({status:a.gC.OUT_OF_SYNC,linkTypeKey:"link_state_out_of_sync"}),t.push({status:a.gC.RECEIVING_SNAPSHOT,linkTypeKey:"link_state_receiving_snapshot"}),t.forEach((t,e)=>t.id=e),t},SVG_NODE_WIDTH:15,PADDING_LEFT:12,PADDING_TOP:12,TITLE_PADDING_TOP:15,TITLE_FONT_SIZE:13,TITLE_FONT_WEIGHT:700,TITLE_LINE_HEIGHT:18,LEGEND_ITEM_FONT_SIZE:11,LEGEND_ITEM_ICON_FONT_SIZE:15,LEGEND_ITEM_FONT_WEIGHT:400,LEGEND_ITEM_LINE_HEIGHT:13,LEGEND_ITEM_PADDING_LEFT:27,LEGEND_ITEMS_PADDING_TOP:40,LEGEND_ITEM_PADDING_TOP:8,BACKGROUND_PADDING:24}},57952(t,e,n){n.d(e,{$$:()=>f,CQ:()=>C,D6:()=>A,HF:()=>h,Iz:()=>m,J5:()=>N,Wg:()=>v,Xl:()=>u,ZC:()=>L,_D:()=>G,cZ:()=>g,cy:()=>D,dB:()=>E,kI:()=>T,r_:()=>I,ss:()=>x});var s=n(70962),a=n(98980),r=n(93462);const o={line:r.line,select:r.select},c="var(--gw-secondary-base)",i={[s.gC.IN_SYNC]:c,[s.gC.SYNCING]:c,[s.gC.OUT_OF_SYNC]:"var(--gw-neutral-base)",[s.gC.RECEIVING_SNAPSHOT]:c},l={[s.gC.IN_SYNC]:"none",[s.gC.SYNCING]:"10 10",[s.gC.OUT_OF_SYNC]:"10 10",[s.gC.RECEIVING_SNAPSHOT]:"10 10"},_="REMIXICON",d="ICOMOON";function N(t){return o.select(t).append("svg").classed("cluster-diagram",!0)}function E(t){const e=t.append("g");return e.append("circle").classed("cluster-zone",!0).style("fill","transparent").style("stroke-width","4"),e}function u(t,e,n,s=!1){if(e.select(".cluster-zone").classed("no-cluster",!t).classed("has-access",s),t)e.selectAll("#no-cluster-zone").remove();else{const t=e.append("g").attr("id","no-cluster-zone");t.append("text").attr("id","no-cluster-label").text(n.no_cluster_configured).attr("y",-50).classed("h2",!0).style("text-anchor","middle"),s&&t.append("text").attr("id","create-cluster-label").classed("h3",!0).text(n.create_cluster_btn).style("text-anchor","middle"),t.append("text").attr("y",130).attr("class","icon-any repo").attr("fill","var(--gw-primary-base)").style("text-anchor","middle").classed("settings-icon",!0).text("")}}function I(t,e,n){t||(e.select("#no-cluster-zone #no-cluster-label").text(n.no_cluster_configured),e.select("#no-cluster-zone #create-cluster-label").text(n.create_cluster_btn))}function g(t,e,n){t.attr("transform",()=>`translate(${e}, ${n})`)}function T(t,e,n){const s=t.enter().append("g").attr("id","node-group").classed("legend",n),a=s.merge(t).attr("id","node-group").classed("legend",n);return function(t,e){const n=Math.sqrt(3)/2,s=[[e+0,0],[e/2+0,e*n+0],[-e/2+0,e*n+0],[0-e,0],[-e/2+0,-e*n+0],[e/2+0,-e*n+0],[e+0,0],[e/2+0,e*n+0]];t.selectAll("path.area").data([s]).enter().append("path").attr("class","node member").attr("stroke-width","10").attr("stroke-linejoin","round").attr("d",o.line())}(s,e),t.exit().remove(),s.append("text").attr("class","icon-any node-icon"),n||function(t,e){const n=t.append("g");n.append("rect").attr("class","id-host-background").attr("rx",6),n.append("rect").attr("class","node-info-background").attr("rx",6),n.append("text").attr("y",e+25).attr("class","id id-host"),n.append("text").attr("y",e+55).attr("class","node-info-text")}(s,e),a}function h(t){!function(t){t.select(".node-icon").each(function(t){const e=(n=t,(0,a.isEmpty)(n.recoveryStatus)?function(t){return O[t.nodeState]||{icon:"",font:""}}(t):function(t){const e=t.recoveryStatus;return e&&e.state&&p[e.state]||{icon:"",font:""}}(t));var n;o.select(this).classed("icon-any",e.font===d).classed("remixicon",e.font===_).text(e.icon)})}(t),function(t){t.select(".node.member").classed("leader",t=>t.nodeState===s.UY.LEADER).classed("follower",t=>t.nodeState===s.UY.FOLLOWER).classed("candidate",t=>t.nodeState===s.UY.CANDIDATE).classed("other",t=>t.nodeState!==s.UY.LEADER&&t.nodeState!==s.UY.FOLLOWER&&t.nodeState!==s.UY.CANDIDATE)}(t),function(t){t.select(".id.id-host").each(function(t){t.labelNode=this}).text(function(t){return t.hostname}),t.select(".id-host-background").attr("width",function(t){return o.select(t.labelNode).node().getBBox().width+10}).attr("height",function(t){return o.select(t.labelNode).node().getBBox().height+10}).attr("x",function(t){return o.select(t.labelNode).node().getBBox().x-5}).attr("y",function(t){return o.select(t.labelNode).node().getBBox().y-5})}(t),function(t){let e,n;t.select(".node-info-text").each(function(t){t.infoNode=this}).select(function(){return this.parentNode}).append("foreignObject").attr("width",function(t){let s="";(0,a.isEmpty)(t.recoveryStatus)||(s=S(t));const r=y(s);return e=r.height,n=r.width,n}).attr("height",function(t){return e}).attr("x",function(t){return-n/2}).attr("y",function(t){return 78}).classed("hidden",function(t){return(0,a.isEmpty)(t.recoveryStatus)}).style("font-size","12px").style("font-weight","400").style("text-align","center").style("padding","4px").style("background","#EEEEEE").style("border-radius","6px").attr("class","node-info-fo").append("xhtml:div").html(function(t){return S(t)}),t.select(".node-info-text").remove(),function(t){t.select(".node-info-fo").each(function(t){const e=o.select(this);if((0,a.isEmpty)(t.recoveryStatus))return void e.attr("width",0);const n=S(t),s=t.recoveryStatus.message&&t.recoveryStatus.message.length>40&&n!==t.recoveryStatus.message,r=s?n:t.recoveryStatus.message,c=y(n),i=y(t.recoveryStatus.message);e.on(".tooltip",null),s&&function(t,e,n,s,a){t.on("mouseover.tooltip",()=>{t.attr("width",a.width).attr("height",a.height).attr("x",-a.width/2).html(`<div>${e}</div>`)}),t.on("mouseout.tooltip",()=>{t.attr("width",n.width).attr("height",n.height).attr("x",-n.width/2).html(`<div>${s}</div>`)})}(e,t.recoveryStatus.message,c,r,i),e.attr("width",c.width).attr("height",c.height).attr("x",-c.width/2).html(`<div>${r}</div>`)})}(t)}(t)}const p={[s.vQ.SEARCHING_FOR_NODE]:{icon:"",font:_},[s.vQ.WAITING_FOR_SNAPSHOT]:{icon:"",font:_},[s.vQ.RECEIVING_SNAPSHOT]:{icon:"",font:_},[s.vQ.APPLYING_SNAPSHOT]:{icon:"",font:_},[s.vQ.BUILDING_SNAPSHOT]:{icon:"",font:_},[s.vQ.SENDING_SNAPSHOT]:{icon:"",font:_},[s.vQ.RECOVERY_OPERATION_FAILURE_WARNING]:{icon:"",font:d}},O={[s.UY.CANDIDATE]:{icon:"",font:d},[s.UY.NO_CONNECTION]:{icon:"",font:d},[s.UY.OUT_OF_SYNC]:{icon:"",font:d},[s.UY.READ_ONLY]:{icon:"",font:d},[s.UY.RESTRICTED]:{icon:"",font:d}};function S(t){return t.recoveryStatus.message&&t.recoveryStatus.message.length>40?t.recoveryStatus.message.substring(0,40)+"...":t.recoveryStatus.message||""}function y(t){const e=document.createElement("div");e.innerHTML=t,e.style.padding="4px",e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize="12px",e.style.fontWeight="400",e.style.textAlign="center",e.style.height="auto",e.style.width="auto",e.style.whiteSpace="nowrap",document.body.appendChild(e);const n=e.getBoundingClientRect(),s=n.height,a=n.width;return document.body.removeChild(e),{height:s,width:a}}function D(t){t.enter().append("path").classed("link",!0),t.exit().remove()}function f(t,e){t.attr("class",t=>`link ${t.id.replaceAll(":","-")}`).attr("stroke",G).style("stroke-dasharray",C).style("marker-mid",t=>m(t,L.BIG)).attr("d",t=>function(t,e){const n=e.find(e=>e.address===t.source),s=e.find(e=>e.address===t.target),a=s.x-n.x,r=s.y-n.y,o=Math.sqrt(a*a+r*r),c=a/o,i=r/o,l=n.x+55*c,_=n.y+55*i,d=s.x-55*c,N=s.y-55*i;return"M"+l+","+_+"L"+(l+d)/2+","+(_+N)/2+"L"+d+","+N}(t,e))}const L={SMALL:{name:"small",size:3},BIG:{name:"big",size:5}};function A(t,e){t.append("svg:defs").append("svg:marker").attr("id",`arrowhead_${e.name}`).attr("viewBox",`0 0 ${2*e.size} ${2*e.size}`).attr("refX",e.size).attr("refY",e.size).attr("markerWidth",e.size).attr("markerHeight",e.size).attr("orient","auto-start-reverse").append("path").attr("d",`M 0 0 L ${2*e.size} ${e.size} L 0 ${2*e.size} z`).style("fill","var(--gw-secondary-base)")}function m(t,e){if(t.status===s.gC.RECEIVING_SNAPSHOT)return`url(#arrowhead_${e.name})`}function G(t){return i[t.status]||"none"}function C(t){return l[t.status]||"none"}function x(t,e,n,s){t.attr("transform",(a,r)=>{const o=2*Math.PI*r/t.size(),c=e+Math.cos(o)*s,i=n+Math.sin(o)*s;return a.x=c,a.y=i,`translate(${c}, ${i})`})}function v(){o.select(document).selectAll(".node-info-fo").on(".tooltip",null)}},70962(t,e,n){n.d(e,{UY:()=>s,gC:()=>r,vQ:()=>a,zB:()=>o});const s={LEADER:"LEADER",FOLLOWER:"FOLLOWER",CANDIDATE:"CANDIDATE",OUT_OF_SYNC:"OUT_OF_SYNC",NO_CONNECTION:"NO_CONNECTION",READ_ONLY:"READ_ONLY",RESTRICTED:"RESTRICTED",NO_CLUSTER:"NO_CLUSTER"},a={SEARCHING_FOR_NODE:"SEARCHING_FOR_NODE",WAITING_FOR_SNAPSHOT:"WAITING_FOR_SNAPSHOT",RECEIVING_SNAPSHOT:"RECEIVING_SNAPSHOT",APPLYING_SNAPSHOT:"APPLYING_SNAPSHOT",BUILDING_SNAPSHOT:"BUILDING_SNAPSHOT",SENDING_SNAPSHOT:"SENDING_SNAPSHOT",RECOVERY_OPERATION_FAILURE_WARNING:"RECOVERY_OPERATION_FAILURE_WARNING"},r={IN_SYNC:"IN_SYNC",OUT_OF_SYNC:"OUT_OF_SYNC",SYNCING:"SYNCING",NO_CONNECTION:"NO_CONNECTION",RECEIVING_SNAPSHOT:"RECEIVING_SNAPSHOT"},o={PRIMARY_NODE:"PRIMARY_NODE",SECONDARY_NODE:"SECONDARY_NODE"}},94519(t,e,n){var s=n(53174),a=n(57952),r=n(70962);const o={select:n(93462).select};function c(t,e,n,c){return{restrict:"E",templateUrl:"js/angular/clustermanagement/templates/cluster-legend.html",scope:{},link:i=>{i.hideLegend=!0;const l=[];let _,d,N;i.toggleLegend=()=>{i.hideLegend=!i.hideLegend,_.classed("hidden-legend",i.hideLegend)};const E=()=>{const t=e.getClusterViewD3Container();T(t),h(),u(_),I(),g(),p(),O()},u=t=>{y(t,"cluster_management.cluster_graphical_view.legend_title_node_state");const e=t.selectAll(".node-group").data(s.N.getLegendNodes()),n=a.kI(e,s.N.SVG_NODE_WIDTH,!0);a.HF(n),n.attr("transform",function(t,e){return p(),`translate(${s.N.LEGEND_ITEM_PADDING_LEFT}, ${d+s.N.LEGEND_ITEM_PADDING_TOP})`}).append("text").classed("links-statuses",!0).style("font-weight",s.N.LEGEND_ITEM_FONT_WEIGHT).attr("x",s.N.PADDING_LEFT+s.N.SVG_NODE_WIDTH).attr("y",3).text(function(t){return D(this,"cluster_management.cluster_graphical_view."+t.customText)})},I=()=>{y(_,"cluster_management.cluster_graphical_view.legend_title_sync_status");const t=_.selectAll(".sync-statuses-group").data(s.N.getSyncStatuses()).enter().append("g").attr("class","sync-statuses-group"),e=new Map;t.append("text").attr("class",t=>`sync-status ${t.classes}`).attr("x",s.N.LEGEND_ITEM_PADDING_LEFT-10).attr("y",function(t,n){const a=n*(20+s.N.LEGEND_ITEM_PADDING_TOP)+d+s.N.LEGEND_ITEMS_PADDING_TOP;return e.set(n,a),a}).text(function(t){return t.icon});const n=(s.N.LEGEND_ITEM_ICON_FONT_SIZE-s.N.LEGEND_ITEM_FONT_SIZE)/2;t.append("text").style("font-weight",s.N.LEGEND_ITEM_FONT_WEIGHT).text(function(t){return D(this,"cluster_management.cluster_graphical_view."+t.labelKey)}).attr("x",s.N.LEGEND_ITEM_PADDING_LEFT+s.N.LEGEND_ITEM_FONT_SIZE).attr("y",function(t,s){return e.get(s)-n}).classed("links-statuses",!0)},g=()=>{y(_,"cluster_management.cluster_graphical_view.legend_title_link_states");const t=_.selectAll(".link-states-group").data(s.N.getLegendLinks()).enter().append("g").attr("class","link-state"),e=new Map;t.append("path").classed("link",!0).attr("stroke-dasharray",a.CQ).attr("stroke",a._D).attr("d",(t,n)=>{const a=n*(s.N.LEGEND_ITEM_FONT_SIZE+s.N.LEGEND_ITEM_PADDING_TOP)+d+s.N.LEGEND_ITEMS_PADDING_TOP,o=N/2;let c;if(e.set(n,a),t.status===r.gC.RECEIVING_SNAPSHOT){const t=o/2;c=`M${s.N.PADDING_LEFT} ${a} L${t} ${a} L${o} ${a}`}else c=`M${s.N.PADDING_LEFT} ${a} ${o} ${a}`;return c}).style("marker-mid",t=>a.Iz(t,a.ZC.SMALL)),t.append("text").style("font-size",s.N.LEGEND_ITEM_FONT_SIZE).style("line-height",s.N.LEGEND_ITEM_LINE_HEIGHT).style("font-weight",s.N.LEGEND_ITEM_FONT_WEIGHT).text(function(t){return D(this,"cluster_management.cluster_graphical_view."+t.linkTypeKey)}).attr("x",N/2+s.N.LEGEND_ITEM_PADDING_LEFT).attr("y",function(t,n){return e.get(n)+4}).classed("links-statuses",!0)},T=t=>{_=t.append("g").classed("hidden-legend",i.hideLegend).classed("cluster-legend-group",!0)},h=()=>{_.append("rect").attr("class","legend-background")},p=()=>{_.call(t=>{d=t.node().getBBox().height}),N=S(_)+30},O=()=>{const t=S(_);_.select(".legend-background").attr("height",d+3*s.N.PADDING_TOP).attr("width",t+s.N.BACKGROUND_PADDING).attr("rx","6")},S=t=>{let e=0;return t.selectAll(":not(.legend-background)").each(function(){const t=this.getBBox();e=Math.max(e,t.width)}),e},y=(t,e)=>t.append("text").attr("class","legend-title").attr("x",s.N.PADDING_LEFT).style("font-size",s.N.TITLE_FONT_SIZE).style("font-weight",s.N.TITLE_FONT_WEIGHT).style("line-height",s.N.TITLE_LINE_HEIGHT).text(function(){return D(this,e)}).attr("y",()=>(p(),d+s.N.TITLE_PADDING_TOP)),D=(e,s)=>(l.push(t.$on("$translateChangeSuccess",()=>{o.select(e).text(n.instant(s)),O()})),n.instant(s)),f=()=>{i.hideLegend=!0,_.classed("hidden-legend",i.hideLegend)};c.on("keydown",t=>{"Escape"===t.key&&f()}),l.push(e.onClusterViewD3ContainerUpdated(E)),i.$on("$destroy",()=>{c.off("keydown",f),l.forEach(t=>t())}),E()}}}angular.module("graphdb.framework.clustermanagement.directives.cluster-legend",[]).directive("clusterLegend",c),c.$inject=["$rootScope","ClusterViewContextService","$translate","$document"]}}; //# sourceMappingURL=94519.b9aef2d0b976e4310de0.bundle.js.map