UNPKG

graphdb-workbench

Version:
2 lines 16.8 kB
export const __webpack_id__=94519;export const __webpack_ids__=[48184,48581,53174,57952,70962,94519];export const __webpack_modules__={48184:(t,e,n)=>{n.r(e),n.d(e,{NodeState:()=>s});const s={LEADER:"LEADER",FOLLOWER:"FOLLOWER",CANDIDATE:"CANDIDATE",OUT_OF_SYNC_BLANK:"OUT_OF_SYNC_BLANK"}},53174:(t,e,n)=>{n.r(e),n.d(e,{CLUSTER_MANAGEMENT_CONSTANTS:()=>o});var s=n(48184),a=n(70962);const o={getLegendNodes:function(){const t=[];return t.push({nodeState:s.NodeState.LEADER,customText:"node_state_leader"}),t.push({nodeState:s.NodeState.FOLLOWER,customText:"node_state_follower"}),t.push({nodeState:s.NodeState.OUT_OF_SYNC_BLANK,customText:"node_state_out_of_sync"}),t.forEach((t,e)=>t.id=e),t},getSyncStatuses:()=>[{labelKey:"node_state_candidate",classes:"icon-any",icon:""},{labelKey:"node_state_no_cluster",classes:"close",icon:"X"},{labelKey:"link_state_out_of_sync",classes:"icon-any",icon:""},{labelKey:"node_state_no_connection",classes:"icon-any",icon:""},{labelKey:"node_state_read_only",classes:"icon-any",icon:""},{labelKey:"node_state_restricted",classes:"icon-any",icon:""},{labelKey:"recovery_state.searching_for_node",classes:"fa-d3",icon:""},{labelKey:"recovery_state.waiting_for_snapshot",classes:"fa-d3",icon:""},{labelKey:"recovery_state.building_snapshot",classes:"fa-d3 fa-solid",icon:""},{labelKey:"recovery_state.sending_snapshot",classes:"fa-d3 fa-solid",icon:""},{labelKey:"recovery_state.receiving_snapshot",classes:"fa-d3 fa-solid",icon:""},{labelKey:"recovery_state.applying_snapshot",classes:"fa-d3 fa-solid",icon:""}],getLegendLinks:function(){const t=[];return t.push({status:a.LinkState.IN_SYNC,linkTypeKey:"link_state_in_sync"}),t.push({status:a.LinkState.SYNCING,linkTypeKey:"link_state_syncing"}),t.push({status:a.LinkState.OUT_OF_SYNC,linkTypeKey:"link_state_out_of_sync"}),t.push({status:a.LinkState.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_COLOR:"#000000",TITLE_LINE_HEIGHT:18,LEGEND_ITEM_FONT_SIZE:11,LEGEND_ITEM_ICON_FONT_SIZE:15,LEGEND_ITEM_FONT_WEIGHT:400,LEGEND_ITEM_COLOR:"#000000",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.r(e),n.d(e,{ARROW_CONFIG:()=>y,addArrowHead:()=>G,createClusterSvgElement:()=>l,createClusterZone:()=>T,createHexagon:()=>m,createLinks:()=>h,createNodes:()=>O,moveElement:()=>u,positionNodesOnClusterZone:()=>R,removeEventListeners:()=>x,setArrowLink:()=>f,setCreateClusterZone:()=>d,setLinkColor:()=>M,setLinkStyle:()=>D,updateClusterZoneLabels:()=>S,updateLinks:()=>p,updateNodes:()=>A});var s=n(70962),a=n(98980),o=n(93462);const r={line:o.line,select:o.select},N={ontoOrange:"var(--gw-primary-base)",ontoBlue:"var(--gw-secondary-base)",ontoGreen:"var(--gw-tertiary-base)",ontoGrey:"var(--gw-neutral-base)"},_={[s.LinkState.IN_SYNC]:N.ontoBlue,[s.LinkState.SYNCING]:N.ontoBlue,[s.LinkState.OUT_OF_SYNC]:N.ontoGrey,[s.LinkState.RECEIVING_SNAPSHOT]:N.ontoBlue},E={[s.LinkState.IN_SYNC]:"none",[s.LinkState.SYNCING]:"10 10",[s.LinkState.OUT_OF_SYNC]:"10 10",[s.LinkState.RECEIVING_SNAPSHOT]:"10 10"},c={FONT_AWESOME:"FONT_AWESOME",ICOMOON:"ICOMOON"},i=40;function l(t){return r.select(t).append("svg").classed("cluster-diagram",!0)}function T(t){const e=t.append("g");return e.append("circle").classed("cluster-zone",!0).style("fill","transparent").style("stroke-width","4"),e}function d(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",N.ontoOrange).style("text-anchor","middle").classed("settings-icon",!0).text("")}}function S(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 u(t,e,n){t.attr("transform",()=>`translate(${e}, ${n})`)}function O(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 m(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 A(t){!function(t){t.select(".node-icon").each(function(t){const e=(n=t,(0,a.isEmpty)(n.recoveryStatus)?function(t){return I[t.nodeState]||{icon:"",font:""}}(t):function(t){const e=t.recoveryStatus;return e&&e.state&&L[e.state]||{icon:"",font:""}}(t));var n;r.select(this).classed("icon-any",e.font===c.ICOMOON).classed("fa-d3",e.font===c.FONT_AWESOME).text(e.icon)})}(t),function(t){t.select(".node.member").classed("leader",t=>t.nodeState===s.NodeState.LEADER).classed("follower",t=>t.nodeState===s.NodeState.FOLLOWER).classed("candidate",t=>t.nodeState===s.NodeState.CANDIDATE).classed("other",t=>t.nodeState!==s.NodeState.LEADER&&t.nodeState!==s.NodeState.FOLLOWER&&t.nodeState!==s.NodeState.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 r.select(t.labelNode).node().getBBox().width+10}).attr("height",function(t){return r.select(t.labelNode).node().getBBox().height+10}).attr("x",function(t){return r.select(t.labelNode).node().getBBox().x-5}).attr("y",function(t){return r.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=C(t));const o=g(s);return e=o.height,n=o.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 C(t)}),t.select(".node-info-text").remove(),function(t){t.select(".node-info-fo").each(function(t){const e=r.select(this);if((0,a.isEmpty)(t.recoveryStatus))return void e.attr("width",0);const n=C(t),s=t.recoveryStatus.message&&t.recoveryStatus.message.length>i&&n!==t.recoveryStatus.message,o=s?n:t.recoveryStatus.message,N=g(n),_=g(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,N,o,_),e.attr("width",N.width).attr("height",N.height).attr("x",-N.width/2).html(`<div>${o}</div>`)})}(t)}(t)}const L={[s.RecoveryState.SEARCHING_FOR_NODE]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.WAITING_FOR_SNAPSHOT]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.RECEIVING_SNAPSHOT]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.APPLYING_SNAPSHOT]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.BUILDING_SNAPSHOT]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.SENDING_SNAPSHOT]:{icon:"",font:c.FONT_AWESOME},[s.RecoveryState.RECOVERY_OPERATION_FAILURE_WARNING]:{icon:"",font:c.ICOMOON}},I={[s.NodeState.CANDIDATE]:{icon:"",font:c.ICOMOON},[s.NodeState.NO_CONNECTION]:{icon:"",font:c.ICOMOON},[s.NodeState.OUT_OF_SYNC]:{icon:"",font:c.ICOMOON},[s.NodeState.READ_ONLY]:{icon:"",font:c.ICOMOON},[s.NodeState.RESTRICTED]:{icon:"",font:c.ICOMOON}};function C(t){return t.recoveryStatus.message&&t.recoveryStatus.message.length>i?t.recoveryStatus.message.substring(0,i)+"...":t.recoveryStatus.message||""}function g(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 h(t){t.enter().append("path").classed("link",!0),t.exit().remove()}function p(t,e){t.attr("class",t=>`link ${t.id.replaceAll(":","-")}`).attr("stroke",M).style("stroke-dasharray",D).style("marker-mid",t=>f(t,y.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,o=s.y-n.y,r=Math.sqrt(a*a+o*o),N=a/r,_=o/r,E=n.x+55*N,c=n.y+55*_,i=s.x-55*N,l=s.y-55*_;return"M"+E+","+c+"L"+(E+i)/2+","+(c+l)/2+"L"+i+","+l}(t,e))}const y={SMALL:{name:"small",size:3},BIG:{name:"big",size:5}};function G(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 f(t,e){if(t.status===s.LinkState.RECEIVING_SNAPSHOT)return`url(#arrowhead_${e.name})`}function M(t){return _[t.status]||"none"}function D(t){return E[t.status]||"none"}function R(t,e,n,s){t.attr("transform",(a,o)=>{const r=2*Math.PI*o/t.size(),N=e+Math.cos(r)*s,_=n+Math.sin(r)*s;return a.x=N,a.y=_,`translate(${N}, ${_})`})}function m(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]];return t.selectAll("path.area").data([s]).enter().append("path").attr("class","node member").attr("stroke-width","10").attr("stroke-linejoin","round").attr("d",r.line())}function x(){r.select(document).selectAll(".node-info-fo").on(".tooltip",null)}},70962:(t,e,n)=>{n.r(e),n.d(e,{LinkState:()=>o,NodeState:()=>s,RecoveryState:()=>a,TopologyState:()=>r});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"},o={IN_SYNC:"IN_SYNC",OUT_OF_SYNC:"OUT_OF_SYNC",SYNCING:"SYNCING",NO_CONNECTION:"NO_CONNECTION",RECEIVING_SNAPSHOT:"RECEIVING_SNAPSHOT"},r={PRIMARY_NODE:"PRIMARY_NODE",SECONDARY_NODE:"SECONDARY_NODE"}},94519:(t,e,n)=>{n.r(e);var s=n(53174),a=n(57952),o=n(70962);const r={select:n(93462).select};function N(t,e,n,N){return{restrict:"E",templateUrl:"js/angular/clustermanagement/templates/cluster-legend.html",scope:{},link:_=>{_.hideLegend=!0;const E=[];let c,i,l;_.toggleLegend=()=>{_.hideLegend=!_.hideLegend,c.classed("hidden-legend",_.hideLegend)};const T=()=>{const t=e.getClusterViewD3Container();O(t),A(),d(c),S(),u(),L(),I()},d=t=>{g(t,"cluster_management.cluster_graphical_view.legend_title_node_state");const e=t.selectAll(".node-group").data(s.CLUSTER_MANAGEMENT_CONSTANTS.getLegendNodes()),n=a.createNodes(e,s.CLUSTER_MANAGEMENT_CONSTANTS.SVG_NODE_WIDTH,!0);a.updateNodes(n),n.attr("transform",function(t,e){return L(),`translate(${s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_LEFT}, ${i+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_TOP})`}).append("text").classed("links-statuses",!0).style("font-weight",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_WEIGHT).style("fill",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_COLOR).attr("x",s.CLUSTER_MANAGEMENT_CONSTANTS.PADDING_LEFT+s.CLUSTER_MANAGEMENT_CONSTANTS.SVG_NODE_WIDTH).attr("y",3).text(function(t){return h(this,"cluster_management.cluster_graphical_view."+t.customText)})},S=()=>{g(c,"cluster_management.cluster_graphical_view.legend_title_sync_status");const t=c.selectAll(".sync-statuses-group").data(s.CLUSTER_MANAGEMENT_CONSTANTS.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.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_LEFT-10).attr("y",function(t,n){const a=n*(20+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_TOP)+i+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEMS_PADDING_TOP;return e.set(n,a),a}).text(function(t){return t.icon});const n=(s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_ICON_FONT_SIZE-s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_SIZE)/2;t.append("text").style("font-weight",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_WEIGHT).style("fill",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_COLOR).text(function(t){return h(this,"cluster_management.cluster_graphical_view."+t.labelKey)}).attr("x",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_LEFT+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_SIZE).attr("y",function(t,s){return e.get(s)-n}).classed("links-statuses",!0)},u=()=>{g(c,"cluster_management.cluster_graphical_view.legend_title_link_states");const t=c.selectAll(".link-states-group").data(s.CLUSTER_MANAGEMENT_CONSTANTS.getLegendLinks()).enter().append("g").attr("class","link-state"),e=new Map;t.append("path").classed("link",!0).attr("stroke-dasharray",a.setLinkStyle).attr("stroke",a.setLinkColor).attr("d",(t,n)=>{const a=n*(s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_SIZE+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_TOP)+i+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEMS_PADDING_TOP,r=l/2;let N;if(e.set(n,a),t.status===o.LinkState.RECEIVING_SNAPSHOT){const t=r/2;N=`M${s.CLUSTER_MANAGEMENT_CONSTANTS.PADDING_LEFT} ${a} L${t} ${a} L${r} ${a}`}else N=`M${s.CLUSTER_MANAGEMENT_CONSTANTS.PADDING_LEFT} ${a} ${r} ${a}`;return N}).style("marker-mid",t=>a.setArrowLink(t,a.ARROW_CONFIG.SMALL)),t.append("text").style("font-size",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_SIZE).style("line-height",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_LINE_HEIGHT).style("font-weight",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_FONT_WEIGHT).style("fill",s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_COLOR).text(function(t){return h(this,"cluster_management.cluster_graphical_view."+t.linkTypeKey)}).attr("x",l/2+s.CLUSTER_MANAGEMENT_CONSTANTS.LEGEND_ITEM_PADDING_LEFT).attr("y",function(t,n){return e.get(n)+4}).classed("links-statuses",!0)},O=t=>{c=t.append("g").classed("hidden-legend",_.hideLegend).classed("cluster-legend-group",!0)},A=()=>{c.append("rect").attr("class","legend-background").attr("fill","#EEEEEE")},L=()=>{c.call(t=>{i=t.node().getBBox().height}),l=C(c)+30},I=()=>{const t=C(c);c.select(".legend-background").attr("height",i+3*s.CLUSTER_MANAGEMENT_CONSTANTS.PADDING_TOP).attr("width",t+s.CLUSTER_MANAGEMENT_CONSTANTS.BACKGROUND_PADDING).attr("rx","6")},C=t=>{let e=0;return t.selectAll(":not(.legend-background)").each(function(){const t=this.getBBox();e=Math.max(e,t.width)}),e},g=(t,e)=>t.append("text").attr("class","legend-title").attr("x",s.CLUSTER_MANAGEMENT_CONSTANTS.PADDING_LEFT).style("font-size",s.CLUSTER_MANAGEMENT_CONSTANTS.TITLE_FONT_SIZE).style("font-weight",s.CLUSTER_MANAGEMENT_CONSTANTS.TITLE_FONT_WEIGHT).style("line-height",s.CLUSTER_MANAGEMENT_CONSTANTS.TITLE_LINE_HEIGHT).style("fill",s.CLUSTER_MANAGEMENT_CONSTANTS.TITLE_COLOR).text(function(){return h(this,e)}).attr("y",()=>(L(),i+s.CLUSTER_MANAGEMENT_CONSTANTS.TITLE_PADDING_TOP)),h=(e,s)=>(E.push(t.$on("$translateChangeSuccess",()=>{r.select(e).text(n.instant(s)),I()})),n.instant(s)),p=()=>{_.hideLegend=!0,c.classed("hidden-legend",_.hideLegend)};N.on("keydown",t=>{"Escape"===t.key&&p()}),E.push(e.onClusterViewD3ContainerUpdated(T)),_.$on("$destroy",()=>{N.off("keydown",p),E.forEach(t=>t())}),T()}}}angular.module("graphdb.framework.clustermanagement.directives.cluster-legend",[]).directive("clusterLegend",N),N.$inject=["$rootScope","ClusterViewContextService","$translate","$document"]}}; //# sourceMappingURL=94519.1eca0d127ca5ee0a88a1.bundle.js.map