%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/snap/lxd/29351/share/lxd-ui/assets/
Upload File :
Create Path :
Current File : //proc/self/root/snap/lxd/29351/share/lxd-ui/assets/NetworkDetail-c85f81d1.js

import{e as C,d as t,m as F,i as O,r as x,z as M,q as g,j as e,G as R,I as D,c as E,f as I,A as V,L as A,aE as q,X as $,aF as L,aA as K,C as w,b as H,ap as P}from"./index-13b2882d.js";import{u as G,d as Q,r as X,b as Y,e as W}from"./networks-5caac489.js";import{c as T,a as _,u as z}from"./index.esm-82c30f37.js";import{S as J,u as Z}from"./updateMaxHeight-325b3cd4.js";import{N as k,M as S,t as ee}from"./NetworkForm-ffe61c80.js";import{y as se,d as ie}from"./instanceValidation-45cfba9a.js";import{Y as ae}from"./ProfileFormMenu-3458e77a.js";import{R as ne}from"./RenameHeader-c74d9adb.js";import"./FormMenuItem-c8a1a121.js";import"./ConfigurationTable-1a9d4d6f.js";import"./ConfigFieldDescription-00c1a193.js";import"./settings-c23f9009.js";import"./AutoExpandingTextArea-3a779a81.js";import"./instanceConfigInheritance-fbf987f8.js";const N=s=>({readOnly:!0,isCreating:!1,name:s.name,description:s.description,type:s.type,bridge_driver:s.config["bridge.driver"],bridge_hwaddr:s.config["bridge.hwaddr"],bridge_mtu:s.config["bridge.mtu"],dns_domain:s.config["dns.domain"],dns_mode:s.config["dns.mode"],dns_search:s.config["dns.search"],ipv4_address:s.config["ipv4.address"],ipv4_dhcp:s.config["ipv4.dhcp"],ipv4_dhcp_expiry:s.config["ipv4.dhcp.expiry"],ipv4_dhcp_ranges:s.config["ipv4.dhcp.ranges"],ipv4_l3only:s.config["ipv4.l3only"],ipv4_nat:s.config["ipv4.nat"],ipv4_nat_address:s.config["ipv4.nat.address"],ipv4_ovn_ranges:s.config["ipv4.ovn.ranges"],ipv6_address:s.config["ipv6.address"],ipv6_dhcp:s.config["ipv6.dhcp"],ipv6_dhcp_expiry:s.config["ipv6.dhcp.expiry"],ipv6_dhcp_ranges:s.config["ipv6.dhcp.ranges"],ipv6_dhcp_stateful:s.config["ipv6.dhcp.stateful"],ipv6_l3only:s.config["ipv6.l3only"],ipv6_nat:s.config["ipv6.nat"],ipv6_nat_address:s.config["ipv6.nat.address"],ipv6_ovn_ranges:s.config["ipv6.ovn.ranges"],network:s.config.network}),te=["bridge.driver","bridge.hwaddr","bridge.mode","bridge.mtu","dns.domain","dns.mode","dns.search","fan.type","fan.overlay_subnet","fan.underlay_subnet","ipv4.address","ipv4.dhcp","ipv4.dhcp.expiry","ipv4.dhcp.ranges","ipv4.l3only","ipv4.nat","ipv4.nat.address","ipv4.ovn.ranges","ipv6.address","ipv6.dhcp","ipv6.dhcpexpiry","ipv6.dhcp.ranges","ipv6.dhcp.stateful","ipv6.l3only","ipv6.nat","ipv6.nat.address","ipv6.ovn.ranges","network"],re=({network:s,project:a})=>{const i=C(),r=t.useNotify(),{activeSection:d}=F(),m=O(),c=x.useState(null),l=T().shape({name:_().test("deduplicate","A network with this name already exists",o=>o===s.name||M(o,a,c,"networks")).required("Network name is required"),network:_().when("type",(o,h)=>o==="ovn"?h.required("Uplink network is required"):h)}),n=z({initialValues:N(s),validationSchema:l,onSubmit:o=>{const h=o.yaml?o.yaml:u(),j=se(h);G({...j,etag:s.etag},a).then(()=>{n.setValues(N(j)),m.invalidateQueries({queryKey:[g.projects,a,g.networks,s.name]}),r.success("Network updated.")}).catch(b=>{r.failure("Network update failed",b)}).finally(()=>n.setSubmitting(!1))}}),f=o=>{const h=ee(o),j=new Set(["used_by","etag","status","locations","managed","name","description","config","type"]),b=Object.fromEntries(Object.entries(s).filter(v=>!j.has(v[0]))),B=new Set(te),U=Object.fromEntries(Object.entries(s.config).filter(v=>!B.has(v[0])&&!v[0].startsWith("volatile")));return{...b,...h,config:{...h.config,...U}}},u=()=>ie(f(n.values)),p=o=>{n.values.yaml&&d!==ae&&n.setFieldValue("yaml",void 0);const h=`/ui/project/${a}/networks/detail/${s.name}/configuration`;i(o===S?h:`${h}/${R(o)}`)},y=n.values.readOnly;return e.jsxs(e.Fragment,{children:[e.jsx(k,{formik:n,getYaml:u,project:a,section:d??R(S),setSection:p}),e.jsxs("div",{className:"p-bottom-controls",children:[e.jsx("hr",{}),e.jsx(t.Row,{className:"u-align--right",children:e.jsx(t.Col,{size:12,children:y?e.jsx(t.Button,{appearance:"positive",onClick:()=>void n.setFieldValue("readOnly",!1),children:"Edit network"}):e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{appearance:"base",onClick:()=>n.setValues(N(s)),children:"Cancel"}),e.jsx(J,{isSubmitting:n.isSubmitting,isDisabled:!n.isValid||!n.values.name,buttonLabel:"Save changes",onClick:()=>void n.submitForm()})]})})})]})]})},de=({network:s,project:a})=>{var u;const i=t.useNotify(),r=O(),[d,m]=x.useState(!1),c=C(),l=()=>{m(!0),Q(s.name,a).then(()=>{r.invalidateQueries({queryKey:[g.networks]}),c(`/ui/project/${a}/networks`,i.queue(i.success(`Network ${s.name} deleted.`)))}).catch(p=>{m(!1),i.failure("Network deletion failed",p)})},n=(((u=s.used_by)==null?void 0:u.length)??0)>0,f=s.managed;return e.jsx(t.ConfirmationButton,{onHoverText:f?n?"Can not delete, network is currently in use":"Delete network":"Can not delete, network is not managed",confirmationModalProps:{title:"Confirm delete",confirmButtonAppearance:"negative",confirmButtonLabel:"Delete",children:e.jsxs("p",{children:["Are you sure you want to delete the network"," ",e.jsx(D,{item:s,bold:!0}),"?",e.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),onConfirm:l},className:"u-no-margin--bottom",loading:d,disabled:n||!f,shiftClickEnabled:!0,showShiftClickHint:!0,children:"Delete network"})},ce=({name:s,network:a,project:i})=>{var u;const r=C(),d=t.useNotify(),m=x.useState(null),c=T().shape({name:_().test("deduplicate","A network with this name already exists",p=>(a==null?void 0:a.name)===p||M(p,i,m,"networks")).required("Network name is required")}),l=z({initialValues:{name:s,isRenaming:!1},validationSchema:c,onSubmit:p=>{if(s===p.name){l.setFieldValue("isRenaming",!1),l.setSubmitting(!1);return}X(s,p.name,i).then(()=>{r(`/ui/project/${i}/networks/detail/${p.name}`,d.queue(d.success("Network renamed."))),l.setFieldValue("isRenaming",!1)}).catch(y=>{d.failure("Renaming failed",y)}).finally(()=>l.setSubmitting(!1))}}),n=(((u=a==null?void 0:a.used_by)==null?void 0:u.length)??0)>0,f=a==null?void 0:a.managed;return e.jsx(ne,{name:s,parentItems:[e.jsx(E,{to:`/ui/project/${i}/networks`,children:"Networks"},1)],renameDisabledReason:f?n?"Can not rename, network is currently in use.":void 0:"Can not rename, network is not managed",controls:a&&e.jsx(de,{network:a,project:i}),isLoaded:!!a,formik:l})},le=({network:s})=>{var l;const{project:a}=F();if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:i,isLoading:r}=I({queryKey:[g.projects,a,g.networks,s.name,g.state],queryFn:()=>Y(s.name,a)}),d=()=>{Z("network-overview-tab")};x.useEffect(d,[a,i]),V("resize",d);const m=((l=s.used_by)==null?void 0:l.length)??0;if(r)return e.jsx(A,{});const c={instances:q("instances",s.used_by),profiles:q("profiles",s.used_by)};return e.jsxs("div",{className:"network-overview-tab",children:[e.jsxs(t.Row,{className:"section",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"General"})}),e.jsx(t.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Name"}),e.jsx("td",{children:e.jsx(D,{item:s})})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Description"}),e.jsx("td",{children:s.description?s.description:"-"})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"Type"}),e.jsx("td",{children:s.type})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"State"}),e.jsx("td",{children:s.status})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"IPv4"}),e.jsx("td",{children:s.config["ipv4.address"]})]}),e.jsxs("tr",{children:[e.jsx("th",{className:"p-muted-heading",children:"IPv6"}),e.jsx("td",{children:s.config["ipv6.address"]})]})]})})})]}),e.jsxs(t.Row,{className:"section",children:[e.jsx(t.Col,{size:3,children:e.jsx("h2",{className:"p-heading--5",children:"Status"})}),e.jsx(t.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"RX"}),e.jsxs("td",{children:[$((i==null?void 0:i.counters.bytes_received)??0)," (",(i==null?void 0:i.counters.packets_received)??0," packets)"]})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"TX"}),e.jsxs("td",{children:[$((i==null?void 0:i.counters.bytes_sent)??0)," (",(i==null?void 0:i.counters.packets_sent)??0," packets)"]})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"MAC address"}),e.jsx("td",{children:(i==null?void 0:i.hwaddr)??"-"})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsx("th",{className:"p-muted-heading",children:"MTU"}),e.jsx("td",{children:(i==null?void 0:i.mtu)??"-"})]})]})})})]}),e.jsxs(t.Row,{className:"usage list-wrapper",children:[e.jsx(t.Col,{size:3,children:e.jsxs("h2",{className:"p-heading--5",children:["Usage (",m,")"]})}),e.jsx(t.Col,{size:7,children:e.jsx("table",{children:e.jsxs("tbody",{children:[e.jsxs("tr",{className:"list-wrapper",children:[e.jsxs("th",{className:"p-muted-heading",children:["Instances (",c.instances.length,")"]}),e.jsx("td",{children:c.instances.length>0?e.jsx(L,{items:c.instances.map(n=>e.jsxs("div",{children:[e.jsx(K,{instance:n}),n.project!==a&&` (project ${n.project})`]},n.name))}):"-"})]}),e.jsxs("tr",{className:"list-wrapper",children:[e.jsxs("th",{className:"p-muted-heading",children:["Profiles (",c.profiles.length,")"]}),e.jsx("td",{children:c.profiles.length>0?e.jsx(L,{items:c.profiles.map(n=>e.jsxs("div",{children:[e.jsx(E,{to:`/ui/project/${n.project}/profiles/detail/${n.name}`,children:n.name}),n.project!==a&&` (project ${n.project})`]},n.name))}):"-"})]})]})})})]})]})},oe=["Overview","Configuration"],Fe=()=>{const{name:s,project:a,activeTab:i}=F();if(!s)return e.jsx(e.Fragment,{children:"Missing name"});if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const{data:r,isLoading:d}=I({queryKey:[g.projects,a,g.networks,s],queryFn:()=>W(s,a)});return d?e.jsx(A,{}):e.jsxs(w,{header:e.jsx(ce,{network:r,project:a,name:s}),contentClassName:"edit-network",children:[e.jsx(H,{}),e.jsxs(t.Row,{children:[e.jsx(P,{tabs:oe,activeTab:i,tabUrl:`/ui/project/${a}/networks/detail/${s}`}),!i&&e.jsx("div",{role:"tabpanel","aria-labelledby":"overview",children:r&&e.jsx(le,{network:r})}),i==="configuration"&&e.jsx("div",{role:"tabpanel","aria-labelledby":"configuration",children:r&&e.jsx(re,{network:r,project:a})})]})]})};export{Fe as default};

Zerion Mini Shell 1.0