2FAuth/public/build/assets/Users-Bxf3ihka.js
2024-11-17 23:37:23 +01:00

2 lines
4.3 KiB
JavaScript
Vendored

import{_ as j}from"./AdminTabs-Bc7uXBY-.js";import{a as I,a1 as N,r as b,x as $,o as S,I as T,a0 as E,d as u,j as n,e as t,k as h,L as R,l as p,m,t as i,g as B,f as r,D as O,F as W,E as D,U as F,n as y,i as x}from"./app-D4Udf6Mm.js";import{S as M}from"./Spinner-DHClvaFf.js";import{_ as Z}from"./SearchBox-B-38rGG5.js";/*! 2FAuth version 5.4.1 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const q={class:"options-tabs"},G={class:"title is-4 has-text-grey-light"},H={class:"is-size-7-mobile"},J={class:"mb-6 mt-3"},K={class:"columns"},P={class:"column pb-0"},Q={class:"level is-mobile mb-0"},X={class:"level-item has-text-centered is-justify-content-end"},Y={class:"subtitle is-7"},ee={class:"level-item has-text-centered is-justify-content-start"},se={class:"buttons"},te={key:0},ae={class:"has-ellipsis"},oe={class:"is-block has-ellipsis is-family-primary is-size-6 is-size-7-mobile has-text-grey"},ne={class:"tags mt-2"},ie={class:"ml-3"},le={key:1,class:"mt-4 pl-3"},he={__name:"Users",setup(re){const A=R("2fauth"),w=I(),L=N(A.prefix+"returnTo","accounts"),f=b([]),a=b(""),g=b(!1),C=$(()=>f.value.filter(e=>{let s=e.name.toLowerCase().includes(d.value.keywords)||e.email.toLowerCase().includes(d.value.keywords);return d.value.admin!=null&&(s=s&&e.is_admin==d.value.admin),d.value.oauth!=null&&(s=s&&e.oauth_provider==d.value.oauth),s})),d=$(()=>{const e={admin:void 0,oauth:void 0,keywords:a.value.toLowerCase()},s=a.value.toLowerCase().split(" "),c=/admin:([01])/,_=/oauth:([a-zA-Z0-9])/;return s.forEach(l=>{l.match(c)&&(e.admin=parseInt(l.replace(c,"$1")),e.keywords=e.keywords.replace(l,"").trim()),l.match(_)&&(e.oauth=l.replace(_,"$1"),e.keywords=e.keywords.replace(l,"").trim())}),e});S(()=>{z()});function k(e){const s=/admin:([01])/,c=/oauth:([a-zA-Z0-9]*)/;a.value.match(s)&&e.match(s)?a.value=a.value.replace(s,e):d.value.oauth!=null&&e.match(c)?a.value=a.value.replace(c,e):a.value=a.value?a.value+" "+e:e}function z(){g.value=!0,T.getAll({returnError:!0}).then(e=>{f.value=e.data}).catch(e=>{w.error(e)}).finally(()=>{g.value=!1})}return E(e=>{e.name.startsWith("admin.")||w.clear()}),(e,s)=>{const c=p("FontAwesomeIcon"),_=p("RouterLink"),l=p("ButtonBackCloseCancel"),U=p("VueFooter"),V=p("FormWrapper");return m(),u("div",null,[n(j,{activeTab:"admin.users"}),t("div",q,[n(V,null,{default:h(()=>[t("h4",G,i(e.$t("admin.users")),1),t("div",H,i(e.$t("admin.users_legend")),1),t("div",J,[n(_,{class:"is-link mt-5",to:{name:"admin.createUser"}},{default:h(()=>[n(c,{icon:["fas","plus-circle"]}),B(" "+i(e.$t("admin.create_new_user")),1)]),_:1},8,["to"])]),t("div",K,[t("div",P,[n(Z,{keyword:r(a),"onUpdate:keyword":s[0]||(s[0]=o=>O(a)?a.value=o:null),hasNoBackground:!0,placeholder:e.$t("admin.search_user_placeholder")},null,8,["keyword","placeholder"])])]),t("div",Q,[t("div",X,[t("p",Y,i(e.$t("admin.quick_filters_colons")),1)]),t("div",ee,[t("div",se,[t("button",{class:"button is-small is-ghost p-0",onClick:s[1]||(s[1]=o=>k("admin:1"))},"admin"),t("button",{class:"button is-small is-ghost p-0",onClick:s[2]||(s[2]=o=>k("oauth:github"))},"github"),t("button",{class:"button is-small is-ghost p-0",onClick:s[3]||(s[3]=o=>k("oauth:openid"))},"openId")])])]),r(C).length>0?(m(),u("div",te,[(m(!0),u(W,null,D(r(C),o=>(m(),u("div",{key:o.id,class:"list-item is-size-5 is-size-6-mobile is-flex is-justify-content-space-between"},[t("div",ae,[t("span",null,i(o.name),1),t("span",oe,i(o.email),1),n(r(F),null,{default:h(({mode:v})=>[t("div",ne,[o.is_admin?(m(),u("span",{key:0,class:y(["tag is-rounded has-text-warning-dark",v=="dark"?"has-background-black-bis":"has-background-grey-lighter"])},"admin",2)):x("",!0),o.oauth_provider?(m(),u("span",{key:1,class:y(["tag is-rounded has-text-grey",v=="dark"?"has-background-black-bis":"has-background-grey-lighter"])},"oauth: "+i(o.oauth_provider),3)):x("",!0)])]),_:2},1024)]),t("div",ie,[n(r(F),null,{default:h(({mode:v})=>[n(_,{to:{name:"admin.manageUser",params:{userId:o.id}},class:y(["button is-small has-normal-radius",{"is-dark":v=="dark"}]),title:e.$t("commons.manage")},{default:h(()=>[B(i(e.$t("commons.manage")),1)]),_:2},1032,["to","class","title"])]),_:2},1024)])]))),128))])):(m(),u("div",le,i(e.$t("commons.no_result")),1)),n(M,{isVisible:r(g)&&r(f).length===0},null,8,["isVisible"]),n(U,{showButtons:!0},{default:h(()=>[n(l,{returnTo:{name:r(L)},action:"close"},null,8,["returnTo"])]),_:1})]),_:1})])])}}};export{he as default};