import{u as T,Q as z}from"./use-meta-V82asQQa.js";import{l as $,t as D,v as G}from"./QItemLabel-BBmtOiru.js";import{u as M,a as R,Q as P}from"./token-C_-JxJ5Q.js";import{a as b,r as s,o as S,w as y,Z as h,_ as w,a1 as e,a2 as l,C as B,a4 as m,a0 as c,a3 as _,a8 as g,$ as V,am as F,ac as K,aj as L,e as E,a6 as H}from"./index-BxiAnk4a.js";import{Q as O,a as W,b as Z}from"./QTable-SflwU_Su.js";import{get as J}from"./axios-P0fZ9nat.js";import{u as X}from"./vue-i18n.runtime-D3CRIBOQ.js";const Y={class:"q-pa-md"},ee={key:0},ae={key:1},te={__name:"UserList",setup(U){const{t}=X(),i=$(),v=M(),k=b(()=>[{name:"username",required:!0,label:t("username"),align:"left",field:"username",sortable:!0},{name:"email",align:"center",label:t("email"),field:"email",sortable:!0},{name:"date_joined",label:t("date_joined"),field:"date_joined",sortable:!0},{name:"last_login",label:t("last_login"),field:"last_login",sortable:!0},{name:"updated_time",label:t("updated_time"),field:"updated_time",sortable:!0},{name:"action",label:t("action"),align:"right"}]),p=s([]),d=s(""),r=s({sortBy:"username",descending:!0,page:1,rowsPerPage:1,rowsNumber:1}),j=b(()=>Q.value!==""?Math.ceil(p.value.length/r.value.rowsPerPage):0),q=s(i.screen.height*.73+"px"),A=s(i.screen.width*.825+"px"),x=s(i.dark.isActive?"#121212":"#ffffff"),Q=b(()=>v.token),I=b(()=>v.tokenDataGet);function f(n){Q.value!==""&&(J({url:"core/user/",params:{search:d.value,page:n.pagination.page,max_page:n.pagination.rowsPerPage,ordering:`-${n.pagination.sortBy}`}}).then(a=>{p.value=a.results}).catch(a=>(console.error(a),Promise.reject(a))),r.value=n.pagination)}function N(n){console.log("pageChange",n)}function C(n){let a=I.value.permissions;return!!Array.from(a).includes(n)}return S(()=>{f({pagination:r.value})}),y(()=>i.dark.isActive,n=>{x.value=n?"#121212":"#ffffff"}),y(()=>r.value,n=>{console.log("watch",n.sortBy)}),(n,a)=>(h(),w("div",Y,[e(Z,{class:L(c(i).dark.isActive?"my-sticky-header-last-column-table-dark":"my-sticky-header-last-column-table"),flat:"",bordered:"",rows:p.value,columns:k.value,"row-key":"name",pagination:r.value,separator:"cell","no-data-label":c(t)("nodata"),"rows-per-page-label":c(t)("per_page"),"rows-per-page-options":[1,10,30,50,200,0],"table-style":{height:q.value,width:A.value},"card-style":{backgroundColor:x.value},onRequest:f},{top:l(o=>[e(R,{flat:""},{default:l(()=>[B(e(m,{label:c(t)("refresh"),icon:"refresh",onClick:a[0]||(a[0]=u=>f({pagination:r.value}))},{default:l(()=>[e(P,{"content-class":"bg-indigo text-black shadow-4",offset:[10,10],"content-style":"font-size: 12px"},{default:l(()=>[_(g(c(t)("refresh")),1)]),_:1})]),_:1},8,["label"]),[[V,C("Get User List")]]),B(e(m,{label:c(t)("new"),icon:"add"},{default:l(()=>[e(P,{"content-class":"bg-indigo text-black shadow-4",offset:[10,10],"content-style":"font-size: 12px"},{default:l(()=>[_(g(c(t)("new")),1)]),_:1})]),_:1},8,["label"]),[[V,C("Create One User")]])]),_:1}),_(" "+g(j.value)+" ",1),e(D),e(G,{borderless:"",dense:"",debounce:"300",color:"primary",modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=u=>d.value=u),onInput:a[2]||(a[2]=u=>f({pagination:r.value})),onKeyup:a[3]||(a[3]=F(u=>f({pagination:r.value}),["enter"]))},{append:l(()=>[e(K,{name:"search"})]),_:1},8,["modelValue"]),e(m,{flat:"",round:"",dense:"",icon:o.inFullscreen?"fullscreen_exit":"fullscreen",onClick:o.toggleFullscreen},null,8,["icon","onClick"])]),"body-cell":l(o=>[e(O,{props:o},{default:l(()=>[o.col.name==="action"?(h(),w("div",ee,[e(m,{round:"",flat:"",icon:"admin_panel_settings"}),e(m,{round:"",flat:"",icon:"brush"}),e(m,{round:"",flat:"",icon:"delete_sweep"})])):(h(),w("div",ae,g(o.value),1))]),_:2},1032,["props"])]),pagination:l(o=>[_(g(o)+" ",1),e(W,{modelValue:o.pagination.page,"onUpdate:modelValue":[u=>o.pagination.page=u,u=>N(o)],max:o.pagesNumber,input:"","input-class":"text-orange-10"},null,8,["modelValue","onUpdate:modelValue","max"])]),_:1},8,["class","rows","columns","pagination","no-data-label","rows-per-page-label","table-style","card-style"])]))}},ce={__name:"UserReader",setup(U){const t=$(),i=s(!1),v=s(""),k=s(""),p=s("");return T(()=>({title:v.value,meta:{description:{name:"description",content:k.value},keywords:{name:"keywords",content:p.value}}})),S(()=>{}),E(()=>{}),y(()=>t.dark.isActive,d=>{i.value=d}),(d,r)=>(h(),H(z,{class:"flex flex-top"},{default:l(()=>[e(te)]),_:1}))}};export{ce as default};
