Files
twofauth-rs/public/build/assets/AccessLogViewer-D5ke4CwJ.js
T
wt cf25e28c28
Rust verification / test (push) Successful in 4m10s
initial commit
2026-10-28 15:59:54 +07:00

2 lines
4.9 KiB
JavaScript

import{C as j,M as z,e as p,o as P,a1 as X,f as A,h as l,l as h,d as r,D as H,j as e,X as J,k as B,m as s,n as i,t as a,i as v,F as N,E as R,w as y,p as w,B as q}from"./app-dvJP63FL.js";import{U as G}from"./index-BJsmINgd.js";import{C as K,a as Q,S as W,T as Z,M as tt}from"./tablet-DYUfDfjC.js";import{X as et}from"./x-DQVIq0xP.js";import{C as st}from"./check-CPGWPXZa.js";const ot={key:1,class:"level is-mobile mb-2"},nt={class:"level-item has-text-centered"},lt={class:"buttons"},at=["title"],rt=["title"],it=["title"],dt=["title"],ct=["title"],ht=["title"],ut={key:3,class:"mt-4"},gt={key:4},_t={class:"light-or-darker"},pt={class:"light-or-darker"},yt={class:"light-or-darker"},mt={class:"light-or-darker"},bt={class:"light-or-darker"},kt={class:"light-or-darker"},ft={class:"light-or-darker"},vt={class:"log-icon-wrapper"},wt={key:5,class:"mt-5 pl-3"},At={__name:"AccessLogViewer",props:{userId:[Number,String],lastOnly:Boolean,showSearch:Boolean,period:{type:[Number,String],default:12}},emits:["has-more-entries"],setup(D,{emit:Y}){const L=j(),O=z("2fauth"),u=D,d={aMonth:1,threeMonths:3,halfYear:6,aYear:12},c=p([]),f=p(!1),m=p(""),g=p(u.period),_=p(!0),V=Y,S=q(()=>c.value.filter(t=>JSON.stringify(t).toString().toLowerCase().includes(m.value)));P(()=>{M()});function b(t){g.value=t,M()}function E(){_.value=!1,$()}function $(){c.value.sort((t,n)=>t.id>n.id?1:-1)}function F(){_.value=!0,C()}function C(){c.value.sort((t,n)=>t.id<n.id?1:-1)}function M(){f.value=!0;let t=u.lastOnly?4:!1;X.getauthentications(u.userId,g.value,t,{returnError:!0}).then(n=>{c.value=n.data,c.value.length>3&&u.lastOnly&&(V("has-more-entries"),c.value.pop()),_.value==!0?C():$()}).catch(n=>{L.show(n)}).finally(()=>{f.value=!1})}const I=t=>!t.login_at&&t.logout_at,x=t=>!t.login_successful&&!t.logout_at;return(t,n)=>{const T=A("Spinner"),k=A("i18n-t");return l(),h(N,null,[u.showSearch?(l(),r(e(J),{key:0,keyword:e(m),"onUpdate:keyword":n[0]||(n[0]=o=>H(m)?m.value=o:null),hasNoBackground:!0},null,8,["keyword"])):B("",!0),u.showSearch?(l(),h("nav",ot,[s("div",nt,[s("div",lt,[s("button",{id:"btnShowOneMonth",title:t.$t("tooltip.show_last_month_log"),onClick:n[1]||(n[1]=o=>b(d.aMonth)),class:i([{"has-text-grey":e(g)!==d.aMonth},"button is-ghost p-1"]),type:"button"},a(t.$t("label.one_month")),11,at),s("button",{id:"btnShowThreeMonths",title:t.$t("tooltip.show_three_months_log"),onClick:n[2]||(n[2]=o=>b(d.threeMonths)),class:i([{"has-text-grey":e(g)!==d.threeMonths},"button is-ghost p-1"]),type:"button"},a(t.$t("label.x_month",{x:"3"})),11,rt),s("button",{id:"btnShowSixMonths",title:t.$t("tooltip.show_six_months_log"),onClick:n[3]||(n[3]=o=>b(d.halfYear)),class:i([{"has-text-grey":e(g)!==d.halfYear},"button is-ghost p-1"]),type:"button"},a(t.$t("label.x_month",{x:"6"})),11,it),s("button",{id:"btnShowOneYear",title:t.$t("tooltip.show_one_year_log"),onClick:n[4]||(n[4]=o=>b(d.aYear)),class:i([{"has-text-grey":e(g)!==d.aYear},"button is-ghost p-1 mr-5"]),type:"button"},a(t.$t("label.one_year")),11,dt),s("button",{id:"btnSortLogDesc",onClick:F,title:t.$t("tooltip.sort_by_date_desc"),class:i([{"has-text-grey":!e(_)},"button p-1 is-ghost"]),type:"button"},[v(e(K))],10,ct),s("button",{id:"btnSortLogAsc",onClick:E,title:t.$t("tooltip.sort_by_date_asc"),class:i([{"has-text-grey":e(_)},"button p-1 is-ghost"]),type:"button"},[v(e(Q))],10,ht)])])])):B("",!0),e(f)?(l(),r(T,{key:2,isVisible:!0,type:"list-loading"})):e(c).length==0?(l(),h("div",ut,a(t.$t("message.no_entry_yet")),1)):e(S).length>0?(l(),h("div",gt,[(l(!0),h(N,null,R(e(S),o=>(l(),h("div",{key:o.id,class:"list-item is-size-6 is-size-7-mobile has-text-grey is-flex is-justify-content-space-between"},[v(e(G),null,{default:y(({mode:U})=>[s("div",null,[s("div",null,[x(o)?(l(),r(k,{key:0,keypath:"message.failed_login_on",tag:"span"},{login_at:y(()=>[s("span",_t,a(o.login_at),1)]),_:2},1024)):I(o)?(l(),r(k,{key:1,keypath:"message.successful_logout_on",tag:"span"},{logout_at:y(()=>[s("span",pt,a(o.logout_at),1)]),_:2},1024)):e(O).config.proxyAuth?(l(),r(k,{key:2,keypath:"message.viewed_on",tag:"span"},{login_at:y(()=>[s("span",yt,a(o.login_at),1)]),_:2},1024)):(l(),r(k,{key:3,keypath:"message.successful_login_on",tag:"span"},{login_at:y(()=>[s("span",mt,a(o.login_at),1)]),_:2},1024))]),s("div",null,[w(a(t.$t("label.IP"))+": ",1),s("span",bt,a(o.ip_address),1),w(" - "+a(t.$t("label.browser"))+": ",1),s("span",kt,a(o.browser),1),w(" - "+a(t.$t("label.operating_system_short"))+": ",1),s("span",ft,a(o.platform),1)])]),s("div",{class:i([U=="dark"?"has-text-grey-darker":"has-text-grey-lighter","is-align-self-center"])},[s("div",vt,[o.device=="phone"?(l(),r(e(W),{key:0,class:"log-icon-bg"})):o.device=="tablet"?(l(),r(e(Z),{key:1,class:"log-icon-bg"})):(l(),r(e(tt),{key:2,class:"log-icon-bg"})),x(o)?(l(),r(e(et),{key:3,"stroke-width":"3",class:i(["log-icon-mark","has-text-danger"])})):(l(),r(e(st),{key:4,"stroke-width":"3",class:i(["log-icon-mark","has-text-success-50"])}))])],2)]),_:2},1024)]))),128))])):(l(),h("div",wt,a(t.$t("message.no_result")),1))],64)}}};export{At as _};