The URL from scale sets and pools to the entity to which they belong was not being properly resolved. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1 line
7.6 KiB
JavaScript
1 line
7.6 KiB
JavaScript
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}/organizations`)}}function Ee(t){if(!e(a))return;const n=t.payload;if(n.org_id===e(a).id){if(t.operation==="create")o(c,[...e(c),n]);else if(t.operation==="update")o(c,e(c).map(r=>r.id===n.id?n:r));else if(t.operation==="delete"){const r=n.id||n;o(c,e(c).filter(i=>i.id!==r))}}}function Oe(t){if(!e(a)||!e(c))return;const n=t.payload;if(e(c).some(i=>i.id===n.pool_id)){if(t.operation==="create")o(p,[...e(p),n]);else if(t.operation==="update")o(p,e(p).map(i=>i.id===n.id?n:i));else if(t.operation==="delete"){const i=n.id||n;o(p,e(p).filter(L=>L.id!==i))}}}qe(()=>{V().then(()=>{e(a)?.events?.length&&setTimeout(()=>{J()},100)});const t=G.subscribeToEntity("organization",["update","delete"],we),n=G.subscribeToEntity("pool",["create","update","delete"],Ee),r=G.subscribeToEntity("instance",["create","update","delete"],Oe);M=()=>{t(),n(),r()}}),He(()=>{M&&(M(),M=null)}),je(()=>R(),()=>{o(I,R().params.id)}),Ge(),Ne();var K=ft();Re(t=>{q(()=>Je.title=`${e(a),s(()=>e(a)?`${e(a).name} - Organization Details`:"Organization Details")??""} - GARM`)});var B=C(K),U=f(B),Q=f(U),F=f(Q),De=f(F);m(F);var X=d(F,2),Y=f(X),Z=d(f(Y),2),Te=f(Z,!0);m(Z),m(Y),m(X),m(Q),m(U);var Pe=d(U,2);{var Me=t=>{var n=dt();x(t,n)},ke=t=>{var n=ce(),r=C(n);{var i=z=>{var $=ct(),k=f($),N=f(k,!0);m(k),m($),q(()=>de(N,e(O))),x(z,$)},L=z=>{var $=ce(),k=C($);{var N=W=>{var ne=ut(),oe=C(ne);{let v=g(()=>(e(a),s(()=>e(a).name||"Organization"))),y=g(()=>(e(a),s(()=>e(a).endpoint?.name))),Le=g(()=>(Qe(me),e(a),s(()=>me(e(a).endpoint?.endpoint_type||"unknown"))));rt(oe,{get title(){return e(v)},get subtitle(){return`Endpoint: ${e(y)??""}`},get forgeIcon(){return e(Le)},onEdit:()=>o(D,!0),onDelete:()=>o(T,!0)})}var re=d(oe,2);at(re,{get entity(){return e(a)},entityType:"organization"});var ie=d(re,2);{let v=g(()=>(e(a),s(()=>e(a).id||""))),y=g(()=>(e(a),s(()=>e(a).name||"")));st(ie,{entityType:"organization",get entityId(){return e(v)},get entityName(){return e(y)}})}var se=d(ie,2);{let v=g(()=>(e(a),s(()=>e(a).id||""))),y=g(()=>(e(a),s(()=>e(a).name||"")));nt(se,{get pools(){return e(c)},entityType:"organization",get entityId(){return e(v)},get entityName(){return e(y)},$$events:{addPool:xe}})}var le=d(se,2);it(le,{get instances(){return e(p)},entityType:"organization",onDeleteInstance:$e});var Fe=d(le,2);{let v=g(()=>(e(a),s(()=>e(a)?.events)));ot(Fe,{get events(){return e(v)},get eventsContainer(){return e(b)},set eventsContainer(y){o(b,y)},$$legacy:!0})}x(W,ne)};h(k,W=>{e(a)&&W(N)},!0)}x(z,$)};h(r,z=>{e(O)?z(i):z(L,!1)},!0)}x(t,n)};h(Pe,t=>{e(S)?t(Me):t(ke,!1)})}m(B);var ee=d(B,2);{var Ce=t=>{tt(t,{get entity(){return e(a)},entityType:"organization",$$events:{close:()=>o(D,!1),submit:n=>_e(n.detail)}})};h(ee,t=>{e(D)&&e(a)&&t(Ce)})}var te=d(ee,2);{var Ae=t=>{fe(t,{title:"Delete Organization",message:"Are you sure you want to delete this organization? This action cannot be undone and will remove all associated pools and instances.",get itemName(){return e(a),s(()=>e(a).name)},$$events:{close:()=>o(T,!1),confirm:be}})};h(te,t=>{e(T)&&e(a)&&t(Ae)})}var ae=d(te,2);{var Se=t=>{fe(t,{title:"Delete Instance",message:"Are you sure you want to delete this instance? This action cannot be undone.",get itemName(){return e(u),s(()=>e(u).name)},$$events:{close:()=>{o(w,!1),o(u,null)},confirm:ze}})};h(ae,t=>{e(w)&&e(u)&&t(Se)})}var Be=d(ae,2);{var Ue=t=>{{let n=g(()=>(e(a),s(()=>e(a).id||"")));lt(t,{initialEntityType:"organization",get initialEntityId(){return e(n)},$$events:{close:()=>o(P,!1),submit:Ie}})}};h(Be,t=>{e(P)&&e(a)&&t(Ue)})}q(()=>{Ze(De,"href",`${H}/organizations`),de(Te,(e(a),s(()=>e(a)?e(a).name:"Loading...")))}),x(ge,K),Ve(),ye()}export{Mt as component};
|