AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 18.223.210.196


Current Path : /snap/lxd/31333/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/31333/share/lxd-ui/assets/DiskSizeSelector-dd5e138a.js

import{j as r,d as o}from"./index-13b2882d.js";var i=(e=>(e.B="B",e.KB="kB",e.MB="MB",e.GB="GB",e.TB="TB",e.PB="PB",e.EB="EB",e.KIB="KiB",e.MIB="MiB",e.GIB="GiB",e.TIB="TiB",e.PIB="PiB",e.EIB="EiB",e))(i||{}),c=(e=>(e[e.FIXED=0]="FIXED",e[e.PERCENT=1]="PERCENT",e))(c||{}),u=(e=>(e[e.DYNAMIC=0]="DYNAMIC",e[e.FIXED=1]="FIXED",e))(u||{});const x=e=>{var n,a,t;if(e){if(typeof e=="string")return e;switch(e.selectedType){case u.DYNAMIC:return(n=e.dynamicValue)==null?void 0:n.toString();case u.FIXED:if((a=e.fixedValue)!=null&&a.includes(",")||(t=e.fixedValue)!=null&&t.includes("-"))return e.fixedValue;if(e.fixedValue){const l=+e.fixedValue;return`${l}-${l}`}return}}},B=e=>{if(e)return e.includes(",")||e.includes("-")?{fixedValue:e,selectedType:u.FIXED}:{dynamicValue:parseInt(e),selectedType:u.DYNAMIC}},D=e=>{if(typeof e=="string")return e;if(e!=null&&e.value)return`${e.value}${e.unit}`},p=e=>{if(e)return e.includes("%")?{value:e?parseInt(e):void 0,unit:"%",selectedType:c.PERCENT}:{value:parseInt(e),unit:e.replace(/[0-9]/g,""),selectedType:c.FIXED}},h=({label:e,value:n,help:a,setMemoryLimit:t,disabled:l})=>{const d=p(n)??{value:1,unit:i.GIB},f=()=>Object.values(i).map(s=>({label:s,value:s}));return r.jsxs("div",{children:[e&&r.jsx("label",{className:"p-form__label",htmlFor:"limits_disk",children:e}),r.jsxs("div",{className:"memory-limit-with-unit",children:[r.jsx(o.Input,{id:"limits_disk",name:"limits_disk",type:"number",min:"0",step:"Any",placeholder:"Enter value",onChange:s=>t(s.target.value+d.unit),value:n!=null&&n.match(/^\d/)?d.value:"",disabled:l}),r.jsx(o.Select,{id:"memUnitSelect",name:"memUnitSelect",options:f(),onChange:s=>t(`${d.value??0}${s.target.value}`),value:d.unit,disabled:l})]}),a&&r.jsx("p",{className:"p-form-help-text",children:a})]})};export{i as B,u as C,h as D,c as M,p as a,x as c,D as m,B as p};