garm/webapp/assets/_app/immutable/nodes/12.CtZLJ4UU.js

2 lines
7.6 KiB
JavaScript
Raw Normal View History

import"../chunks/DsnmJJEf.js";import{i as Ne}from"../chunks/B3Pzt0F_.js";import{p as We,o as qe,A as He,l as je,a as Ge,f as A,h as Re,b as C,t as q,c as x,d as Ve,g as e,m as l,s as o,u as s,$ as Je,j as f,r as m,k as d,v as de,y as Ke,B as ce,q as g,n as Qe}from"../chunks/D8EpLgQ1.js";import{i as h,s as Xe,a as Ye}from"../chunks/5WA7h8uK.js";import{c as Ze,g as _}from"../chunks/CiE1LlKV.js";import{p as et}from"../chunks/-1rkm990.js";import{g as ue}from"../chunks/DsX4H4sg.js";import{b as H}from"../chunks/D3_ugSUS.js";import{U as tt}from"../chunks/CIBm3n2u.js";import{D as fe}from"../chunks/KQ2xQpA3.js";import{E as at,P as nt,a as ot}from"../chunks/DxQgLoe9.js";import{D as rt,I as it}from"../chunks/G-ddPbA8.js";import{g as me}from"../chunks/D5ucq3Gx.js";import{e as j}from"../chunks/BZiHL9L3.js";import{W as st}from"../chunks/BsqC4UA1.js";import{C as lt}from"../chunks/CRD55Dyg.js";import{w as G}from"../chunks/u94nIB4-.js";import{t as E}from"../chunks/BEkVdVE1.js";var dt=A('<div class="p-6 text-center"><div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"></div> <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">Loading organization...</p></div>'),ct=A('<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>'),ut=A("<!> <!> <!> <!> <!> <!>",1),ft=A('<div class="space-y-6"><nav class="flex" aria-label="Breadcrumb"><ol class="inline-flex items-center space-x-1 md:space-x-3"><li class="inline-flex items-center"><a class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white"><svg class="w-3 h-3 mr-2.5" fill="currentColor" viewBox="0 0 20 20"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"></path></svg> Organizations</a></li> <li><div class="flex items-center"><svg class="w-3 h-3 text-gray-400 mx-1" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg> <span class="ml-1 text-sm font-medium text-gray-500 md:ml-2 dark:text-gray-400"> </span></div></li></ol></nav> <!></div> <!> <!> <!> <!>',1);function Mt(ge,pe){We(pe,!1);const[ve,ye]=Xe(),R=()=>Ye(et,"$page",ve),I=l();let a=l(null),c=l([]),p=l([]),S=l(!0),O=l(""),D=l(!1),T=l(!1),w=l(!1),P=l(!1),u=l(null),M=null,b=l();async function V(){if(e(I))try{o(S,!0),o(O,"");const[t,n,r]=await Promise.all([_.getOrganization(e(I)),_.listOrganizationPools(e(I)).catch(()=>[]),_.listOrganizationInstances(e(I)).catch(()=>[])]);o(a,t),o(c,n),o(p,r)}catch(t){o(O,j(t))}finally{o(S,!1)}}function he(t,n){const{events:r}=t;return{...n,events:r}}async function _e(t){if(e(a))try{await _.updateOrganization(e(a).id,t),await V(),E.success("Organization Updated",`Organization ${e(a).name} has been updated successfully.`),o(D,!1)}catch(n){throw n}}async function be(){if(e(a)){try{await _.deleteOrganization(e(a).id),ue(`${H}/organizations`)}catch(t){const n=j(t);E.error("Delete Failed",n)}o(T,!1)}}async function ze(){if(e(u))try{await _.deleteInstance(e(u).name),E.success("Instance Deleted",`Instance ${e(u).name} has been deleted successfully.`),o(w,!1),o(u,null)}catch(t){const n=j(t);E.error("Delete Failed",n),o(w,!1),o(u,null)}}function $e(t){o(u,t),o(w,!0)}function xe(){o(P,!0)}async function Ie(t){try{if(!e(a))return;await _.createOrganizationPool(e(a).id,t.detail),E.success("Pool Created",`Pool has been created successfully for organization ${e(a).name}.`),o(P,!1)}catch(n){throw n}}function J(){e(b)&&Ke(b,e(b).scrollTop=e(b).scrollHeight)}function we(t){if(t.operation==="update"){const n=t.payload;if(e(a)&&n.id===e(a).id){const r=e(a).events?.length||0,i=n.events?.length||0;o(a,he(e(a),n)),i>r&&setTimeout(()=>{J()},100)}}else if(t.operation==="delete"){const n=t.payload.id||t.payload;e(a)&&e(a).id===n&&ue(`${H}/organizatio