UNPKG

@sync-in/server

Version:

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

2 lines (1 loc) 9.26 kB
import{A as fe}from"./chunk-E32J777S.js";import{c as W}from"./chunk-3WZ6F3LC.js";import{e as _e,g as P,h as ye}from"./chunk-XTVNHFKX.js";import"./chunk-RTNEBRKJ.js";import"./chunk-JXZCNFW7.js";import{w as Se}from"./chunk-B6HQYQYG.js";import"./chunk-GWRAGN3M.js";import{Cb as ue,D as w,Mb as x,Nb as E,Ob as S,pb as me,qb as he,rb as h,s as ae,vb as pe}from"./chunk-O3YLAEVE.js";import{d as Y}from"./chunk-QHJT5H4M.js";import{Bb as B,Cd as te,Dd as ie,Eb as _,Ed as ne,Gb as m,Hf as le,Ia as R,Jd as re,Kb as O,Kd as oe,Lb as $,Mb as H,Me as se,Oa as a,Oe as ce,Rb as V,Sb as I,Tb as u,Ub as v,Xb as Z,Yb as U,Zb as j,ab as M,cc as N,fc as Q,fd as G,ja as f,jd as q,kc as g,kd as J,lb as y,mb as C,mc as b,md as K,oa as z,od as X,pa as T,pb as L,pd as ee,qb as F,qg as de,rb as l,sb as s,tb as c,ub as p,va as k}from"./chunk-D55YR5X7.js";import"./chunk-SDJNZULP.js";import"./chunk-2YQ4SX3A.js";import"./chunk-DM4NXKEP.js";import"./chunk-ZIJQRARU.js";import{i as D}from"./chunk-KAVP6UXH.js";var Ce=()=>({standalone:!0}),ve=(i,o)=>o.id;function Pe(i,o){if(i&1&&p(0,"fa-icon",25),i&2){let n=m(2);I(N("circle-",n.selectedPath.iconClass,"-icon")),l("icon",n.selectedPath.icon)}}function ge(i,o){if(i&1&&p(0,"img",23),i&2){let n=m(2);l("src",n.selectedPath.mimeUrl,R)}}function be(i,o){if(i&1&&(y(0,Pe,1,4,"fa-icon",22)(1,ge,1,1,"img",23),s(2,"span",24),u(3),c()),i&2){let n=m();C(n.selectedPath.icon?0:1),a(3),v(n.selectedPath.name)}}function we(i,o){i&1&&(s(0,"span",3),u(1,"Please select the server directory to sync, if it doesn't exist you can create it."),c())}function xe(i,o){if(i&1&&(s(0,"span",3),u(1),c()),i&2){let n=m();a(),v(n.infoMsg)}}function Ee(i,o){if(i&1&&(s(0,"th",13),u(1),c()),i&2){let n=m();a(),v(n.currentShowedPath)}}function Ae(i,o){i&1&&(s(0,"th",3),u(1,"Double click to browse directories"),c())}function ze(i,o){if(i&1&&p(0,"fa-icon",25),i&2){let n=m().$implicit;I(N("circle-",n.iconClass,"-icon")),l("icon",n.icon)}}function Te(i,o){if(i&1&&p(0,"img",23),i&2){let n=m().$implicit;l("src",n.mimeUrl,R)}}function Re(i,o){if(i&1){let n=B();s(0,"tr",26),_("click",function(){let r=z(n).$implicit,e=m();return T(e.onSelect(r))})("dblclick",function(){let r=z(n).$implicit,e=m();return T(e.browse(r.path))}),s(1,"td")(2,"div",27),y(3,ze,1,4,"fa-icon",22)(4,Te,1,1,"img",23),s(5,"span",28),u(6),c()()()()}if(i&2){let n=o.$implicit;V("selected",n.selected),a(3),C(n.icon?3:4),a(3),v(n.name)}}var Xe=(()=>{let o=class o{constructor(){this.locale=f(ne),this.icons={faArrowCircleLeft:se,faArrowCircleRight:ce,faFolderPlus:le},this.infoMsg=null,this.canCreateDir=!1,this.router=f(Y),this.store=f(pe),this.userService=f(Se),this.filesService=f(fe),this.syncService=f(ye),this.layout=f(ue),this.rootPaths=[this.userService.userHavePermission(w.PERSONAL_SPACE)?new P({id:0,name:this.layout.translateString(x.PERSONAL_FILES),path:`${S.FILES}/${S.PERSONAL}`,icon:E.PERSONAL,hasChildren:!0,enabled:!0,iconClass:"primary"}):null,this.userService.userHavePermission(w.SPACES)?new P({id:-1,name:this.layout.translateString(x.SPACES),path:S.SPACES,icon:E.SPACES,hasChildren:!0,enabled:!0,iconClass:"primary"}):null,this.userService.userHavePermission(w.SHARES)?new P({id:-2,name:this.layout.translateString(x.SHARES),path:S.SHARES,icon:E.SHARES,hasChildren:!0,enabled:!0,iconClass:"purple"}):null].filter(Boolean),this.currentPaths=k([...this.rootPaths]),this.syncService.wizard.remotePath&&this.browse(this.syncService.wizard.remotePath.path.split("/").slice(0,-1).join("/"),this.syncService.wizard.remotePath.name).catch(t=>{console.error(t),this.currentPath="",this.onBack()}),this.layout.setBreadcrumbIcon(he.WIZARD),this.layout.setBreadcrumbNav({url:`/${h.BASE}/${h.WIZARD}/${h.WIZARD_SERVER}/${me.WIZARD_SERVER}`,splicing:3,translating:!0,sameLink:!0})}browse(t,r=null){return D(this,null,function*(){if(this.currentPath=t||"",this.setCurrentPaths((yield this.filesService.getTreeNode(t)).map(e=>new P(e))),this.setCurrentShowedPath(),this.canCreateDir=this.currentPath.length?_e(`${this.currentPath}/canCreate`,!0):!1,r){let e=this.currentPaths().findIndex(d=>d.name===r);e>-1&&(this.onSelect(this.currentPaths()[e]),this.autoResize.scrollIntoView(Math.max(e,1)*30-30))}else this.onSelect(),this.autoResize.scrollTop()})}onBack(){let t=this.currentPath.split("/");if(t.length===2&&t[0]===S.FILES&&t[1]===S.PERSONAL||t.length<=1)this.currentPath="",this.onSelect(),this.initRootPaths(),this.setCurrentShowedPath(),this.canCreateDir=!1;else{let r=t.length===2&&t[0]===S.FILES?[S.SPACES]:t.slice(0,-1);this.browse(r.join("/")).catch(console.error)}}addDirectory(){this.filesService.make("directory",this.newDirectoryName,this.currentPath,!0).subscribe({next:()=>{this.browse(this.currentPath,this.newDirectoryName).then(()=>this.newDirectoryName="").catch(console.error)},error:t=>this.setInfoMsg(t.error.message)})}onSelect(t){if(this.setInfoMsg(null),this.currentPaths().forEach(r=>r.selected=!1),!t){this.selectPath();return}t.selected=!0,t.isSynchronizable&&(t.enabled?t.isAlreadySynced?(this.setInfoMsg("This directory is already synced"),this.selectPath()):(t.isWriteable||this.setInfoMsg("This directory is read-only, you will not be able to modify it"),this.selectPath(t)):(this.setInfoMsg("This directory is not accessible"),this.selectPath()))}onNext(){this.router.navigate([h.BASE,h.WIZARD,h.WIZARD_SETTINGS]).catch(console.error)}onPrevious(){this.router.navigate([h.BASE,h.WIZARD,h.WIZARD_CLIENT]).catch(console.error)}setServerPath(t){this.syncService.wizard.remotePath=t}setCurrentPaths(t){for(let r of this.store.clientSyncPaths()){let e=new RegExp(`^${r.settings.remotePath}((\\/.*)+|\\/?)$`);for(let d of t)e.test(d.serverPath)&&d.setAlreadySynced()}this.currentPaths.set(t)}initRootPaths(){this.currentPaths.set([...this.rootPaths])}setCurrentShowedPath(){this.currentShowedPath=this.syncService.translateServerPath(this.currentPath)}selectPath(t=null){this.selectedPath=t,this.setServerPath(t)}setInfoMsg(t,r=!1){this.infoMsg=t,r&&setTimeout(()=>this.infoMsg=null,6e3)}};o.\u0275fac=function(r){return new(r||o)},o.\u0275cmp=M({type:o,selectors:[["app-sync-wizard-server"]],viewQuery:function(r,e){if(r&1&&O(W,7),r&2){let d;$(d=H())&&(e.autoResize=d.first)}},decls:36,vars:29,consts:[[1,"wizard"],[1,"my-2"],[1,"d-flex","align-items-center","justify-content-center","fs-sm",2,"min-height","40px"],["l10nTranslate",""],[1,"app-top-menu","px-0","bg-transparent"],["type","button",1,"btn","btn-sm","btn-secondary",3,"click","disabled","tooltip"],[3,"icon"],[1,"text-warning","mx-auto","fs-sm"],[1,"row","align-items-center"],[1,"input-group"],["type","button",1,"btn","btn-sm","btn-secondary","input-group-text",3,"click","hidden","disabled","tooltip"],["type","text",1,"form-control","form-control-sm","me-1",3,"keyup.enter","ngModelChange","ngModel","hidden","ngModelOptions","placeholder"],[1,"app-table","wizard-nav-header"],[1,"text-truncate"],["appAutoResize","",1,"wizard-nav-content",3,"resizeOffset","useMaxHeight"],[1,"app-table"],["tabindex","-1"],[3,"selected"],[1,"mt-auto"],[1,"d-flex","align-items-start"],["type","button","l10nTranslate","",1,"btn","btn-secondary","me-auto",3,"click"],["type","button","l10nTranslate","",1,"btn","btn-secondary","ms-auto",3,"click","disabled"],[2,"width","32px","height","32px","font-size","16px",3,"icon","class"],["alt","","height","30",3,"src"],[1,"text-truncate","fw-500","ms-2"],[2,"width","32px","height","32px","font-size","16px",3,"icon"],[3,"click","dblclick"],[1,"d-flex","align-items-center"],[1,"ms-1"]],template:function(r,e){r&1&&(s(0,"div",0)(1,"div",1)(2,"div",2),y(3,be,4,2)(4,we,2,0,"span",3),c(),s(5,"div",4)(6,"button",5),g(7,"translate"),_("click",function(){return e.onBack()}),p(8,"fa-icon",6),c(),s(9,"div",7),y(10,xe,2,1,"span",3),c(),s(11,"form",8)(12,"div",9)(13,"button",10),g(14,"translate"),_("click",function(){return e.addDirectory()}),p(15,"fa-icon",6),c(),s(16,"input",11),g(17,"translate"),_("keyup.enter",function(){return e.addDirectory()}),j("ngModelChange",function(A){return U(e.newDirectoryName,A)||(e.newDirectoryName=A),A}),c()()()(),s(18,"table",12)(19,"thead")(20,"tr"),y(21,Ee,2,1,"th",13)(22,Ae,2,0,"th",3),c()()(),s(23,"div",14)(24,"table",15)(25,"tbody",16),L(26,Re,7,4,"tr",17,ve),c()()()(),s(28,"div",18)(29,"div",19)(30,"button",20),_("click",function(){return e.onPrevious()}),p(31,"fa-icon",6),u(32," Previous "),c(),s(33,"button",21),_("click",function(){return e.onNext()}),p(34,"fa-icon",6),u(35," Next "),c()()()()),r&2&&(a(3),C(e.selectedPath?3:4),a(3),l("disabled",!e.currentPath)("tooltip",b(7,19,"Back",e.locale.language)),a(2),l("icon",e.icons.faArrowCircleLeft),a(2),C(e.infoMsg?10:-1),a(3),l("hidden",!e.canCreateDir)("disabled",!e.newDirectoryName)("tooltip",b(14,22,"Add",e.locale.language)),a(2),l("icon",e.icons.faFolderPlus),a(),Z("ngModel",e.newDirectoryName),l("hidden",!e.canCreateDir)("ngModelOptions",Q(28,Ce))("placeholder",b(17,25,"New folder",e.locale.language)),a(5),C(e.currentPath?21:22),a(2),l("resizeOffset",230)("useMaxHeight",!1),a(3),F(e.currentPaths()),a(5),l("icon",e.icons.faArrowCircleLeft),a(2),l("disabled",!e.selectedPath),a(),l("icon",e.icons.faArrowCircleRight))},dependencies:[de,oe,W,te,ee,G,q,J,X,K,ie,ae,re],encapsulation:2});let i=o;return i})();export{Xe as SyncWizardServerComponent};