UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

8 lines (2 loc) 19.5 kB
import{f as _e,g as Ce}from"./chunk-FNFGUIQH.js";import{f as ge}from"./chunk-VPJ2V27B.js";import{Lb as fe,Qb as z,ua as me,wb as he}from"./chunk-4U5A2DEP.js";import{$b as Z,Cb as h,Dc as Y,Eb as c,Fa as E,Fd as ae,J as L,Jd as le,Lb as D,Ma as r,N as R,Nb as y,Ob as J,Pb as m,Qb as k,Re as pe,Tb as F,Ub as V,Vb as G,Xa as M,Xb as K,Xc as ee,Za as U,Zb as X,Zc as P,_c as te,ab as w,ac as $,ad as ie,ba as I,bb as x,bf as de,dc as A,ed as ne,fc as H,ha as O,hc as j,jb as f,jd as oe,kb as g,lb as q,ma as C,na as v,nb as B,ob as Q,of as ue,pb as d,pe as ce,qb as l,rb as a,sb as _,wd as se,xd as re,ya as W,yb as T,zb as b}from"./chunk-HW2H3ISM.js";var be=(function(i){return i[i.USER=0]="USER",i[i.PERSONAL=1]="PERSONAL",i})(be||{}),ye=(function(i){return i[i.VISIBLE=0]="VISIBLE",i[i.PRIVATE=1]="PRIVATE",i[i.ISOLATED=2]="ISOLATED",i})(ye||{});function ke(i,n){if(i&1&&(l(0,"span"),m(1),a()),i&2){let s=c();r(),k(s.group.name)}}function Se(i,n){i&1&&(l(0,"span",3),m(1,"New personal group"),a())}function Me(i,n){if(i&1&&_(0,"fa-icon",4),i&2){let s=c();d("icon",s.icons.faSpinner)}}function we(i,n){i&1&&(l(0,"span",3),m(1,"Edit personal group"),a())}function Pe(i,n){i&1&&(l(0,"span",3),m(1,"Edit group"),a())}function Ee(i,n){if(i&1&&(l(0,"h4",5),f(1,we,2,0,"span",3)(2,Pe,2,0,"span",3),a()),i&2){let s=c();r(),g(s.isPersonalGroup?1:2)}}var st=(()=>{let n=class n{constructor(){this.groupChange=new x,this.layout=O(he),this.icons={GROUPS:me.GROUPS,faSpinner:de,faCog:pe,faUsers:ce,faPen:ue},this.isPersonalGroup=!0,this.submitted=!1,this.loading=!1,this.userService=O(ge),this.user=this.userService.user}ngOnInit(){this.originalGroup?.id?(this.isPersonalGroup=this.originalGroup.isPersonalGroup,this.group=new z({id:this.originalGroup.id,name:this.originalGroup.name,description:this.originalGroup.description,createdAt:this.originalGroup.createdAt,modifiedAt:this.originalGroup.modifiedAt,type:this.originalGroup.type})):this.group=new z({id:0,name:"",description:"",createdAt:null,modifiedAt:null,type:fe.PGROUP})}onCancel(){this.layout.closeDialog()}onSubmit(){if(this.loading=!0,this.submitted=!0,this.group.id===0)this.userService.createPersonalGroup(this.makeDto(!0)).subscribe({next:e=>{this.loading=!1,this.groupChange.emit(["add",e]),this.layout.sendNotification("success","Group created",e.name),this.layout.closeDialog()},error:e=>this.onError(e)});else{let e=this.makeDto();if(!Object.keys(e).length){this.loading=!1,this.submitted=!1;return}this.userService.updatePersonalGroup(this.originalGroup.id,this.makeDto()).subscribe({next:t=>{this.loading=!1,this.groupChange.emit(["update",t]),this.layout.sendNotification("success","Group updated",t.name),this.layout.closeDialog()},error:t=>this.onError(t)})}}makeDto(e=!1){return{name:e?this.group.name:this.group.name!==this.originalGroup.name?this.group.name:void 0,description:e?this.group.description:this.group.description!==this.originalGroup.description?this.group.description:void 0}}onError(e){this.layout.sendNotification("error","Group error",this.group.name,e),this.submitted=!1,this.loading=!1}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=M({type:n,selectors:[["app-user-group-dialog"]],inputs:{originalGroup:"originalGroup"},outputs:{groupChange:"groupChange"},decls:23,vars:15,consts:[[1,"modal-header","align-items-center"],[1,"modal-title"],[1,"me-2",3,"icon"],["l10nTranslate",""],["animation","spin","size","sm",1,"ms-2",3,"icon"],[1,"modal-title","ms-auto"],["aria-label","Close","type","button",3,"click"],[1,"modal-body"],[1,"d-flex","col-12","pb-3"],[1,"flex-fill","col-6","pe-4"],["for","name","l10nTranslate",""],["id","name","appAutofocus","","autocomplete","off","type","text",1,"form-control","form-control-sm",3,"ngModelChange","disabled","autoSelect","ngModel"],[1,"flex-fill","col-6","ps-4"],["for","description","l10nTranslate",""],["id","description","autocomplete","off","type","text",1,"form-control","form-control-sm",3,"ngModelChange","ngModel","disabled"],[1,"modal-footer"],["data-dismiss","modal","type","button","l10nTranslate","",1,"btn","btn-sm","btn-secondary","ms-auto",3,"click"],["type","button","l10nTranslate","",1,"btn","btn-sm","btn-primary",3,"click","disabled"]],template:function(t,o){t&1&&(l(0,"div",0)(1,"h4",1),_(2,"fa-icon",2),f(3,ke,2,1,"span")(4,Se,2,0,"span",3),f(5,Me,1,1,"fa-icon",4),a(),f(6,Ee,3,1,"h4",5),l(7,"button",6),h("click",function(){return o.layout.closeDialog()}),a()(),l(8,"div",7)(9,"div",8)(10,"div",9)(11,"label",10),m(12,"Name"),a(),l(13,"input",11),G("ngModelChange",function(u){return V(o.group.name,u)||(o.group.name=u),u}),a()(),l(14,"div",12)(15,"label",13),m(16,"Description"),a(),l(17,"input",14),G("ngModelChange",function(u){return V(o.group.description,u)||(o.group.description=u),u}),a()()()(),l(18,"div",15)(19,"button",16),h("click",function(){return o.onCancel()}),m(20,"Cancel"),a(),l(21,"button",17),h("click",function(){return o.onSubmit()}),m(22," Confirm "),a()()),t&2&&(r(2),d("icon",o.icons.GROUPS),r(),g(o.group.id?3:4),r(2),g(o.loading?5:-1),r(),g(o.group.id?6:-1),r(),J(K("btn-close btn-close-white ",o.group.id?"ms-2":"ms-auto"," ms-2")),r(6),y("is-invalid",!o.group.name),d("disabled",!o.isPersonalGroup)("autoSelect",!1),F("ngModel",o.group.name),r(4),F("ngModel",o.group.description),d("disabled",!o.isPersonalGroup),r(4),d("disabled",!o.group.name||o.submitted))},dependencies:[re,ie,ne,se,oe,P,ae,_e],encapsulation:2});let i=n;return i})();var xe=(()=>{let n=class n{onClick(e){e.stopPropagation()}ngOnInit(){setTimeout(()=>{typeof document<"u"&&document.addEventListener("click",this.offClickHandler)},0)}ngOnDestroy(){typeof document<"u"&&document.removeEventListener("click",this.offClickHandler)}};n.\u0275fac=function(t){return new(t||n)},n.\u0275dir=U({type:n,selectors:[["","offClick",""]],hostBindings:function(t,o){t&1&&h("click",function(u){return o.onClick(u)})},inputs:{offClickHandler:[0,"offClick","offClickHandler"]}});let i=n;return i})();var S=class{constructor(n){typeof n=="string"&&(this.id=this.name=n,this.description=""),typeof n=="object"&&(this.id=n.id||n.name,this.name=n.name,this.description=n.description||"")}};var Te=i=>({active:i}),De=(i,n)=>({o:i,i:n});function Fe(i,n){if(i&1){let s=b();l(0,"input",6),h("keydown",function(t){C(s);let o=c();return v(o.inputEvent(t))})("keyup",function(t){C(s);let o=c();return v(o.inputEvent(t,!0))}),a()}if(i&2){let s=c();d("disabled",s.disabled)}}function Ve(i,n){i&1&&T(0)}function Ge(i,n){if(i&1&&(l(0,"span",12),w(1,Ve,1,0,"ng-container",13),a()),i&2){let s=c(2),e=D(6);y("ui-select-allow-clear",s.allowClear&&s.active),r(),d("ngTemplateOutlet",s.customTemplateSelect||e)("ngTemplateOutletContext",Z(4,Te,s.active))}}function Ae(i,n){if(i&1&&(l(0,"span",9),m(1),a()),i&2){let s=c(2);r(),k(s.placeholder)}}function He(i,n){if(i&1){let s=b();l(0,"button",14),h("click",function(t){C(s);let o=c(2);return v(o.removeClick(o.active,t))}),a()}}function je(i,n){if(i&1){let s=b();l(0,"div",4)(1,"span",7),h("click",function(t){C(s);let o=c();return v(o.matchClick(t))}),f(2,Ge,2,6,"span",8)(3,Ae,2,1,"span",9),f(4,He,1,0,"button",10),_(5,"i",11),a()()}if(i&2){let s=c();r(2),g(s.active?2:3),r(2),g(s.allowClear&&s.active?4:-1)}}function ze(i,n){i&1&&T(0)}function Ne(i,n){if(i&1){let s=b();l(0,"li",15)(1,"div",16),h("click",function(t){let o=C(s).$implicit,p=c(2);return v(p.selectMatch(o,t))})("mouseenter",function(){let t=C(s).$implicit,o=c(2);return v(o.selectActive(t))}),w(2,ze,1,0,"ng-container",13),a()()}if(i&2){let s=n.$implicit,e=c(2),t=D(8);r(),y("active",e.isActive(s)),r(),d("ngTemplateOutlet",e.customTemplateOptions||t)("ngTemplateOutletContext",$(4,De,s,e.inputValue))}}function Le(i,n){if(i&1&&(l(0,"ul",5),B(1,Ne,3,7,"li",15,q),a()),i&2){let s=c();r(),Q(s.options)}}function Re(i,n){if(i&1&&(l(0,"div",17)(1,"span",18),_(2,"fa-icon",19),a(),l(3,"span"),m(4),a(),l(5,"div",20),m(6),a()()),i&2){let s=n.active,e=c();r(2),d("icon",e.itemIcon)("fixedWidth",!1),r(2),k(s.name),r(2),k(s.description)}}function Ie(i,n){if(i&1&&(l(0,"a",21)(1,"div",17)(2,"span",18),_(3,"fa-icon",19),a(),_(4,"span",22),A(5,"highlight"),_(6,"span",23),A(7,"highlight"),a()()),i&2){let s=n.i,e=n.o,t=c();r(3),d("icon",t.itemIcon)("fixedWidth",!1),r(),d("innerHtml",t.sanitize(H(5,4,e.name,s)),E),r(2),d("innerHtml",t.sanitize(H(7,7,e.description,s)),E)}}var bt=(()=>{let n=class n{constructor(){this.element=O(W),this.itemIcon=le,this.allowClear=!0,this.placeholder="",this.idField="id",this.nameField="name",this.descriptionField="description",this.data=new x,this.selected=new x,this.removed=new x,this.typed=new x,this.opened=new x,this.options=[],this.itemObjects=[],this.inputMode=!1,this.inputValue="",this.onChange=Function.prototype,this.onTouched=Function.prototype,this.sanitizer=O(ee),this._items=[],this._optionsOpened=!1,this._disabled=!1,this._active=null,this.clickedOutside=this.clickedOutside.bind(this)}set items(e){if(!e.length){this._items=this.itemObjects=[],this.itemObjects=[];return}this._items=e.filter(t=>{if(typeof t=="string"||typeof t=="object"&&t&&t[this.nameField]&&t[this.idField])return t}),this.itemObjects=this._items.map(t=>typeof t=="string"?new S(t):new S({id:t[this.idField],name:t[this.nameField],description:t[this.descriptionField]}))}get optionsOpened(){return this._optionsOpened}set optionsOpened(e){this._optionsOpened=e,this.opened.emit(e)}get disabled(){return this._disabled}set disabled(e){this._disabled=e,this._disabled===!0&&this.hideOptions()}get active(){return this._active}set active(e){e?this._active=typeof e=="string"?e:new S({id:e[this.idField],name:e[this.nameField],description:e[this.descriptionField]}):this._active=null}sanitize(e){return this.sanitizer.bypassSecurityTrustHtml(e)}inputEvent(e,t=!1){if(e.keyCode===9)return;if(t&&(e.keyCode===37||e.keyCode===39||e.keyCode===38||e.keyCode===40||e.keyCode===13)){e.preventDefault();return}if(!t&&e.keyCode===8){let p=this.element.nativeElement.querySelector("div.ui-select-container > input");(!p.value||p.value.length<=0)&&(this.active&&this.remove(this.active),e.preventDefault())}if(!t&&e.keyCode===27){this.hideOptions(),e.preventDefault();return}if(!t&&e.keyCode===46&&(this.active&&this.remove(this.active),e.preventDefault()),!t&&e.keyCode===37&&this._items.length>0){this.behavior.first(),e.preventDefault();return}if(!t&&e.keyCode===39&&this._items.length>0){this.behavior.last(),e.preventDefault();return}if(!t&&e.keyCode===38){this.behavior.prev(),e.preventDefault();return}if(!t&&e.keyCode===40){this.behavior.next(),e.preventDefault();return}if(!t&&e.keyCode===13){(!this.active||this.active.id!==this.activeOption.id)&&(this.selectActiveMatch(),this.behavior.next()),e.preventDefault();return}let o=e.target||e.srcElement;o?(this.inputValue=o.value,this.doEvent("typed",this.inputValue||" ")):this.open()}ngOnInit(){this.subscription=this.typed.asObservable().pipe(L(200),R()).subscribe(e=>this.doSearch(e)),this.behavior=new N(this),this.doEvent("typed"," ")}ngOnDestroy(){this.subscription.unsubscribe()}remove(e){this._disabled!==!0&&(this.active=null,this.data.next(this.active),this.doEvent("removed",e),this.inputValue="",this.doEvent("typed"," "))}doEvent(e,t){this[e]&&t&&this[e].next(t),this.onTouched(),(e==="selected"||e==="removed")&&this.onChange(this.active)}clickedOutside(){this.inputMode=!1,this.optionsOpened=!1}writeValue(e){this.active=e,this.data.emit(this.active)}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}matchClick(e){this._disabled!==!0&&(this.inputMode=!this.inputMode,this.inputMode===!0&&(this.focusToInput(),this.open()))}mainClick(e){if(this.inputMode===!0||this._disabled===!0)return;if(e.keyCode===46){e.preventDefault(),this.inputEvent(e);return}if(e.keyCode===8){e.preventDefault(),this.inputEvent(e,!0);return}if(e.keyCode===9||e.keyCode===13||e.keyCode===27||e.keyCode>=37&&e.keyCode<=40){e.preventDefault();return}this.inputMode=!0;let t=String.fromCharCode(96<=e.keyCode&&e.keyCode<=105?e.keyCode-48:e.keyCode).toLowerCase();this.focusToInput(t),this.open();let o=e.target||e.srcElement;o.value=t,this.inputEvent(e)}selectActive(e){this.activeOption=e}isActive(e){return this.activeOption.id===e.id}removeClick(e,t){t.stopPropagation(),this.remove(e)}focusToInput(e=""){setTimeout(()=>{let t=this.element.nativeElement.querySelector("div.ui-select-container > input");t&&(t.focus(),t.value=e)},0)}selectMatch(e,t=void 0){t&&(t.stopPropagation(),t.preventDefault()),!(this.options.length<=0)&&(this.active=e,this.data.next(this.active),this.doEvent("selected",e),this.hideOptions(),this.focusToInput(e.name),this.element.nativeElement.querySelector(".ui-select-container").focus())}doSearch(e){this.searchFunction(e).subscribe({next:t=>{this.items=t},error:t=>{console.error(t),this.items=[]},complete:()=>this.behavior.filter()})}open(){this.options=this.itemObjects,this.options.length>0&&this.behavior.first(),this.optionsOpened=!0}hideOptions(){this.inputMode=!1,this.optionsOpened=!1}selectActiveMatch(){this.selectMatch(this.activeOption)}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=M({type:n,selectors:[["app-select"]],inputs:{searchFunction:"searchFunction",customTemplateOptions:"customTemplateOptions",customTemplateSelect:"customTemplateSelect",itemIcon:"itemIcon",allowClear:"allowClear",placeholder:"placeholder",idField:"idField",nameField:"nameField",descriptionField:"descriptionField",disabled:"disabled",active:"active"},outputs:{data:"data",selected:"selected",removed:"removed",typed:"typed",opened:"opened"},features:[X([{provide:te,useExisting:I(()=>n),multi:!0}])],decls:9,vars:5,consts:[["DefaultSelect",""],["DefaultOptions",""],[1,"ui-select-container","dropdown","open",3,"keyup","offClick"],["autocomplete","false","tabindex","-1","type","text",1,"form-control","form-control-sm","ui-select-search",3,"disabled"],[1,"ui-select-match","form-control","form-control-sm"],["role","menu",1,"ui-select-choices","dropdown-menu"],["autocomplete","false","tabindex","-1","type","text",1,"form-control","form-control-sm","ui-select-search",3,"keydown","keyup","disabled"],["tabindex","-1",1,"ui-select-toggle","no-select",2,"outline","0",3,"click"],[1,"ui-select-match-text","w-100",3,"ui-select-allow-clear"],[1,"ui-select-placeholder"],["aria-label","close","type","button",1,"btn-close"],[1,"dropdown-toggle"],[1,"ui-select-match-text","w-100"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],["aria-label","close","type","button",1,"btn-close",3,"click"],["role","menuitem"],[1,"ui-select-choices-row",3,"click","mouseenter"],[1,"d-flex","align-items-center"],[1,"ui-icon","circle-primary-icon","me-2"],[3,"icon","fixedWidth"],[1,"d-flex","ms-auto","me-4","fs-xxxs","text-muted"],["href","javascript:void(0)",1,"dropdown-item","cursor-pointer",2,"padding","3px 5px"],[3,"innerHtml"],[1,"d-flex","ms-auto","fs-xxxs","text-muted",3,"innerHtml"]],template:function(t,o){if(t&1){let p=b();l(0,"div",2),h("keyup",function(Oe){return C(p),v(o.mainClick(Oe))}),_(1,"div"),f(2,Fe,1,1,"input",3)(3,je,6,2,"div",4),f(4,Le,3,0,"ul",5),a(),w(5,Re,7,4,"ng-template",null,0,j)(7,Ie,8,10,"ng-template",null,1,j)}t&2&&(d("offClick",o.clickedOutside),r(),y("ui-disabled",o.disabled),r(),g(o.inputMode?2:3),r(2),g(o.optionsOpened&&o.options&&o.options.length>0?4:-1))},dependencies:[xe,P,Y,Ce],styles:[`.ui-select-container[_ngcontent-%COMP%]{background-color:transparent;border-radius:4px}.ui-select-container.open[_ngcontent-%COMP%] > .dropdown-menu[_ngcontent-%COMP%]{display:block}.ui-select-container.open[_ngcontent-%COMP%] > a[_ngcontent-%COMP%]{outline:none}.ui-select-container[_ngcontent-%COMP%] .ui-icon[_ngcontent-%COMP%]{min-width:26px;min-height:26px;font-size:.85rem}.ui-select-container[_ngcontent-%COMP%] .ui-disabled[_ngcontent-%COMP%]{background-color:#d4dbe8;border-radius:4px;position:absolute;width:100%;height:100%;z-index:5;opacity:.6;top:0;left:0;cursor:not-allowed}.ui-select-container[_ngcontent-%COMP%] .ui-select-search[_ngcontent-%COMP%]{line-height:26px}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%]{padding-left:.3rem}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]{text-align:start!important}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .caret[_ngcontent-%COMP%]{position:absolute;top:45%;right:15px}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .close[_ngcontent-%COMP%]{font-size:1.6em;line-height:.75}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .ui-select-toggle[_ngcontent-%COMP%]{display:flex;align-items:center}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .ui-select-toggle[_ngcontent-%COMP%] > .caret[_ngcontent-%COMP%]{position:absolute;height:10px;top:50%;right:10px;margin-top:-2px}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .ui-select-placeholder[_ngcontent-%COMP%]{float:left;line-height:26px;color:#8c8c8c;width:100%}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .dropdown-toggle[_ngcontent-%COMP%]{cursor:pointer}.ui-select-container[_ngcontent-%COMP%] .ui-select-match[_ngcontent-%COMP%] .dropdown-toggle[_ngcontent-%COMP%]:after{display:inline-block!important}.ui-select-container[_ngcontent-%COMP%] .ui-select-choices[_ngcontent-%COMP%]{width:100%;height:auto;max-height:200px;overflow-x:hidden;margin-top:0}.ui-select-container[_ngcontent-%COMP%] .ui-select-choices[_ngcontent-%COMP%] .ui-select-choices-row[_ngcontent-%COMP%] > a[_ngcontent-%COMP%]{display:block;padding:3px 5px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.ui-select-container[_ngcontent-%COMP%] .ui-select-choices[_ngcontent-%COMP%] .ui-select-choices-row[_ngcontent-%COMP%] .active[_ngcontent-%COMP%] > a[_ngcontent-%COMP%]{text-decoration:none;outline:0}.ui-select-container[_ngcontent-%COMP%] .ui-select-choices[_ngcontent-%COMP%] .ui-select-choices-row[_ngcontent-%COMP%] .dropdown-item[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{pointer-events:none} `]});let i=n;return i})(),N=class{constructor(n){this.actor=n}first(){this.actor.activeOption=this.actor.options[0],this.ensureHighlightVisible()}last(){this.actor.activeOption=this.actor.options[this.actor.options.length-1],this.ensureHighlightVisible()}prev(){let n=this.actor.options.indexOf(this.actor.activeOption);this.actor.activeOption=this.actor.options[n-1<0?this.actor.options.length-1:n-1],this.ensureHighlightVisible()}next(){let n=this.actor.options.indexOf(this.actor.activeOption);this.actor.activeOption=this.actor.options[n+1>this.actor.options.length-1?0:n+1],this.ensureHighlightVisible()}ensureHighlightVisible(n=void 0){let s=this.actor.element.nativeElement.querySelector(".ui-select-choices-content");if(!s)return;let e=s.querySelectorAll(".ui-select-choices-row");if(e.length<1)return;let t=this.getActiveIndex(n);if(t<0)return;let o=e[t];if(!o)return;let p=o.offsetTop+o.clientHeight-s.scrollTop,u=s.offsetHeight;p>u?s.scrollTop+=p-u:p<o.clientHeight&&(s.scrollTop-=o.clientHeight-p)}filter(){this.actor.options=[...this.actor.itemObjects],this.actor.options.length>0&&(this.actor.activeOption=this.actor.options[0],this.ensureHighlightVisible())}getActiveIndex(n=void 0){let s=this.actor.options.indexOf(this.actor.activeOption);return s<0&&n!==void 0&&(s=n.get(this.actor.activeOption.id)),s}};export{be as a,ye as b,st as c,bt as d};