import{t as e}from"./axios-m7YkukvY.js";import{A as t,L as n,N as r,St as i,W as a,_ as o,at as s,c,et as l,h as u,l as d,m as f,s as p}from"./runtime-core.esm-bundler-Babufkcf.js";import{t as m}from"./QIcon-cTVL6ikA.js";import{t as h}from"./QChip-Bsee2q-S.js";import{t as g}from"./QTd-mJJNUD6x.js";import{t as _}from"./QPage-eKZDij2L.js";var v={class:`row my_radio_less q-pa-sm`},y={class:`col-12`},b={class:`col-12 q-mt-sm`},x={class:`col-6 col-sm-3`},S={class:`col-6 col-sm-3`},C={class:`col-12`},w={class:`col-12 q-mt-xs text-caption text-grey-6`},T={__name:`LogPage`,setup(T){let{proxy:E}=o(),D=l([]),O=l(!1),k=l(null),A=l(null),j=l(``),M=p(()=>[{label:E.$t(`Created`),value:`created`},{label:E.$t(`Updated`),value:`updated`},{label:E.$t(`Deleted`),value:`deleted`}]),N=p(()=>[...new Set(D.value.map(e=>e.module).filter(Boolean))].map(e=>({label:e,value:e}))),P=p(()=>{let e=D.value;return k.value&&(e=e.filter(e=>e.action===k.value)),A.value&&(e=e.filter(e=>e.module===A.value)),e}),F=[{name:`created_at`,label:`#`,field:`id`,align:`left`},{name:`action`,label:`Action`,field:`action`,align:`left`,sortable:!0},{name:`module`,label:`Module`,field:`module`,align:`left`,sortable:!0},{name:`description`,label:`Description`,field:`description`,align:`left`},{name:`user`,label:`User`,field:e=>e.user?.name??`—`,align:`left`,sortable:!0},{name:`time`,label:`Time`,field:e=>e.created_at_human??e.created_at?.slice(0,16),align:`left`,sortable:!0}],I=F;function L(e){return{created:`positive`,updated:`warning`,deleted:`negative`}[e]??`grey`}function R(e){return{User:`manage_accounts`,Role:`rule`,Branch:`store`,Company:`business`,Settings:`settings`,Project:`domain`,Site:`place`,Task:`checklist`,Milestone:`flag`,DailyLog:`assignment`,Subcontractor:`engineering`,SubPayment:`payments`,Document:`folder`,Currency:`payments`,ExchangeRate:`currency_exchange`,Expense:`receipt_long`,Invoice:`request_quote`,Receipt:`payments`,Asset:`construction`,Department:`apartment`,Designation:`badge`,Employee:`groups`,Investor:`diversity_3`,Investment:`account_balance`,Contract:`assignment_turned_in`,Treasury:`savings`,Party:`account_balance_wallet`,Supplier:`local_shipping`,Stock:`inventory`,PurchaseOrder:`shopping_cart`}[e]??`circle`}async function z(){O.value=!0;try{let{data:t}=await e.get(`/activity-logs`);D.value=Array.isArray(t)?t:[]}catch{}finally{O.value=!1}}return t(z),(e,t)=>{let o=n(`m-header`),l=n(`table-stats`),p=n(`s-select`),T=n(`progress-btn`),E=n(`action-bar`),B=n(`n-table`),V=n(`m-backgrounds`);return r(),d(_,null,{default:a(()=>[u(V,null,{default:a(()=>[c(`div`,v,[c(`div`,y,[u(o,{icon:`manage_search`,controlRoomButton:`false`,class:`q-mt-xs`},{default:a(()=>[f(i(e.$t(`Log`)),1)]),_:1})]),c(`div`,b,[u(l,{rows:P.value,"total-label":e.$t(`TotalLogEntries`),"total-icon":`manage_search`,breakdown:[{field:`action`,max:4,icon:`bolt`},{field:`module`,max:3,icon:`widgets`}]},null,8,[`rows`,`total-label`])]),u(E,{rows:P.value,columns:s(I),filename:`activity-log`,"has-date":``,"date-field":`created_at`,"onUpdate:filtered":()=>{}},{filters:a(()=>[c(`div`,x,[u(p,{outlined:``,dense:``,color:`blue-grey-9`,"label-color":`blue-grey-9`,modelValue:k.value,"onUpdate:modelValue":t[0]||=e=>k.value=e,options:M.value,"emit-value":``,"map-options":``,clearable:``,label:e.$t(`Action`)},null,8,[`modelValue`,`options`,`label`])]),c(`div`,S,[u(p,{outlined:``,dense:``,color:`blue-grey-9`,"label-color":`blue-grey-9`,modelValue:A.value,"onUpdate:modelValue":t[1]||=e=>A.value=e,options:N.value,"emit-value":``,"map-options":``,clearable:``,label:e.$t(`Module`)},null,8,[`modelValue`,`options`,`label`])])]),"extra-buttons":a(()=>[u(T,{color:`primary`,icon:`refresh`,onClick:z},{default:a(()=>[f(i(e.$t(`Load`)),1)]),_:1})]),_:1},8,[`rows`,`columns`]),c(`div`,C,[u(B,{"config-key":`page.log`,loading:O.value,data:P.value,columns:F,filter:j.value,"onUpdate:filter":t[2]||=e=>j.value=e,noInfo:!0,noEdit:!0,noDelete:!0},{"body-cell-action":a(e=>[u(g,{props:e},{default:a(()=>[u(h,{dense:``,size:`sm`,color:L(e.row.action),"text-color":`white`,class:`q-ma-none`},{default:a(()=>[f(i(e.row.action),1)]),_:2},1032,[`color`])]),_:2},1032,[`props`])]),"body-cell-module":a(e=>[u(g,{props:e},{default:a(()=>[u(h,{dense:``,size:`sm`,color:`grey-3`,"text-color":`grey-8`,class:`q-ma-none`},{default:a(()=>[u(m,{name:R(e.row.module),size:`12px`,class:`q-mr-xs`},null,8,[`name`]),f(i(e.row.module),1)]),_:2},1024)]),_:2},1032,[`props`])]),_:1},8,[`loading`,`data`,`filter`])]),c(`div`,w,` Showing `+i(P.value.length)+` of `+i(D.value.length)+` entries `,1)])]),_:1})]),_:1})}}};export{T as default};