@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
2 lines (1 loc) • 4.32 kB
JavaScript
import{e as oe}from"./chunk-7VRYTDX4.js";import{b as ne}from"./chunk-6WMXMIE4.js";import{s as d,u as se,v as I}from"./chunk-B6HQYQYG.js";import{$a as te,A as R,C as A,D as W,F as v,fb as ie,ka as E,la as u,ma as K,na as f,oa as Q,pa as a,qa as X,ra as Y,sa as Z,ta as ee,tb as re}from"./chunk-O3YLAEVE.js";import{d as H}from"./chunk-QHJT5H4M.js";import{Bb as D,Eb as k,Ed as V,G as w,Gb as g,Jd as q,Kd as z,Oa as S,Qa as O,Tb as U,Vb as L,Yc as F,ab as C,ea as P,ja as c,kc as $,lc as B,mc as j,nb as N,oa as x,pa as T,pb as b,qb as G,rb as y,sb as _,tb as l,v as o}from"./chunk-D55YR5X7.js";import{n as J}from"./chunk-DM4NXKEP.js";var m=class{constructor(i){this.isAdmin=!1,this.newly=0,this.applications=[],this.currentAccessHover=!1,this.setGroups(i),this.setManagers(i),Object.assign(this,i),this.isAdmin=i.role===R.ADMINISTRATOR,this.userRoleText=ie(R[i.role]),this.avatarUrl=re(i.login),this.userIsActiveText=this.isActive?"active":"suspended",this.hTimeAgo=J(this.currentAccess).fromNow(!0),this.newly=te(this.currentAccess),this.permissions&&(this.applications=this.permissions.split(A))}setGroups(i){i?.groups&&(i.groups=i.groups.map(p=>new d(p)))}setManagers(i){i?.managers&&(i.managers=i.managers.map(p=>new d(p)))}};var h=class{constructor(i){Object.assign(this,i),this.permissions&&(this.applications=this.permissions.split(A))}};var Te=(()=>{let i=class i{constructor(){this.http=c(F),this.router=c(H),this.authService=c(ne)}listUsers(e=!1){return this.http.get(e?Q:K).pipe(o(t=>t.map(r=>new m(r))))}getUser(e,t=!1){return this.http.get(`${t?f:u}/${e}`).pipe(o(r=>t?new I(r):new m(r)))}createUser(e,t,r=!1){return this.http.post(r?f:u,e,{headers:t}).pipe(o(n=>r?new I(n):new m(n)))}updateUser(e,t,r,n=!1){return this.http.put(`${n?f:u}/${e}`,t,{headers:r}).pipe(o(M=>n?new I(M):new m(M)))}deleteUser(e,t,r){return this.http.request("delete",`${t.isGuest?f:u}/${e}`,{headers:r,body:t})}browseGroup(e,t=!1){return this.http.get(`${t?Y:X}${e?`/${e}`:""}`).pipe(o(r=>new se(r)))}getGroup(e){return this.http.get(`${a}/${e}`).pipe(o(t=>new h(t)))}createGroup(e){return this.http.post(a,e).pipe(o(t=>new h(t)))}updateGroup(e,t){return this.http.put(`${a}/${e}`,t).pipe(o(r=>new h(r)))}deleteGroup(e){return this.http.delete(`${a}/${e}`)}addUsersToGroup(e,t){return this.http.patch(`${a}/${e}/${E.USERS}`,t)}updateUserFromGroup(e,t,r){return this.http.patch(`${a}/${e}/${E.USERS}/${t}`,r)}removeUserFromGroup(e,t){return this.http.delete(`${a}/${e}/${E.USERS}/${t}`)}searchMembers(e,t=!1){return this.http.request("search",Z,{body:e}).pipe(o(r=>r.map(n=>(t&&delete n.description,new d(n)))),w(()=>[]))}impersonateUser(e,t){return this.http.post(`${ee}/${e}`,null,{headers:t})}initImpersonateUser(e){this.authService.initUserFromResponse(e,!0),this.router.navigate([v.BASE,v.ACCOUNT]).catch(console.error)}};i.\u0275fac=function(t){return new(t||i)},i.\u0275prov=P({token:i,factory:i.\u0275fac,providedIn:"root"});let s=i;return s})();function ae(s,i){if(s&1){let p=D();_(0,"div",3)(1,"label",4)(2,"input",5),k("change",function(t){let r=x(p).$implicit,n=g();return T(n.updatePermissions(r,t))}),l(),U(3),$(4,"translate"),$(5,"capitalize"),l()()}if(s&2){let p=i.$implicit,e=g();S(2),y("checked",e.permissions.indexOf(p)>-1)("value",p),S(),L(" ",B(5,6,j(4,3,p,e.locale.language))," ")}}var Le=(()=>{let i=class i{constructor(){this.permissions=[],this.permissionsChange=new O,this.locale=c(V),this.allApplications=Object.values(W)}updatePermissions(e,t){t.target.checked?this.permissions.push(e):this.permissions.splice(this.permissions.indexOf(e),1),this.permissionsChange.emit(this.permissions)}};i.\u0275fac=function(t){return new(t||i)},i.\u0275cmp=C({type:i,selectors:[["app-admin-permissions"]],inputs:{permissions:"permissions"},outputs:{permissionsChange:"permissionsChange"},decls:6,vars:0,consts:[[1,"d-flex","flex-column","col-12","pb-3"],["for","permissions","l10nTranslate",""],["id","permissions",1,"form-check","form-switch","form-check-inline"],[1,"d-flex"],[1,"form-check-label"],["type","checkbox",1,"form-check-input",3,"change","checked","value"]],template:function(t,r){t&1&&(_(0,"div",0)(1,"label",1),U(2,"Permissions"),l(),_(3,"div",2),b(4,ae,6,8,"div",3,N),l()()),t&2&&(S(4),G(r.allApplications))},dependencies:[z,oe,q],encapsulation:2});let s=i;return s})();export{m as a,Te as b,Le as c};