UNPKG

@sync-in/server

Version:

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

2 lines (1 loc) 5.61 kB
import{a as w}from"./chunk-NMF2ZFBE.js";import{h as O}from"./chunk-XTVNHFKX.js";import{c as S,h as v}from"./chunk-RTNEBRKJ.js";import{Cb as M,pb as V,qb as L,rb as d,vb as N}from"./chunk-O3YLAEVE.js";import{d as R}from"./chunk-QHJT5H4M.js";import{Bb as x,Eb as h,Gb as m,He as D,Ia as E,Kd as k,Oa as l,Oe as A,Tb as c,Ub as T,Vb as P,Wa as b,ab as I,ja as p,lb as C,mb as g,oa as u,pa as _,qg as W,rb as f,sb as i,tb as n,ub as y}from"./chunk-D55YR5X7.js";import"./chunk-DM4NXKEP.js";import"./chunk-ZIJQRARU.js";import"./chunk-KAVP6UXH.js";function $(o,s){if(o&1&&(i(0,"div",16)(1,"span",3),c(2),n(),i(3,"span",17),c(4),n()()),o&2){let r=m(2);l(2),T(r.infoMsg),l(2),P(":\xA0",r.syncService.wizard.localPath.origin)}}function U(o,s){if(o&1){let r=x();i(0,"div",5)(1,"fa-icon",13),h("click",function(){u(r);let t=m();return _(t.onReset())}),n(),y(2,"img",14),i(3,"div",15),c(4),n(),C(5,$,5,2,"div",16),n()}if(o&2){let r=m();l(),f("icon",r.icons.faTimesCircle),l(),f("src",r.syncService.wizard.localPath.mimeUrl,E),l(2),T(r.syncService.wizard.localPath.path),l(),g(r.infoMsg?5:-1)}}function Y(o,s){if(o&1){let r=x();i(0,"div",18),h("dragleave",function(t){u(r);let a=m();return _(a.dragLeave(t))})("dragover",function(t){u(r);let a=m();return _(a.dragOver(t))})("drop",function(t){u(r);let a=m();return _(a.drop(t))}),i(1,"div",19)(2,"span",20),c(3,"Drop folder here"),n()()()}}var ie=(()=>{let s=class s{constructor(){this.pathIsValid=!1,this.infoMsg=null,this.syncService=p(O),this.icons={faTimesCircle:D,faArrowCircleRight:A},this.router=p(R),this.renderer=p(b),this.store=p(N),this.layout=p(M),this.layout.setBreadcrumbIcon(L.WIZARD),this.layout.setBreadcrumbNav({url:`/${d.BASE}/${d.WIZARD}/${d.WIZARD_CLIENT}/${V.WIZARD_CLIENT}`,splicing:3,translating:!0,sameLink:!0}),this.syncService.wizard.localPath&&this.checkSelection();let e=this.router.currentNavigation()?.extras.state;e?.file&&this.syncService.addFileToRemotePath(e.file)}dragOver(e){return e.preventDefault(),e.dataTransfer.items[0].type?!1:(e.dataTransfer.dropEffect="copy",e.stopPropagation(),e.target.classList.contains("dropzone")&&this.renderer.addClass(e.target,"active"),!0)}dragLeave(e){e.preventDefault(),e.target.classList.contains("dropzone")&&this.renderer.removeClass(e.target,"active")}drop(e){e.preventDefault(),e.stopPropagation();let t=e.dataTransfer.items[0].webkitGetAsEntry();return t&&t.isDirectory?(this.syncService.wizard.localPath={name:t.name,path:this.syncService.getFilePath(e.dataTransfer.files[0]),mimeUrl:v(S),origin:null},this.checkSelection(),!0):!1}onSelect(){this.syncService.showOpenDialog({properties:[w.DIRECTORY,w.CREATE_DIRECTORY],defaultPath:""}).then(e=>{e.canceled||(this.syncService.wizard.localPath={name:e.filePaths[0].split("\\").pop().split("/").pop(),path:e.filePaths[0],mimeUrl:v(S),origin:null},this.checkSelection())})}onReset(){this.syncService.wizard.localPath=null,this.pathIsValid=!1,this.infoMsg=null}onNext(){this.router.navigate([d.BASE,d.WIZARD,d.WIZARD_SERVER]).catch(console.error)}onCancel(){this.router.navigate([d.BASE,d.PATHS]).catch(console.error),this.syncService.resetWizard()}checkSelection(){let e=this.store.clientSyncPaths().find(t=>new RegExp(`^${t.settings.localPath}((\\/.*)+|\\/?)$`).test(this.syncService.wizard.localPath.path));e?(this.pathIsValid=!1,this.syncService.wizard.localPath.mimeUrl=v(`${S}_sync`),this.syncService.wizard.localPath.origin=e.settings.localPath,this.infoMsg="The parent directory is already synced"):(this.infoMsg=null,this.pathIsValid=!0)}};s.\u0275fac=function(t){return new(t||s)},s.\u0275cmp=I({type:s,selectors:[["app-sync-wizard-client"]],decls:22,vars:4,consts:[[1,"wizard"],[1,"d-flex","flex-column","text-center","fs-sm"],["l10nTranslate","",1,"mb-2"],["l10nTranslate",""],[1,"d-flex","flex-column","h-100"],[1,"d-flex","flex-column","my-auto","fs-sm"],[1,"area"],[1,"d-flex","flex-column","mt-4"],[1,"d-flex","align-items-start"],["type","button","l10nTranslate","",1,"btn","btn-secondary","me-auto",3,"click"],[3,"icon"],["type","button","l10nTranslate","",1,"btn","btn-secondary",3,"click"],["type","button","l10nTranslate","",1,"btn","btn-secondary","ms-auto",3,"click","disabled"],["size","2x",1,"position-absolute","align-self-center","cursor-pointer",2,"margin-left","85px",3,"click","icon"],["alt","","height","96",1,"align-self-center","mb-2",3,"src"],[1,"align-self-center","mt-2","font-size-md","word-break-all","fw-500"],[1,"align-self-center","text-warning","mt-4"],[1,"fw-bold","ms-1"],[1,"area",3,"dragleave","dragover","drop"],["l10nTranslate","",1,"dropzone"],[1,"d-flex","flex-column","justify-content-center","align-self-center"]],template:function(t,a){t&1&&(i(0,"div",0)(1,"div",1)(2,"div",2),c(3,"This wizard will help you synchronize a directory on your computer with a Sync-in directory."),n(),i(4,"div")(5,"div",3),c(6,"To begin, select a folder on your computer."),n(),i(7,"div",3),c(8,'You can drag the folder into the area below or click on the "Select" button.'),n()()(),i(9,"div",4),C(10,U,6,4,"div",5)(11,Y,4,0,"div",6),n(),i(12,"div",7)(13,"div",8)(14,"button",9),h("click",function(){return a.onCancel()}),y(15,"fa-icon",10),c(16," Cancel "),n(),i(17,"button",11),h("click",function(){return a.onSelect()}),c(18,"Select a folder"),n(),i(19,"button",12),h("click",function(){return a.onNext()}),y(20,"fa-icon",10),c(21," Next "),n()()()()),t&2&&(l(10),g(a.syncService.wizard.localPath?10:11),l(5),f("icon",a.icons.faTimesCircle),l(4),f("disabled",!a.pathIsValid),l(),f("icon",a.icons.faArrowCircleRight))},dependencies:[W,k],encapsulation:2});let o=s;return o})();export{ie as SyncWizardClientComponent};