| Current Path : /snap/lxd/current/share/lxd-ui/assets/ |
| Current File : //snap/lxd/current/share/lxd-ui/assets/NetworkRichChip-Cp8QBNS_.js |
import{bK as y,j as t,z as j,L as b,d as w,bX as I,bA as L,w as k,R as d,a0 as f,cL as U,H as C,cM as $}from"./index-BsQN_SZU.js";import{b as S,u as P,j as _}from"./useNetworks-1j5RF-bH.js";const A=({network:s,project:i})=>{const{data:o}=S(s.name,i);if(o&&o.length>0){const l=o.filter(y).filter(n=>n!==void 0&&n.config&&n.config.parent).map(n=>n.config.parent);if(l.length===0)return"-";const e=[...new Set(l)];return e.length===1?e[0]:`${e.length} different parents`}return s?.config.parent||"-"},F=({networkName:s,projectName:i,networkUrl:o,clusterMember:l})=>{const{data:e,isLoading:n,error:c}=P(s,i,l),{data:a}=_(s,i,l,!n||!c);if(!e&&!n)return t.jsxs(t.Fragment,{children:["Network ",t.jsx(j,{type:"network",value:s,bold:!0})," not found"]});const v=e?.description||"-",g=e?.config["security.acls"]?.split(","),R=e?.config["ipv4.address"]||"-",x=e?.config["ipv6.address"]||"-",m=e?.config.vlan||"-",h=e?.config.mtu||"-",{counters:p}=a??{},r=[{title:"Network",value:e?t.jsx(b,{to:o,title:s,children:s}):t.jsx(w.Spinner,{}),valueTitle:s},{title:"Description",value:v,valueTitle:v},{title:"State",value:a?.state||"-"},{title:"Type",value:e?.type||"-"}];e?.managed&&(e?.type==="bridge"||e?.type==="ovn")?r.push({title:"IPV4",value:R},{title:"IPV6",value:x}):r.push({title:"Parent",value:e&&t.jsx(A,{network:e,project:i})},{title:"VLAN ID",value:m}),I.includes(e?.type??"")?r.push({title:"ACLs",value:t.jsx(L,{items:g?g.map(u=>t.jsx(k,{type:"network-acl",value:u,to:`${d}/ui/project/${encodeURIComponent(i)}/network-acl/${encodeURIComponent(u)}`},u)):[t.jsx(t.Fragment,{children:"-"})]})}):r.push({title:"MTU",value:h});const T=()=>e?{bridge:{title:"MTU",value:h},ovn:{title:"Uplink",value:e.config.network||"-"},macvlan:{title:"GVRP registration",value:e.config.gvrp||"-"},physical:{title:"OVN ingress",value:e.config["ovn.ingress_mode"]||"-"}}[e.type]||{title:"-",value:"-"}:{title:"-",value:"-"};return r.push(T()),r.push({title:"Statistics",value:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"general-field-label",children:["RX: ",f(p?.bytes_received??0)," (",p?.packets_received??0," packets)"]}),t.jsxs("div",{className:"general-field-label",children:["TX: ",f(p?.bytes_sent??0)," (",p?.packets_sent??0," packets)"]})]})}),r.push({title:"Used by",value:e?.used_by?.length||0}),t.jsx(U,{rows:r,className:"profile-rich-tooltip-table"})},V=({networkName:s,projectName:i,clusterMember:o,className:l,disabled:e})=>{const n=!C($,"height"),c=o?`${d}/ui/project/${encodeURIComponent(i)}/member/${encodeURIComponent(o)}/network/${encodeURIComponent(s)}`:`${d}/ui/project/${encodeURIComponent(i)}/network/${encodeURIComponent(s)}`,a=t.jsx(k,{type:"network",value:s,to:c,hasTitle:!n,className:l,disabled:e});return n?t.jsx(w.Tooltip,{zIndex:1e3,position:"right",message:t.jsx(F,{networkName:s,projectName:i,networkUrl:c,clusterMember:o}),children:a}):t.jsx(t.Fragment,{children:a})};export{V as N};