garm/webapp/assets/_app/immutable/chunks/CclkODgu.js
Gabriel Adrian Samfira eec158b32c Add SPA UI for GARM
This change adds a single page application front-end to GARM. It uses
a generated REST client, built from the swagger definitions, the websocket
interface for live updates of entities and eager loading of everything
except runners, as users may have many runners and we don't want to load
hundreds of runners in memory.

Proper pagination should be implemented in the API, in future commits,
to avoid loading lots of elements for no reason.

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

1 line
7.9 KiB
JavaScript

import"./DsnmJJEf.js";import{i as Oe}from"./B3Pzt0F_.js";import{p as qe,E as Ie,o as Ke,f as x,j as t,r,k as o,g as e,m,z as B,t as y,x as ue,u as c,v,n as T,s as i,e as be,c as u,D as Ge,d as He}from"./D8EpLgQ1.js";import{p as ge,i as $}from"./5WA7h8uK.js";import{e as Je,i as Qe}from"./u94nIB4-.js";import{r as me,b as ye,g as Ve}from"./CiE1LlKV.js";import{a as Xe,b as Ye}from"./C6k1Q4We.js";import{p as Ze}from"./D4Caz1gY.js";import{M as ea}from"./qB7B8uiS.js";var aa=x('<div class="rounded-md bg-red-50 dark:bg-red-900 p-4"><p class="text-sm font-medium text-red-800 dark:text-red-200"> </p></div>'),ta=x('<div><span class="text-gray-500 dark:text-gray-400">Owner:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div>'),ra=x('<div class="animate-pulse bg-gray-200 dark:bg-gray-700 h-10 rounded"></div>'),sa=x("<option> </option>"),oa=x('<select id="credentials" class="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"><option>Keep current credentials</option><!></select>'),na=x('<div><label for="webhookSecret" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">New Webhook Secret <span class="text-red-500">*</span></label> <input id="webhookSecret" type="password" placeholder="Enter new webhook secret" class="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"/> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Leave empty to auto-generate a new secret</p></div>'),ia=x('<div class="flex items-center"><div class="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div> Updating...</div>'),da=x('<div class="max-w-2xl w-full"><div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700"><h2 class="text-xl font-semibold text-gray-900 dark:text-white"> </h2> <p class="mt-1 text-sm text-gray-500 dark:text-gray-400"> </p></div> <form class="p-6 space-y-6"><!> <div class="bg-gray-50 dark:bg-gray-900 p-4 rounded-lg"><h3 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"> </h3> <div class="space-y-2 text-sm"><!> <div><span class="text-gray-500 dark:text-gray-400">Name:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Endpoint:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Current Credentials:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div> <div><span class="text-gray-500 dark:text-gray-400">Current Pool Balancer:</span> <span class="ml-2 text-gray-900 dark:text-white"> </span></div></div></div> <div class="space-y-4"><div><label for="credentials" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Credentials</label> <!> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Leave unchanged to keep current credentials</p></div> <div><label for="poolBalancer" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Pool Balancer Type</label> <select id="poolBalancer" class="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"><option>Round Robin</option><option>Pack</option></select> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Round Robin distributes jobs evenly across pools, Pack fills pools in order</p></div> <div class="space-y-3"><div class="flex items-center"><input id="changeWebhookSecret" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded"/> <label for="changeWebhookSecret" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">Change webhook secret</label></div> <!></div></div> <div class="flex justify-end space-x-3 pt-6 border-t border-gray-200 dark:border-gray-700"><button type="button" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 cursor-pointer">Cancel</button> <button type="submit" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"><!></button></div></form></div>');function xa(xe,D){qe(D,!1);let d=ge(D,"entity",8),k=ge(D,"entityType",8);const P=Ie();let C=m(!1),w=m(""),M=m([]),R=m(!1),f=m(""),_=m(""),h=m(""),b=m(!1);function fe(){if(k()==="repository"){const l=d();return`${l.owner}/${l.name}`}return d().name||""}function W(){return k().charAt(0).toUpperCase()+k().slice(1)}function _e(){return k()==="repository"&&d().owner||""}async function he(){try{i(R,!0),i(M,await Ve.listCredentials())}catch(l){i(w,l instanceof Error?l.message:"Failed to load credentials")}finally{i(R,!1)}}function ke(){i(f,d().credentials_name||""),i(_,d().pool_balancing_type||"roundrobin"),i(h,""),i(b,!1)}async function we(){try{i(C,!0),i(w,"");const l={};let E=!1;if(e(f)&&e(f)!==d().credentials_name&&(l.credentials_name=e(f),E=!0),e(_)&&e(_)!==d().pool_balancing_type&&(l.pool_balancer_type=e(_),E=!0),e(b)){if(!e(h).trim()){i(w,"Please enter a webhook secret or uncheck the option to change it");return}l.webhook_secret=e(h),E=!0}if(!E){P("close");return}P("submit",l)}catch(l){i(w,l instanceof Error?l.message:`Failed to update ${k()}`)}finally{i(C,!1)}}Ke(()=>{he(),ke()}),Oe(),ea(xe,{$$events:{close:()=>P("close")},children:(l,E)=>{var j=da(),F=t(j),N=t(F),Ce=t(N);r(N);var Y=o(N,2),Ee=t(Y,!0);r(Y),r(F);var z=o(F,2),Z=t(z);{var Se=a=>{var s=aa(),n=t(s),p=t(n,!0);r(n),r(s),y(()=>v(p,e(w))),u(a,s)};$(Z,a=>{e(w)&&a(Se)})}var A=o(Z,2),L=t(A),Ue=t(L);r(L);var ee=o(L,2),ae=t(ee);{var $e=a=>{var s=ta(),n=o(t(s),2),p=t(n,!0);r(n),r(s),y(S=>v(p,S),[()=>c(_e)]),u(a,s)};$(ae,a=>{k()==="repository"&&a($e)})}var O=o(ae,2),te=o(t(O),2),Pe=t(te,!0);r(te),r(O);var q=o(O,2),re=o(t(q),2),Be=t(re,!0);r(re),r(q);var I=o(q,2),se=o(t(I),2),Te=t(se,!0);r(se),r(I);var oe=o(I,2),ne=o(t(oe),2),De=t(ne,!0);r(ne),r(oe),r(ee),r(A);var K=o(A,2),G=t(K),Me=o(t(G),2);{var Re=a=>{var s=ra();u(a,s)},We=a=>{var s=oa();y(()=>{e(f),ue(()=>{e(M)})});var n=t(s);n.value=n.__value="";var p=o(n);Je(p,1,()=>e(M),Qe,(S,g)=>{var U=sa(),Le=t(U);r(U);var pe={};y(()=>{v(Le,`${e(g),c(()=>e(g).name)??""} (${e(g),c(()=>e(g).endpoint?.name||"Unknown")??""})`),pe!==(pe=(e(g),c(()=>e(g).name)))&&(U.value=(U.__value=(e(g),c(()=>e(g).name)))??"")}),u(S,U)}),r(s),ye(s,()=>e(f),S=>i(f,S)),u(a,s)};$(Me,a=>{e(R)?a(Re):a(We,!1)})}B(2),r(G);var H=o(G,2),J=o(t(H),2);y(()=>{e(_),ue(()=>{})});var Q=t(J);Q.value=Q.__value="roundrobin";var ie=o(Q);ie.value=ie.__value="pack",r(J),B(2),r(H);var de=o(H,2),V=t(de),le=t(V);me(le),B(2),r(V);var je=o(V,2);{var Fe=a=>{var s=na(),n=o(t(s),2);me(n),B(2),r(s),y(()=>n.required=e(b)),Ye(n,()=>e(h),p=>i(h,p)),u(a,s)};$(je,a=>{e(b)&&a(Fe)})}r(de),r(K);var ce=o(K,2),ve=t(ce),X=o(ve,2),Ne=t(X);{var ze=a=>{var s=ia();u(a,s)},Ae=a=>{var s=Ge();y(n=>v(s,`Update ${n??""}`),[()=>c(W)]),u(a,s)};$(Ne,a=>{e(C)?a(ze):a(Ae,!1)})}r(X),r(ce),r(z),r(j),y((a,s,n,p)=>{v(Ce,`Update ${a??""}`),v(Ee,s),v(Ue,`${n??""} Information`),v(Pe,(T(d()),c(()=>d().name))),v(Be,(T(d()),c(()=>d().endpoint?.name))),v(Te,(T(d()),c(()=>d().credentials_name))),v(De,(T(d()),c(()=>d().pool_balancing_type||"roundrobin"))),X.disabled=p},[()=>c(W),()=>c(fe),()=>c(W),()=>(e(C),e(b),e(h),c(()=>e(C)||e(b)&&!e(h).trim()))]),ye(J,()=>e(_),a=>i(_,a)),Xe(le,()=>e(b),a=>i(b,a)),be("click",ve,()=>P("close")),be("submit",z,Ze(we)),u(l,j)},$$slots:{default:!0}}),He()}export{xa as U};