garm/webapp/assets/_app/immutable/nodes/2.XEoeauIa.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
25 KiB
JavaScript

import"../chunks/DsnmJJEf.js";import{i as Fe}from"../chunks/zNh6Oe5P.js";import{f as h,k as a,j as r,r as t,t as D,v as S,c as m,B as He,b as ze,p as Oe,E as vt,l as Le,s as v,m as I,g as e,a as Ne,C as ut,z as ve,n as _,u,d as Qe,e as Ge,o as mt,A as gt,h as bt,$ as pt,y as Q}from"../chunks/sWNKMed7.js";import{p as fe,i as z,s as ft,a as xt}from"../chunks/Ccl3fNd2.js";import{e as ht,w as Me,i as kt}from"../chunks/BuuPrWMc.js";import{s as xe,B as yt,r as Ue,g as Ke,d as P,c as ue}from"../chunks/DVl4ZBgx.js";import{e as _t,a as Ce}from"../chunks/DA-798Ko.js";import{b as Re}from"../chunks/CLagxtgo.js";import{p as wt}from"../chunks/D4Caz1gY.js";import{M as Mt}from"../chunks/DN14Fk2Y.js";import{t as Je}from"../chunks/BZUCTtPY.js";import{e as Ut}from"../chunks/BZiHL9L3.js";var Ct=h('<div class="absolute top-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-t-gray-900"></div>'),Rt=h('<div class="absolute bottom-full left-1/2 transform -translate-x-1/2 border-4 border-transparent border-b-gray-900"></div>'),zt=h('<div class="absolute right-full top-1/2 transform -translate-y-1/2 border-4 border-transparent border-l-gray-900"></div>'),Lt=h('<div class="absolute left-full top-1/2 transform -translate-y-1/2 border-4 border-transparent border-r-gray-900"></div>'),St=h('<div class="relative group"><svg class="w-3 h-3 text-gray-400 cursor-help" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> <div><div class="font-semibold mb-1"> </div> <div class="text-gray-300"> </div> <!></div></div>');function pe(me,V){let f=fe(V,"title",8),re=fe(V,"content",8),s=fe(V,"position",8,"top"),ae=fe(V,"width",8,"w-80");var l=St(),k=a(r(l),2),p=r(k),y=r(p,!0);t(p);var d=a(p,2),L=r(d,!0);t(d);var oe=a(d,2);{var ge=E=>{var q=Ct();m(E,q)},se=E=>{var q=He(),J=ze(q);{var F=j=>{var T=Rt();m(j,T)},K=j=>{var T=He(),ie=ze(T);{var le=$=>{var H=zt();m($,H)},ne=$=>{var H=He(),X=ze(H);{var de=i=>{var o=Lt();m(i,o)};z(X,i=>{s()==="right"&&i(de)},!0)}m($,H)};z(ie,$=>{s()==="left"?$(le):$(ne,!1)},!0)}m(j,T)};z(J,j=>{s()==="bottom"?j(F):j(K,!1)},!0)}m(E,q)};z(oe,E=>{s()==="top"?E(ge):E(se,!1)})}t(k),t(l),D(()=>{xe(k,1,`absolute ${s()==="top"?"bottom-full":s()==="bottom"?"top-full":s()==="left"?"right-full top-1/2 -translate-y-1/2":"left-full top-1/2 -translate-y-1/2"} left-1/2 transform -translate-x-1/2 ${s()==="top"?"mb-2":s()==="bottom"?"mt-2":"mx-2"} ${ae()??""} p-3 bg-gray-900 text-white text-xs rounded-lg shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50`),S(y,f()),S(L,re())}),m(me,l)}var jt=ut('<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg> Settings',1),$t=h('<div><div class="flex items-center"><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Metadata</div> <div class="ml-2"><!></div></div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 break-all min-h-[38px] flex items-center"> </div></div>'),Bt=h('<div><div class="flex items-center"><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Callback</div> <div class="ml-2"><!></div></div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 break-all min-h-[38px] flex items-center"> </div></div>'),At=h('<div><div class="flex items-center"><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Webhook</div> <div class="ml-2"><!></div></div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 break-all min-h-[38px] flex items-center"> </div></div>'),It=h('<div class="text-center py-4"><svg class="mx-auto h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"></path></svg> <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">No URLs configured</p> <button class="mt-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-500 dark:hover:text-blue-300 font-medium cursor-pointer">Configure now</button></div>'),Et=h('<div class="mt-6 pt-4 border-t border-gray-200 dark:border-gray-600"><div class="flex items-center mb-2"><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Controller Webhook URL</div> <div class="ml-2"><!></div></div> <div class="p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md border border-blue-200 dark:border-blue-800"><div class="flex items-start space-x-3"><div class="flex-shrink-0 mt-0.5"><svg class="w-4 h-4 text-blue-600 dark:text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"></path></svg></div> <div class="min-w-0 flex-1"><code class="text-sm font-mono text-blue-800 dark:text-blue-300 break-all"> </code> <p class="mt-1 text-xs text-blue-700 dark:text-blue-400">Use this URL in your GitHub organization/repository webhook settings</p></div></div></div></div>'),Ht=h('<p class="mt-1 text-sm text-red-600">Please enter a valid URL</p>'),Gt=h('<p class="mt-1 text-sm text-red-600">Please enter a valid URL</p>'),Pt=h('<p class="mt-1 text-sm text-red-600">Please enter a valid URL</p>'),qt=h('<div class="max-w-2xl w-full p-6"><h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">Controller Settings</h3> <form class="space-y-4"><div><label for="metadataUrl" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Metadata URL</label> <input id="metadataUrl" type="url" placeholder="https://garm.example.com/api/v1/metadata"/> <!> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">URL where runners can fetch metadata and setup information</p></div> <div><label for="callbackUrl" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Callback URL</label> <input id="callbackUrl" type="url" placeholder="https://garm.example.com/api/v1/callbacks"/> <!> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">URL where runners send status updates and lifecycle events</p></div> <div><label for="webhookUrl" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Webhook Base URL</label> <input id="webhookUrl" type="url" placeholder="https://garm.example.com/webhooks"/> <!> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">URL where GitHub/Gitea will send webhook events for job notifications</p></div> <div><label for="minimumJobAgeBackoff" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Minimum Job Age Backoff (seconds)</label> <input id="minimumJobAgeBackoff" type="number" min="0" placeholder="30" class="block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white sm:text-sm"/> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Time to wait before spinning up a runner for a new job (0 = immediate)</p></div> <div class="flex justify-end space-x-3 pt-4"><button type="button" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer">Cancel</button> <button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 dark:focus:ring-offset-gray-900 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"> </button></div></form></div>'),Tt=h('<div class="bg-white dark:bg-gray-800 shadow rounded-lg"><div class="p-6"><div class="flex items-center justify-between mb-6"><div class="flex items-center space-x-3"><div class="flex items-center justify-center w-10 h-10 rounded-lg bg-blue-100 dark:bg-blue-900"><svg class="w-6 h-6 text-blue-600 dark:text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg></div> <div><h3 class="text-lg font-semibold text-gray-900 dark:text-white">Controller Information</h3> <div class="mt-1"><span class="text-sm text-gray-500 dark:text-gray-400"> </span></div></div></div> <!></div> <div class="grid grid-cols-1 lg:grid-cols-2 gap-6"><div class="space-y-4"><div><h4 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">Identity</h4> <div class="space-y-3"><div><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Controller ID</div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 break-all min-h-[38px] flex items-center"> </div></div> <div><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Hostname</div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 break-all min-h-[38px] flex items-center"> </div></div> <div><div class="flex items-center"><div class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Job Age Backoff</div> <div class="ml-2"><!></div></div> <div class="mt-1 p-2 bg-gray-50 dark:bg-gray-700 rounded text-sm font-mono text-gray-600 dark:text-gray-300 min-h-[38px] flex items-center"> </div></div></div></div></div> <div class="space-y-4"><div><h4 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">Integration URLs</h4> <div class="space-y-3"><!> <!> <!> <!></div></div></div></div> <!></div></div> <!>',1);function Dt(me,V){Oe(V,!1);const f=I(),re=I();let s=fe(V,"controllerInfo",12);const ae=vt();let l=I(!1),k=I(!1),p=I(""),y=I(""),d=I(""),L=I(null);function oe(){v(p,s().metadata_url||""),v(y,s().callback_url||""),v(d,s().webhook_url||""),v(L,s().minimum_job_age_backoff||null),v(l,!0)}async function ge(){try{v(k,!0);const n={};e(p).trim()&&(n.metadata_url=e(p).trim()),e(y).trim()&&(n.callback_url=e(y).trim()),e(d).trim()&&(n.webhook_url=e(d).trim()),e(L)!==null&&e(L)>=0&&(n.minimum_job_age_backoff=e(L));const c=await Ke.updateController(n);Je.success("Settings Updated","Controller settings have been updated successfully."),v(l,!1),s(c),ae("updated",c)}catch(n){Je.error("Update Failed",n instanceof Error?n.message:"Failed to update controller settings")}finally{v(k,!1)}}function se(){v(l,!1),v(p,""),v(y,""),v(d,""),v(L,null)}Le(()=>{},()=>{v(f,n=>{if(!n.trim())return!0;try{return new URL(n),!0}catch{return!1}})}),Le(()=>(e(f),e(p),e(y),e(d),e(L)),()=>{v(re,e(f)(e(p))&&e(f)(e(y))&&e(f)(e(d))&&(e(L)===null||e(L)>=0))}),Ne(),Fe();var E=Tt(),q=ze(E),J=r(q),F=r(J),K=r(F),j=a(r(K),2),T=a(r(j),2),ie=r(T),le=r(ie);t(ie),t(T),t(j),t(K);var ne=a(K,2);yt(ne,{variant:"secondary",size:"sm",$$events:{click:oe},children:(n,c)=>{var b=jt();ve(),m(n,b)},$$slots:{default:!0}}),t(F);var $=a(F,2),H=r($),X=r(H),de=a(r(X),2),i=r(de),o=a(r(i),2),w=r(o,!0);t(o),t(i);var M=a(i,2),x=a(r(M),2),U=r(x,!0);t(x),t(M);var A=a(M,2),W=r(A),Y=a(r(W),2),Z=r(Y);pe(Z,{title:"Job Age Backoff",content:"Time in seconds GARM waits after receiving a new job before spinning up a runner. This delay allows existing idle runners to pick up jobs first, preventing unnecessary runner creation. Set to 0 for immediate response."}),t(Y),t(W);var O=a(W,2),N=r(O);t(O),t(A),t(de),t(X),t(H);var ee=a(H,2),ce=r(ee),he=a(r(ce),2),ke=r(he);{var Se=n=>{var c=$t(),b=r(c),C=a(r(b),2),G=r(C);pe(G,{title:"Metadata URL",content:"URL where runners retrieve setup information and metadata. Runners must be able to connect to this URL during their initialization process. Usually accessible at /api/v1/metadata endpoint."}),t(C),t(b);var R=a(b,2),B=r(R,!0);t(R),t(c),D(()=>S(B,(_(s()),u(()=>s().metadata_url)))),m(n,c)};z(ke,n=>{_(s()),u(()=>s().metadata_url)&&n(Se)})}var Pe=a(ke,2);{var Xe=n=>{var c=Bt(),b=r(c),C=a(r(b),2),G=r(C);pe(G,{title:"Callback URL",content:"URL where runners send status updates and system information (OS version, runner agent ID, etc.) to the controller. Runners must be able to connect to this URL. Usually accessible at /api/v1/callbacks endpoint."}),t(C),t(b);var R=a(b,2),B=r(R,!0);t(R),t(c),D(()=>S(B,(_(s()),u(()=>s().callback_url)))),m(n,c)};z(Pe,n=>{_(s()),u(()=>s().callback_url)&&n(Xe)})}var qe=a(Pe,2);{var Ye=n=>{var c=At(),b=r(c),C=a(r(b),2),G=r(C);pe(G,{title:"Webhook Base URL",content:"Base URL for webhooks where GitHub sends job notifications. GARM needs to receive these webhooks to know when to create new runners for jobs. GitHub must be able to connect to this URL. Usually accessible at /webhooks endpoint."}),t(C),t(b);var R=a(b,2),B=r(R,!0);t(R),t(c),D(()=>S(B,(_(s()),u(()=>s().webhook_url)))),m(n,c)};z(qe,n=>{_(s()),u(()=>s().webhook_url)&&n(Ye)})}var Ze=a(qe,2);{var et=n=>{var c=It(),b=a(r(c),4);t(c),Ge("click",b,oe),m(n,c)};z(Ze,n=>{_(s()),u(()=>!s().metadata_url&&!s().callback_url&&!s().webhook_url)&&n(et)})}t(he),t(ce),t(ee),t($);var tt=a($,2);{var rt=n=>{var c=Et(),b=r(c),C=a(r(b),2),G=r(C);pe(G,{title:"Controller Webhook URL",content:"Unique webhook URL for this GARM controller. This is the preferred URL to use in GitHub webhook settings as it's controller-specific and allows multiple GARM controllers to work with the same repository. Automatically combines the webhook base URL with the controller ID."}),t(C),t(b);var R=a(b,2),B=r(R),be=a(r(B),2),ye=r(be),je=r(ye,!0);t(ye),ve(2),t(be),t(B),t(R),t(c),D(()=>S(je,(_(s()),u(()=>s().controller_webhook_url)))),m(n,c)};z(tt,n=>{_(s()),u(()=>s().controller_webhook_url)&&n(rt)})}t(J),t(q);var at=a(q,2);{var ot=n=>{Mt(n,{$$events:{close:se},children:(c,b)=>{var C=qt(),G=a(r(C),2),R=r(G),B=a(r(R),2);Ue(B);let be;var ye=a(B,2);{var je=g=>{var te=Ht();m(g,te)};z(ye,g=>{e(f),e(p),u(()=>!e(f)(e(p)))&&g(je)})}ve(2),t(R);var $e=a(R,2),_e=a(r($e),2);Ue(_e);let Te;var st=a(_e,2);{var it=g=>{var te=Gt();m(g,te)};z(st,g=>{e(f),e(y),u(()=>!e(f)(e(y)))&&g(it)})}ve(2),t($e);var Be=a($e,2),we=a(r(Be),2);Ue(we);let De;var lt=a(we,2);{var nt=g=>{var te=Pt();m(g,te)};z(lt,g=>{e(f),e(d),u(()=>!e(f)(e(d)))&&g(nt)})}ve(2),t(Be);var Ae=a(Be,2),Ve=a(r(Ae),2);Ue(Ve),ve(2),t(Ae);var We=a(Ae,2),Ie=r(We),Ee=a(Ie,2),dt=r(Ee,!0);t(Ee),t(We),t(G),t(C),D((g,te,ct)=>{be=xe(B,1,"block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white sm:text-sm",null,be,g),Te=xe(_e,1,"block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white sm:text-sm",null,Te,te),De=xe(we,1,"block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white sm:text-sm",null,De,ct),Ie.disabled=e(k),Ee.disabled=!e(re)||e(k),S(dt,e(k)?"Saving...":"Save Changes")},[()=>({"border-red-300":!e(f)(e(p))}),()=>({"border-red-300":!e(f)(e(y))}),()=>({"border-red-300":!e(f)(e(d))})]),Re(B,()=>e(p),g=>v(p,g)),Re(_e,()=>e(y),g=>v(y,g)),Re(we,()=>e(d),g=>v(d,g)),Re(Ve,()=>e(L),g=>v(L,g)),Ge("click",Ie,se),Ge("submit",G,wt(ge)),m(c,C)},$$slots:{default:!0}})};z(at,n=>{e(l)&&n(ot)})}D(n=>{S(le,`v${n??""}`),S(w,(_(s()),u(()=>s().controller_id))),S(U,(_(s()),u(()=>s().hostname||"Unknown"))),S(N,`${_(s()),u(()=>s().minimum_job_age_backoff||30)??""}s`)},[()=>(_(s()),u(()=>s().version?.replace(/^v/,"")||"Unknown"))]),m(me,E),Qe()}var Vt=h('<div class="rounded-md bg-red-50 dark:bg-red-900 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path></svg></div> <div class="ml-3"><h3 class="text-sm font-medium text-red-800 dark:text-red-200">Error loading dashboard</h3> <p class="mt-2 text-sm text-red-700 dark:text-red-300"> </p></div></div></div>'),Wt=h('<a class="bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg hover:shadow-md transition-shadow duration-200"><div class="p-5"><div class="flex items-center"><div class="flex-shrink-0"><div><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div></div> <div class="ml-5 w-0 flex-1"><dl><dt class="text-sm font-medium text-gray-500 dark:text-gray-400 truncate"> </dt> <dd class="text-lg font-medium text-gray-900 dark:text-white"> </dd></dl></div></div></div></a>'),Jt=h('<div class="space-y-6"><div><h1 class="text-2xl font-bold text-gray-900 dark:text-white">Dashboard</h1> <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Welcome to GARM - GitHub Actions Runner Manager</p></div> <!> <div class="grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4"></div> <!> <div class="bg-white dark:bg-gray-800 shadow rounded-lg"><div class="p-6"><h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">Quick Actions</h3> <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Common tasks you can perform</p> <div class="mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"><a class="relative block w-full bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg p-6 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"><div class="flex items-center"><svg class="flex-shrink-0 w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg> <div class="ml-4"><h4 class="text-sm font-medium text-gray-900 dark:text-white">Add Repository</h4> <p class="text-sm text-gray-500 dark:text-gray-400">Connect a new GitHub repository</p></div></div></a> <a class="relative block w-full bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg p-6 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"><div class="flex items-center"><svg class="flex-shrink-0 w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg> <div class="ml-4"><h4 class="text-sm font-medium text-gray-900 dark:text-white">Create Pool</h4> <p class="text-sm text-gray-500 dark:text-gray-400">Set up a new runner pool</p></div></div></a> <a class="relative block w-full bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg p-6 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"><div class="flex items-center"><svg class="flex-shrink-0 w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg> <div class="ml-4"><h4 class="text-sm font-medium text-gray-900 dark:text-white">View Instances</h4> <p class="text-sm text-gray-500 dark:text-gray-400">Monitor running instances</p></div></div></a></div></div></div></div>');function or(me,V){Oe(V,!1);const[f,re]=ft(),s=()=>xt(_t,"$eagerCache",f),ae=I();let l=I({repositories:0,organizations:0,pools:0,instances:0}),k=I(null),p=I(""),y=[];function d(i,o,w=1e3){const M=parseInt(i.textContent||"0"),x=(o-M)/(w/16);let U=M;const A=()=>{if(U+=x,x>0&&U>=o||x<0&&U<=o){i.textContent=o.toString();return}i.textContent=Math.floor(U).toString(),requestAnimationFrame(A)};M!==o&&requestAnimationFrame(A)}mt(async()=>{try{const[x,U,A,W,Y]=await Promise.all([Ce.getRepositories(),Ce.getOrganizations(),Ce.getPools(),Ke.listInstances(),Ce.getControllerInfo()]);setTimeout(()=>{const Z=document.querySelector('[data-stat="repositories"]'),O=document.querySelector('[data-stat="organizations"]'),N=document.querySelector('[data-stat="pools"]'),ee=document.querySelector('[data-stat="instances"]');Z&&d(Z,x.length),O&&d(O,U.length),N&&d(N,A.length),ee&&d(ee,W.length)},100),v(l,{repositories:x.length,organizations:U.length,pools:A.length,instances:W.length}),Y&&v(k,Y)}catch(x){v(p,Ut(x)),console.error("Dashboard error:",x)}const i=Me.subscribeToEntity("repository",["create","delete"],L),o=Me.subscribeToEntity("organization",["create","delete"],oe),w=Me.subscribeToEntity("pool",["create","delete"],ge),M=Me.subscribeToEntity("instance",["create","delete"],se);y=[i,o,w,M]}),gt(()=>{y.forEach(i=>i())});function L(i){const o=document.querySelector('[data-stat="repositories"]');i.operation==="create"?(Q(l,e(l).repositories++),o&&d(o,e(l).repositories,500)):i.operation==="delete"&&(Q(l,e(l).repositories=Math.max(0,e(l).repositories-1)),o&&d(o,e(l).repositories,500))}function oe(i){const o=document.querySelector('[data-stat="organizations"]');i.operation==="create"?(Q(l,e(l).organizations++),o&&d(o,e(l).organizations,500)):i.operation==="delete"&&(Q(l,e(l).organizations=Math.max(0,e(l).organizations-1)),o&&d(o,e(l).organizations,500))}function ge(i){const o=document.querySelector('[data-stat="pools"]');i.operation==="create"?(Q(l,e(l).pools++),o&&d(o,e(l).pools,500)):i.operation==="delete"&&(Q(l,e(l).pools=Math.max(0,e(l).pools-1)),o&&d(o,e(l).pools,500))}function se(i){const o=document.querySelector('[data-stat="instances"]');i.operation==="create"?(Q(l,e(l).instances++),o&&d(o,e(l).instances,500)):i.operation==="delete"&&(Q(l,e(l).instances=Math.max(0,e(l).instances-1)),o&&d(o,e(l).instances,500))}function E(i){v(k,i.detail)}function q(i){return{blue:"bg-blue-500 text-white",green:"bg-green-500 text-white",purple:"bg-purple-500 text-white",yellow:"bg-yellow-500 text-white"}[i]||"bg-gray-500 text-white"}Le(()=>(e(k),s()),()=>{(!e(k)||s().loaded.controllerInfo)&&v(k,s().controllerInfo)}),Le(()=>(e(l),P),()=>{v(ae,[{title:"Repositories",value:e(l).repositories,icon:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",color:"blue",href:P("/repositories")},{title:"Organizations",value:e(l).organizations,icon:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z",color:"green",href:P("/organizations")},{title:"Pools",value:e(l).pools,icon:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z",color:"purple",href:P("/pools")},{title:"Instances",value:e(l).instances,icon:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z",color:"yellow",href:P("/instances")}])}),Ne(),Fe();var J=Jt();bt(i=>{pt.title="Dashboard - GARM"});var F=a(r(J),2);{var K=i=>{var o=Vt(),w=r(o),M=a(r(w),2),x=a(r(M),2),U=r(x,!0);t(x),t(M),t(w),t(o),D(()=>S(U,e(p))),m(i,o)};z(F,i=>{e(p)&&i(K)})}var j=a(F,2);ht(j,5,()=>e(ae),kt,(i,o)=>{var w=Wt(),M=r(w),x=r(M),U=r(x),A=r(U),W=r(A),Y=r(W);t(W),t(A),t(U);var Z=a(U,2),O=r(Z),N=r(O),ee=r(N,!0);t(N);var ce=a(N,2),he=r(ce,!0);t(ce),t(O),t(Z),t(x),t(M),t(w),D((ke,Se)=>{ue(w,"href",(e(o),u(()=>e(o).href))),xe(A,1,`w-8 h-8 rounded-md ${ke??""} flex items-center justify-center`),ue(Y,"d",(e(o),u(()=>e(o).icon))),S(ee,(e(o),u(()=>e(o).title))),ue(ce,"data-stat",Se),S(he,(e(o),u(()=>e(o).value)))},[()=>(e(o),u(()=>q(e(o).color))),()=>(e(o),u(()=>e(o).title.toLowerCase()))]),m(i,w)}),t(j);var T=a(j,2);{var ie=i=>{Dt(i,{get controllerInfo(){return e(k)},$$events:{updated:E}})};z(T,i=>{e(k)&&i(ie)})}var le=a(T,2),ne=r(le),$=a(r(ne),4),H=r($),X=a(H,2),de=a(X,2);t($),t(ne),t(le),t(J),D((i,o,w)=>{ue(H,"href",i),ue(X,"href",o),ue(de,"href",w)},[()=>(_(P),u(()=>P("/repositories"))),()=>(_(P),u(()=>P("/pools"))),()=>(_(P),u(()=>P("/instances")))]),m(me,J),Qe(),re()}export{or as component};