import{_ as f,ax as b,M as w,c as _,a as n,w as r,Z as v,ay as y,r as $,o as g,$ as u,K as l,aj as k,N as m,a1 as L,Q as R}from"./app-DzAYC6xy.js";import{Q as S,a as d}from"./QTable-98FMMxUQ.js";import{Q as q}from"./QTr-BZRxhYsi.js";import"./externalHosting.js";import"./QList-ClLOsgaS.js";import"./QMarkupTable-z27wCkH-.js";import"./QSelect-CKpWbBmC.js";import"./QChip-BlQVc6fr.js";import"./QItemLabel-DrLwH6Mx.js";import"./position-engine-BoHh6ymb.js";import"./selection-vu7NfHfB.js";import"./rtl-DFPa-2ov.js";import"./use-fullscreen-Bv2HJD5x.js";const C={name:"AccountList",data(){return{columns:[{name:"name",align:"left",label:this.$i18n.t("components.accountList.headers.name"),field:t=>t.name,format:t=>`${t}`,sortable:!0},{name:"license",align:"left",label:this.$i18n.t("components.accountList.headers.license"),field:t=>t.license,format:t=>`${t}`,sortable:!0},{name:"character_count",align:"center",label:this.$i18n.t("components.accountList.headers.character_count"),field:t=>t.character_count,format:t=>`${t}`,sortable:!0},{name:"last_active",align:"center",label:this.$i18n.t("components.accountList.headers.last_active"),field:t=>t.last_active,format:t=>`${t}`,sortable:!0}],accounts:[],pagination:{sortBy:"name",descending:!1,page:1,rowsPerPage:0,rowsNumber:0},loading:!0}},methods:{getRowsNumberCount(t){return this.$axios.post("/api/accounts/account-count",{filter:t}).then(a=>a.data.count)},fetchFromServer(t,a,s,c,o){return this.$axios.post("/api/accounts",{startRow:t,count:a,filter:s,sortBy:c,descending:o}).then(i=>i.data.accounts||[]).catch(i=>{this.loading=!1,this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("general.timeout")})}).finally(()=>this.loading=!1)},async onRequest(t){const{page:a,rowsPerPage:s,sortBy:c,descending:o}=t.pagination,i=t.filter;this.loading=!0,this.pagination.rowsNumber=await this.getRowsNumberCount(i);const p=s===0?this.pagination.rowsNumber:s,e=(a-1)*s,h=await this.fetchFromServer(e,p,i,c,o);this.accounts.splice(0,this.accounts.length,...h),this.pagination.page=a,this.pagination.rowsPerPage=s,this.pagination.sortBy=c,this.pagination.descending=o,this.paginationSave=this.pagination,this.loading=!1},onRowClick(t){this.$router.push({name:"game-account-detail",params:{license:t.license}})},getPaginationLabel(t,a,s){return this.$i18n.t("components.accountList.paginationLabel",{from:t,to:a,total:s})},updatePagination(t){this.loading||(this.paginationSave=t,this.pagination=t)}},computed:{...b(y,["searchFilter","paginationSave"])},mounted(){this.$route.name==="game-account-list"&&(this.pagination={...this.paginationSave},this.$refs.tableRef.requestServerInteraction())}},Q={key:0,class:"row q-pa-sm"},N={class:"row"},P={class:"col-12"},x={class:"q-mx-md q-my-sm row"},B={class:"text-caption text-sub"};function F(t,a,s,c,o,i){const p=$("router-view");return t.$route.name==="game-account-list"?(g(),w("div",Q,[n(v,{class:"account-list-card full-width"},{default:r(()=>[u("div",N,[u("div",P,[u("div",x,[u("div",B,l(t.$t("components.accountList.subheader")),1)]),n(k),n(S,{ref:"tableRef",color:"primary","card-class":"account-list-card text-main","table-class":"account-list-table","table-header-class":"account-list-table-header text-main",flat:"",style:{"max-height":"70vh"},rows:o.accounts,columns:o.columns,"row-key":"name",pagination:o.pagination,"onUpdate:pagination":[a[1]||(a[1]=e=>o.pagination=e),i.updatePagination],"no-results-label":t.$t("components.accountList.noData"),"loading-label":t.$t("components.accountList.loadData"),loading:o.loading,filter:t.searchFilter,"binary-state-sort":"",onRequest:i.onRequest},{"top-right":r(()=>[n(L,{"input-style":{color:"var(--q-main)"},borderless:"",dense:"",debounce:"300",modelValue:t.searchFilter,"onUpdate:modelValue":a[0]||(a[0]=e=>t.searchFilter=e),placeholder:t.$t("general.search")},{append:r(()=>[n(R,{class:"text-white search-icon",name:"search"})]),_:1},8,["modelValue","placeholder"])]),body:r(e=>[n(q,{props:e,onClick:h=>i.onRowClick(e.row),class:"cursor-pointer"},{default:r(()=>[n(d,{key:"name",props:e},{default:r(()=>[m(l(e.row.name),1)]),_:2},1032,["props"]),n(d,{key:"license",props:e},{default:r(()=>[m(l(e.row.license),1)]),_:2},1032,["props"]),n(d,{key:"character_count",props:e},{default:r(()=>[m(l(e.row.character_count),1)]),_:2},1032,["props"]),n(d,{key:"last_active",props:e},{default:r(()=>[m(l(new Date(e.row.last_active*1e3).toLocaleString()),1)]),_:2},1032,["props"])]),_:2},1032,["props","onClick"])]),_:1},8,["rows","columns","pagination","no-results-label","loading-label","loading","filter","onRequest","onUpdate:pagination"])])])]),_:1})])):(g(),_(p,{key:1}))}const G=f(C,[["render",F],["__scopeId","data-v-30a694d1"]]);export{G as default};
