garm/webapp/assets/_app/immutable/nodes/13.Bzfe-m2N.js

2 lines
5.1 KiB
JavaScript
Raw Normal View History

import"../chunks/DsnmJJEf.js";import{i as se}from"../chunks/zNh6Oe5P.js";import{p as ne,o as ie,l as d,a as ce,f as de,h as pe,b as ue,c as me,d as fe,g as t,m as l,$ as ge,j as ye,q as M,u as F,k as C,s as o,r as he,n as Pe}from"../chunks/sWNKMed7.js";import{i as D,s as Ce,a as ve}from"../chunks/Ccl3fNd2.js";import{g as N}from"../chunks/t8NOL8UT.js";import{P as $e}from"../chunks/sdr-JCKi.js";import{C as be}from"../chunks/Csic5lDL.js";import{U as _e}from"../chunks/DLiuxLBn.js";import{D as Me}from"../chunks/Dxyf9P7U.js";import{e as De,a as R}from"../chunks/UPGsoYWO.js";import{t as f}from"../chunks/BZUCTtPY.js";import{e as v,h as Ee}from"../chunks/Cbkm53HO.js";import{e as G}from"../chunks/BZiHL9L3.js";import{D as Te,G as E,a as we}from"../chunks/WvS03pW2.js";import{E as ke}from"../chunks/CfvU88k5.js";import{E as Ae}from"../chunks/CC0e8UY8.js";import{S as xe}from"../chunks/C7WQ-JBG.js";import{P as Ie}from"../chunks/MfZe8e4a.js";import"../chunks/BFThZs5w.js";var Ue=de('<div class="space-y-6"><!> <!></div> <!> <!> <!>',1);function Ze(q,L){ne(L,!1);const[j,H]=Ce(),r=()=>ve(De,"$eagerCache",j),$=l(),i=l(),p=l(),T=l();let u=l([]),g=l(!0),w=l(""),y=l(""),s=l(1),c=l(25),h=l(!1),P=l(!1),m=l(!1),a=l(null);async function V(){f.success("Pool Created","Pool has been created successfully."),o(h,!1)}async function z(e){if(t(a))try{await N.updatePool(t(a).id,e),o(P,!1),f.add({type:"success",title:"Pool Updated",message:`Pool ${t(a).id.slice(0,8)}... has been updated successfully.`}),o(a,null)}catch(n){const _=G(n);throw f.add({type:"error",title:"Update Failed",message:_}),n}}async function B(){if(!t(a))return;const e=`Pool ${t(a).id.slice(0,8)}...`;try{await N.deletePool(t(a).id),o(m,!1),f.add({type:"success",title:"Pool Deleted",message:`${e} has been deleted successfully.`}),o(a,null)}catch(n){const _=G(n);f.add({type:"error",title:"Delete Failed",message:_})}o(m,!1),o(a,null)}function J(){o(h,!0)}function k(e){o(a,e),o(P,!0)}function A(e){o(a,e),o(m,!0)}ie(async()=>{try{o(g,!0);const e=await R.getPools();e&&Array.isArray(e)&&o(u,e)}catch(e){console.error("Failed to load pools:",e),o(w,e instanceof Error?e.message:"Failed to load pools")}finally{o(g,!1)}});async function K(){try{await R.retryResource("pools")}catch(e){console.error("Retry failed:",e)}}const O=[{key:"id",title:"ID",flexible:!0,cellComponent:ke,cellProps:{entityType:"pool",showId:!0,fontMono:!0}},{key:"image",title:"Image",flexible:!0,cellComponent:E,cellProps:{field:"image",type:"code",showTitle:!0}},{key:"provider",title:"Provider",cellComponent:E,cellProps:{field:"provider_name"}},{key:"flavor",title:"Flavor",cellComponent:E,cellProps:{field:"flavor"}},{key:"entity",title:"Entity",cellComponent:Ie},{key:"endpoint",title:"Endpoint",cellComponent:Ae},{key:"status",title:"Status",cellComponent:xe,cellProps:{statusType:"enabled"}},{key:"actions",title:"Actions",align:"right",cellComponent:we}],Q={entityType:"pool",primaryText:{field:"id",isClickable:!0,href:"/pools/{id}",useId:!0,isMonospace:!0},secondaryText:{field:"entity_name",computedValue:e=>v(e,r())},badges:[{type:"custom",value:e=>({variant:e.enabled?"success":"error",text:e.enabled?"Enabled":"Disabled"})}],actions:[{type:"edit",handler:e=>k(e)},{type:"delete",handler:e=>A(e)}]};function W(e){o(y,e.detail.term),o(s,1)}function X(e){o(s,e.detail.page)}function Y(e){o(c,e.detail.perPage),o(s,1)}function Z(e){k(e.detail.item)}function ee(e){A(e.detail.item)}d(()=>(t(u),r()),()=>{(!t(u).length||r().loaded.pools)&&o(u,r().pools)}),d(()=>r(),()=>{o(g,r().loading.pools)}),d(()=>r(),()=>{o($,r().errorMessages.pools)}),d(()=>(t(u),t(y),r()),()=>{o(i,Ee(t(u),t(y),e=>v(e,r())))}),d(()=>(t(i),t(c)),()=>{o(p,Math.ceil(t(i).length/t(c)))}),d(()=>(t(s),t(p)),()=>{t(s)>t(p)&&t(p)>0&&o(s,t(p))}),d(()=>(t(i),t(s),t(c)),()=>{o(T,t(i).slice((t(s)-1)*t(c),t(s)*t(c)))}),ce(),se();var x=Ue();pe(e=>{ge.title="Pools - GARM"});var b=ue(x),I=ye(b);$e(I,{title:"Pools",description:"Manage runner pools across all entities",actionLabel:"Add Pool",$$events:{action:J}});var te=C(I,2);{let e=M(()=>t($)||t(w)),n=M(()=>!!t($));Te(te,{get columns(){r