Your IP : 216.73.216.52


Current Path : /snap/lxd/38768/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/38768/share/lxd-ui/assets/NetworkListTable-ClJXyVRh.js

import{cc as g,j as e,cd as k,w as b,R,C,bg as T,ce as $,cb as F,d as w,bw as I,cf as K,bI as H,L as O}from"./index-BsQN_SZU.js";import{S as j}from"./StoragePoolRichChip-Daex_aZU.js";import{h as P}from"./useNetworks-1j5RF-bH.js";import{N as M}from"./NetworkRichChip-Cp8QBNS_.js";const S=({device:t,project:r,location:c})=>t.type==="disk"?g(t)?e.jsxs(e.Fragment,{children:["Pool"," ",e.jsx(j,{poolName:t.pool??"",projectName:r,location:c})]}):k(t)?t.source:e.jsxs(e.Fragment,{children:["Volume"," ",e.jsx(b,{type:"volume",value:t.source,to:`${R}/ui/project/${encodeURIComponent(r)}/storage/pool/${encodeURIComponent(t.pool??"")}/volumes/custom/${encodeURIComponent(t.source??"")}`})," ","on pool"," ",e.jsx(j,{poolName:t.pool??"",projectName:r,location:c})]}):t.type==="gpu"?e.jsx("span",{title:t.pci,className:"u-truncate",children:t.pci?`PCI  ${t.pci}`:`ID ${t.id}`}):t.type==="proxy"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{title:t.listen,className:"u-truncate",children:["Listen: ",t.listen]}),e.jsxs("div",{title:t.connect,className:"u-truncate",children:["Connect: ",t.connect]})]}):"-",_=({configBaseURL:t,devices:r,location:c})=>{const{project:u}=C(),p=(o,s)=>{const l=o[0].toLowerCase(),f=s[0].toLowerCase(),a=o[1].type,i=s[1].type;return a===i?l.localeCompare(f):a.localeCompare(i)},m=Object.entries(r??{}).filter(([o,s])=>s.type!=="nic"&&s.type!=="none").sort(p),d=m.length>0,y=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Type",sortKey:"type",className:"u-text--muted"},{content:"Details",className:"u-text--muted"}],h=m.map(([o,s])=>{let l=s.type;return T(s)&&(g(s)&&(l+=" (root)"),$(s)&&(l+=" (volume)"),k(s)&&(l+=" (host path)")),{key:o,columns:[{content:e.jsx(b,{type:"device",value:o,to:`${t}/${F(s)?"other":s.type}`}),role:"rowheader","aria-label":"Name"},{content:l,role:"cell","aria-label":"Type"},{content:e.jsx(S,{device:s,project:u,location:c}),role:"cell","aria-label":"Details"}],sortData:{name:o.toLowerCase(),type:s.type}}});return e.jsxs(e.Fragment,{children:[d&&e.jsx(w.MainTable,{headers:y,rows:h,className:"device-table",sortable:!0}),!d&&e.jsx(e.Fragment,{children:"-"})]})},z=({onFailure:t,devices:r,instance:c})=>{const{project:u}=C(),{data:p=[],error:m,isLoading:d}=P(u);m&&t("Loading networks failed",m);const y=Object.values(r??{}).filter(I),h=y.length>0,o=p.length>0,s=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Interface",sortKey:"interfaceName",className:"u-text--muted"},{content:"Type",sortKey:"type",className:"u-text--muted"},{content:"MAC address",sortKey:"macAddress",className:"u-text--muted u-hide--small u-hide--medium"},{content:"ACLs",sortKey:"acls",className:"u-text--muted u-hide--small u-hide--medium"}],l=Object.entries(r??{}).map(([a,i])=>{if(i.type!=="nic")return null;const n=p.find(x=>x.name===i.network||x.name===i.parent);if(!n)return null;const D=y.find(x=>x.network===n.name),L=K(D),A=H(n),N=new Set(L.concat(A)).size;return{key:n.name,columns:[{content:e.jsx(M,{networkName:n.name,projectName:u??""}),role:"rowheader","aria-label":"Name"},{content:a,role:"cell","aria-label":"Interface"},{content:e.jsxs(e.Fragment,{children:[n.type,e.jsxs("span",{className:"u-text--muted",children:[", ",n.managed?"managed":"unmanaged"]})]}),role:"cell","aria-label":"Type"},{content:c?.config?.[`volatile.${a}.hwaddr`]||"-",role:"cell","aria-label":"MAC address"},{content:N>0?e.jsx(O,{to:"configuration/network",children:N}):e.jsx(e.Fragment,{children:"-"}),role:"cell","aria-label":"ACLs count"}],sortData:{name:n.name.toLowerCase(),type:n.type+n.managed?"managed":"unmanaged",interfaceName:a.toLowerCase(),macAddress:c?.config?.[`volatile.${a}.hwaddr`]||"-"}}}).filter(a=>a!==null);return d?e.jsx(w.Spinner,{className:"u-loader",text:"Loading networks..."}):h&&!o?e.jsx(w.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to view network details."}):h?e.jsx(w.MainTable,{headers:s,rows:l,sortable:!0,className:"network-table"}):e.jsx(e.Fragment,{children:"-"})};export{_ as D,z as N};