garm/webapp/assets/_app/immutable/nodes/13.kIWXAcC-.js
Gabriel Adrian Samfira 6fee10c737 Fix double creation of pools
This change fixes the creation of pools though the UI. Both the modal and
the page were sending a request to create the pool, leading to double pool.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-25 16:12:01 +00:00

1 line
5.2 KiB
JavaScript

import"../chunks/DsnmJJEf.js";import{i as ne}from"../chunks/zNh6Oe5P.js";import{p as ie,o as ce,l as d,a as de,f as pe,h as ue,b as me,c as fe,d as ge,g as t,m as l,$ as ye,j as he,q as M,u as N,k as v,s as o,r as Pe,n as Ce}from"../chunks/sWNKMed7.js";import{i as T,s as ve,a as _e}from"../chunks/Ccl3fNd2.js";import{g as R}from"../chunks/DVl4ZBgx.js";import{P as $e}from"../chunks/qfys27k5.js";import{C as be}from"../chunks/BRFhz4VJ.js";import{U as Me}from"../chunks/BOoHOAHB.js";import{D as Te}from"../chunks/kJjQhR0J.js";import{e as Ee,a as G}from"../chunks/DA-798Ko.js";import{t as m}from"../chunks/BZUCTtPY.js";import{e as _,h as De}from"../chunks/cjRLNre3.js";import{e as E}from"../chunks/BZiHL9L3.js";import{D as we,G as D,a as ke}from"../chunks/DCYYzf48.js";import{E as Ae}from"../chunks/DAWfW-VQ.js";import{E as Ie}from"../chunks/CARsAFuo.js";import{S as Se}from"../chunks/BJXodF8n.js";import{P as xe}from"../chunks/BaVaT5nU.js";import"../chunks/C6O4o7G1.js";const V={};var Ue=pe('<div class="space-y-6"><!> <!></div> <!> <!> <!>',1);function et(q,L){ie(L,!1);const[j,H]=ve(),r=()=>_e(Ee,"$eagerCache",j),$=l(),i=l(),p=l(),w=l();let u=l([]),y=l(!0),k=l(""),h=l(""),n=l(1),c=l(25),P=l(!1),C=l(!1),f=l(!1),a=l(null);async function z(e){try{m.success("Pool Created","Pool has been created successfully."),o(P,!1)}catch(s){const g=E(s);m.error("Pool Creation Failed",g)}}async function B(e){if(t(a))try{await R.updatePool(t(a).id,e),o(C,!1),m.add({type:"success",title:"Pool Updated",message:`Pool ${t(a).id.slice(0,8)}... has been updated successfully.`}),o(a,null)}catch(s){const g=E(s);throw m.add({type:"error",title:"Update Failed",message:g}),s}}async function J(){if(!t(a))return;const e=`Pool ${t(a).id.slice(0,8)}...`;try{await R.deletePool(t(a).id),o(f,!1),m.add({type:"success",title:"Pool Deleted",message:`${e} has been deleted successfully.`}),o(a,null)}catch(s){const g=E(s);m.add({type:"error",title:"Delete Failed",message:g})}o(f,!1),o(a,null)}function K(){o(P,!0)}function A(e){o(a,e),o(C,!0)}function I(e){o(a,e),o(f,!0)}ce(async()=>{try{o(y,!0);const e=await G.getPools();e&&Array.isArray(e)&&o(u,e)}catch(e){V?.VITEST||console.error("Failed to load pools:",e),o(k,e instanceof Error?e.message:"Failed to load pools")}finally{o(y,!1)}});async function O(){try{await G.retryResource("pools")}catch(e){V?.VITEST||console.error("Retry failed:",e)}}const Q=[{key:"id",title:"ID",flexible:!0,cellComponent:Ae,cellProps:{entityType:"pool",showId:!0,fontMono:!0}},{key:"image",title:"Image",flexible:!0,cellComponent:D,cellProps:{field:"image",type:"code",showTitle:!0}},{key:"provider",title:"Provider",cellComponent:D,cellProps:{field:"provider_name"}},{key:"flavor",title:"Flavor",cellComponent:D,cellProps:{field:"flavor"}},{key:"entity",title:"Entity",cellComponent:xe},{key:"endpoint",title:"Endpoint",cellComponent:Ie},{key:"status",title:"Status",cellComponent:Se,cellProps:{statusType:"enabled"}},{key:"actions",title:"Actions",align:"right",cellComponent:ke}],W={entityType:"pool",primaryText:{field:"id",isClickable:!0,href:"/pools/{id}",useId:!0,isMonospace:!0},secondaryText:{field:"entity_name",computedValue:e=>_(e,r())},badges:[{type:"custom",value:e=>({variant:e.enabled?"success":"error",text:e.enabled?"Enabled":"Disabled"})}],actions:[{type:"edit",handler:e=>A(e)},{type:"delete",handler:e=>I(e)}]};function X(e){o(h,e.detail.term),o(n,1)}function Y(e){o(n,e.detail.page)}function Z(e){o(c,e.detail.perPage),o(n,1)}function ee(e){A(e.detail.item)}function te(e){I(e.detail.item)}d(()=>(t(u),r()),()=>{(!t(u).length||r().loaded.pools)&&o(u,r().pools)}),d(()=>r(),()=>{o(y,r().loading.pools)}),d(()=>r(),()=>{o($,r().errorMessages.pools)}),d(()=>(t(u),t(h),r()),()=>{o(i,De(t(u),t(h),e=>_(e,r())))}),d(()=>(t(i),t(c)),()=>{o(p,Math.ceil(t(i).length/t(c)))}),d(()=>(t(n),t(p)),()=>{t(n)>t(p)&&t(p)>0&&o(n,t(p))}),d(()=>(t(i),t(n),t(c)),()=>{o(w,t(i).slice((t(n)-1)*t(c),t(n)*t(c)))}),de(),ne();var S=Ue();ue(e=>{ye.title="Pools - GARM"});var b=me(S),x=he(b);$e(x,{title:"Pools",description:"Manage runner pools across all entities",actionLabel:"Add Pool",$$events:{action:K}});var oe=v(x,2);{let e=M(()=>t($)||t(k)),s=M(()=>!!t($));we(oe,{get columns(){return Q},get data(){return t(w)},get loading(){return t(y)},get error(){return t(e)},get searchTerm(){return t(h)},searchPlaceholder:"Search by entity name...",get currentPage(){return t(n)},get perPage(){return t(c)},get totalPages(){return t(p)},get totalItems(){return t(i),N(()=>t(i).length)},itemName:"pools",emptyIconType:"cog",get showRetry(){return t(s)},get mobileCardConfig(){return W},$$events:{search:X,pageChange:Y,perPageChange:Z,retry:O,edit:ee,delete:te}})}Pe(b);var U=v(b,2);{var ae=e=>{be(e,{$$events:{close:()=>o(P,!1),submit:z}})};T(U,e=>{t(P)&&e(ae)})}var F=v(U,2);{var le=e=>{Me(e,{get pool(){return t(a)},$$events:{close:()=>{o(C,!1),o(a,null)},submit:s=>B(s.detail)}})};T(F,e=>{t(C)&&t(a)&&e(le)})}var re=v(F,2);{var se=e=>{{let s=M(()=>(t(a),Ce(_),r(),N(()=>`Pool ${t(a).id.slice(0,8)}... (${_(t(a),r())})`)));Te(e,{title:"Delete Pool",message:"Are you sure you want to delete this pool? This action cannot be undone and will remove all associated runners.",get itemName(){return t(s)},$$events:{close:()=>{o(f,!1),o(a,null)},confirm:J}})}};T(re,e=>{t(f)&&t(a)&&e(se)})}fe(q,S),ge(),H()}export{et as component};