import{d as _,r as f,o as y,c as n,a as c,b as $,e,u as C,f as S,F as m,g as T,h as k,t as B,i as d,j as P,$ as R}from"./chunks/filter-CiYqP1_r.js";import{p as j}from"./chunks/bootbox-D3SJ_Fwv.js";import"./chunks/index-sLCKmIWG-umQeu_-w.js";import{u as A,_ as E,B as N}from"./chunks/BToastOrchestrator.vue_vue_type_style_index_0_lang-CgGO-ddH-BDr_frBe.js";const V={class:"row align-stretch"},D={class:"col-sm-6 col-md-4 col-lg-3 m-2"},F=["href"],L={class:"col-sm-6 col-md-4 col-lg-3 m-2"},O=["href"],U={class:"col-sm-6 col-md-4 col-lg-3 m-2"},G={key:0,class:"col-sm-6 col-md-4 col-lg-3 m-2"},H=["href"],I={class:"row align-stretch"},J={class:"dropdown m-2"},M={class:"dropdown-menu"},q=["onClick"],z=_({__name:"Dashboard",setup(K){const p=URLS.prefix,{show:x}=A();async function v(a){const o=u.value[a].arguments,l=[];if(o?.length>0)for(const t of o){const h=await j({title:t.description,value:t.default,inputType:"text"});if(h===null)return;l.push(h)}const r=bootbox.dialog({message:'<i class="fa fa-spin fa-spinner"></i> Script is being executed',closeButton:!1});let g=new Promise((t,h)=>{r.on("shown.bs.modal",()=>t())});try{const t=await(await fetch(`${p}/api/scripts/${a}/run`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({args:l})})).json();await g,r.modal("hide"),bootbox.dialog({title:t.success?"Success":"Error",message:t.result??t.error})}catch(t){await g,r.modal("hide"),bootbox.dialog({message:`<p>An error occurred</p><p>${t}</p>`,title:"Error"})}}async function w(){const a=bootbox.dialog({message:'<i class="fa fa-spin fa-spinner"></i> Clearing caches',closeButton:!1});let s=new Promise((o,l)=>{a.on("shown.bs.modal",()=>o())});try{await fetch(`${p}/api/settings/clear_caches`,{method:"POST",headers:{"Content-Type":"application/json"}}),await s,a.modal("hide"),x?.({props:{value:5e3,progressProps:{variant:"success"}},component:d(N,{variant:"success"},{default:()=>d("div",{style:"display: flex; align-items: center; gap: 16px"},[d("i",{class:"fa fa-check"}),d("span",null,"Caches cleared!")])})})}catch(o){await s,a.modal("hide"),bootbox.dialog({message:`<p>An error occurred</p><p>${o}</p>`,title:"Error"})}}const i=f(URLS),u=f(null);return y(async()=>{u.value=(await(await fetch(`${p}/api/scripts`)).json()).result}),(a,s)=>(c(),n(m,null,[$(C(E)),e("div",V,[e("div",D,[e("a",{href:i.value.release,class:"card bg-light",style:{height:"100%","text-decoration":"none","border-width":"2px 2px 4px 2px"}},[...s[1]||(s[1]=[e("div",{class:"section p-5 text-center fs-2 bg-light"},[e("i",{class:"fas fa-upload"})],-1),e("div",{class:"card-body"},[e("h4",null,"Release"),e("p",null," Start the release process and release a new version of ontologies ")],-1)])],8,F)]),e("div",L,[e("a",{href:i.value.rebuildIndex,class:"card bg-light",style:{height:"100%","text-decoration":"none","border-width":"2px 2px 4px 2px"}},[...s[2]||(s[2]=[e("div",{class:"section p-5 text-center fs-2 bg-light"},[e("i",{class:"fas fa-folder-open"})],-1),e("div",{class:"card-body"},[e("h4",null,"Rebuild index"),e("p",null," Force a complete rebuild of the index to ensure the search finds all entries. ")],-1)])],8,O)]),e("div",U,[e("a",{class:"card bg-light",href:"#",style:{height:"100%","text-decoration":"none","border-width":"2px 2px 4px 2px"},onClick:s[0]||(s[0]=o=>w())},[...s[3]||(s[3]=[e("div",{class:"section p-5 text-center fs-2 bg-light"},[e("i",{class:"fas fa-gauge-high"})],-1),e("div",{class:"card-body"},[e("h4",null,"Clear caches"),e("p",null," Clear cached files loaded from GitHub to ensure the latest version is used. ")],-1)])])]),"settings"in i.value?(c(),n("div",G,[e("a",{href:i.value.settings,class:"card bg-light",style:{height:"100%","text-decoration":"none","border-width":"2px 2px 4px 2px"}},[...s[4]||(s[4]=[e("div",{class:"section p-5 text-center fs-2 bg-light"},[e("i",{class:"fa-solid fa-gear"})],-1),e("div",{class:"card-body"},[e("h4",null,"Repositories"),e("p",null," Add, remove, or edit repositories available on the editor. ")],-1)])],8,H)])):S("",!0)]),e("div",I,[e("div",J,[s[6]||(s[6]=e("button",{"aria-expanded":"false",class:"btn btn-danger dropdown-toggle","data-bs-toggle":"dropdown",type:"button"}," Run a script ",-1)),e("ul",M,[(c(!0),n(m,null,T(u.value,(o,l)=>(c(),n("li",null,[e("a",{class:"dropdown-item",href:"#",onClick:r=>v(l)},[s[5]||(s[5]=e("i",{class:"fa-regular fa-circle-play text-success"},null,-1)),k(" "+B(o.title),1)],8,q)]))),256))])])])],64))}}),b=P(z);b.config.globalProperties.$filters=R;b.mount("#vue-app-dashboard");
//# sourceMappingURL=admin.js.map
