import{Q as K}from"./QPage-DjgmKzZ_.js";import{u as M}from"./use-meta-Drr87NGw.js";import{u as B}from"./use-quasar-CxlsMA-r.js";import{u as U,Q as $}from"./QItemLabel-BRceraJL.js";import{a as w,r as o,o as S,w as Q,a2 as _,a3 as k,a6 as n,a7 as l,a8 as x,ad as f,a5 as r,K as V,a9 as P,a4 as q,av as z,aK as L,ag as R,aq as E,e as H,ab as O}from"./index-D6xcdmSy.js";import{a as W,b as j}from"./rtl-BJcSdsPV.js";import{Q as J,a as X,b as Y}from"./QTable-mJIsuc0j.js";import{e as Z,g as ee,p as ae}from"./axios-B_9szzRp.js";import{u as te}from"./language-BmNUDO97.js";import{u as ne}from"./vue-i18n.runtime-BS3IaizX.js";const oe={class:"q-pa-md"},se={key:0},le={key:1},ie={__name:"API",setup(D){const{t:i}=ne(),t=B(),c=U(),y=te(),b=w(()=>[{name:"method",required:!0,label:"Method",align:"left",field:"method"},{name:"api",label:"API",field:"api"},{name:"func_name",label:"Function Name",field:"func_name"},{name:"name",label:"Name",field:"name"},{name:"action",label:i("action"),align:"right"}]),g=w(()=>c.token),m=o([]),A=o([]),v=o(""),h=o(0),d=o({sortBy:"updated_time",descending:!1,page:1,rowsPerPage:30,rowsNumber:30}),C=w(()=>g.value!==""?Math.ceil(h.value/d.value.rowsPerPage):0),N=o(`${t.screen.height*.73}px`),T=o(`${t.screen.width*.825}px`),I=o(t.dark.isActive?"#121212":"#ffffff");function u(s){let e={};s?e=s:e.pagination=d.value,c.tokenDataGet.admin&&(ee({url:"core/api/",params:{search:v.value,page:e.pagination.page,max_page:e.pagination.rowsPerPage}}).then(a=>{m.value=a.results,h.value=a.count,A.value=a.permission}).catch(a=>{t.notify({type:"error",message:a}),t.loading.hide()}),d.value=e.pagination)}function F(s){t.dialog({dark:t.dark.isActive,title:"Change API Function Name",prompt:{model:"",isValid:e=>e.length>2,type:"text"},cancel:!0}).onOk(async e=>{await ae("core/api/change/",{id:m.value[s].id,func_name:e}).then(()=>{u()}).catch(a=>{t.notify({type:"error",message:a}),t.loading.hide()})})}S(()=>{G(),u()}),Q(()=>t.dark.isActive,s=>{I.value=s?"#121212":"#ffffff"});function G(){Z.on("needLogin",s=>{s&&(m.value=[],A.value=[],v.value="",h.value=0)})}return Q(()=>y.langData,s=>{s&&u()}),(s,e)=>(k(),_("div",oe,[n(Y,{class:E(r(t).dark.isActive?"my-sticky-header-last-column-table-dark":"my-sticky-header-last-column-table"),flat:"",bordered:"",rows:m.value,columns:b.value,"row-key":"index",pagination:d.value,"onUpdate:pagination":e[6]||(e[6]=a=>d.value=a),separator:"cell","no-data-label":r(i)("nodata"),"rows-per-page-label":r(i)("per_page"),"rows-per-page-options":[1,30,50,200,1e3],"table-style":{height:N.value,width:T.value},"card-style":{backgroundColor:I.value},onRequest:u},{top:l(a=>[n(W,{flat:""},{default:l(()=>[V(n(P,{label:r(i)("refresh"),icon:"refresh",onClick:e[0]||(e[0]=p=>u())},{default:l(()=>[n($,{class:"bg-indigo",offset:[10,10],"content-style":"font-size: 12px"},{default:l(()=>[x(f(r(i)("refreshdata")),1)]),_:1})]),_:1},8,["label"]),[[q,r(c).tokenDataGet.admin]])]),_:1}),n(j),n(z,{dense:"",debounce:"300",color:"primary",modelValue:v.value,"onUpdate:modelValue":e[1]||(e[1]=p=>v.value=p),onInput:e[2]||(e[2]=p=>u()),onKeyup:e[3]||(e[3]=L(p=>u(),["enter"]))},{append:l(()=>[n(R,{name:"search"})]),_:1},8,["modelValue"]),n(P,{flat:"",round:"",dense:"",icon:a.inFullscreen?"fullscreen_exit":"fullscreen",onClick:a.toggleFullscreen},null,8,["icon","onClick"])]),"body-cell":l(a=>[n(X,{props:a},{default:l(()=>[a.col.name==="action"?(k(),_("div",se,[V(n(P,{round:"",flat:"",icon:"edit",onClick:p=>F(a.rowIndex)},{default:l(()=>[n($,{class:"bg-indigo",offset:[10,10],"content-style":"font-size: 12px"},{default:l(()=>e[7]||(e[7]=[x("Change API")])),_:1,__:[7]})]),_:2},1032,["onClick"]),[[q,r(c).tokenDataGet.admin]])])):(k(),_("div",le,f(a.value),1))]),_:2},1032,["props"])]),pagination:l(()=>[x(f(r(i)("total"))+f(C.value)+" "+f(r(i)("page"))+" ",1),n(J,{modelValue:d.value.page,"onUpdate:modelValue":[e[4]||(e[4]=a=>d.value.page=a),e[5]||(e[5]=a=>u())],max:C.value,input:"","input-class":"text-orange-10"},null,8,["modelValue","max"])]),_:1},8,["class","rows","columns","pagination","no-data-label","rows-per-page-label","table-style","card-style"])]))}},ye={__name:"APIReader",setup(D){const i=B(),t=o(!1),c=o(""),y=o(""),b=o("");return M(()=>({title:c.value,meta:{description:{name:"description",content:y.value},keywords:{name:"keywords",content:b.value}}})),S(()=>{}),H(()=>{}),Q(()=>i.dark.isActive,g=>{t.value=g}),(g,m)=>(k(),O(K,{class:"flex flex-top"},{default:l(()=>[n(ie)]),_:1}))}};export{ye as default};
