diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 6b6366c..1657eef 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -358,29 +358,17 @@ app.controller('websiteCtrl', [ vm.folderName = ''; }; - vm.breadcrumbs = []; - vm.breadcrumbsPath = ['']; - vm.siteDirectories = []; - vm.siteFiles = []; vm.Sites.allContents = function (r) { vm.copyR = r; - vm.strictPath = r.shareAccess.path; - vm.previousSearchQuery = vm.strictPath; var pkg = Auth.oauth3.pkg('www@daplie.com'); return pkg.contents({ - hostname: r.domain, - domain: r.domain, - tld: r.tld, - sld: r.sld, - // sub: r.sub, - path: r.shareAccess.path + hostname: r.domain + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: r.sub + , path: r.shareAccess.path }).then(function (result) { - debugger; - if (r.shareAccess.path !== '/') { - - } else { - vm.breadcrumbs.push('root'); - } vm.folderStructure = result; result.data.forEach(function(data){ if (data.file) { @@ -395,8 +383,22 @@ app.controller('websiteCtrl', [ }); }; - var cleanPathQuery = function (path) { + vm.Sites.contents = function (r) { debugger; + var pkg = Auth.oauth3.pkg('www@daplie.com'); + return pkg.contents({ + hostname: r.domain + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: r.sub + , path: r.newPath + }).then(function (result) { + debugger; + }); + }; + + var cleanPathQuery = function (path) { vm.cleanedPath = path.replace(/\/+/g, '/'); return vm.cleanedPath; }; @@ -445,53 +447,29 @@ app.controller('websiteCtrl', [ vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); }; + var removeFolderCrumbsCleanUp = function (crumb) { + var str2arryQuery = cleanPathQuery(vm.breadcrumbsPath.join('/')); + var str2arry = vm.breadcrumbs; + str2arryQuery = str2arryQuery.split('/'); + var removeFromBreadcrumbsQuery = str2arryQuery.indexOf(crumb); + var removeFromBreadcrumbs = str2arry.indexOf(crumb); + vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery); + vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); + vm.copyR.fromFolder = vm.breadcrumbsPath.join('/'); + }; + vm.getDirectoriesFromBreadcrumbs = function (dir) { - vm.isRoot = false; - if (vm.copyR.shareAccess.path !== '/') { - var strictArray = vm.copyR.shareAccess.path.split('/'); - if (vm.breadcrumbsPath.join('/') === '') { - vm.breadcrumbsPath = strictArray; - } else { - crumbsCleanUp(dir); - } - vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/')); - } else { - crumbsCleanUp(dir); - vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/')); - } + crumbsCleanUp(dir); + cleanPathQuery(vm.breadcrumbsPath.join('/')); + vm.Sites.contents(vm.copyR, vm.cleanedPath); vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1]; }; vm.getDirectories = function (dir) { - if (vm.copyR.shareAccess.path !== '/') { - if (vm.breadcrumbsPath.length === 0) { - var breadcrumblies = vm.strictPath + dir; - vm.breadcrumbsPath = breadcrumblies.split('/'); - vm.breadcrumbs.push(dir); - } else { - if (vm.copyR.shareAccess.path !== '/' && vm.copyR.newFile) { - if (vm.count === 1) { - vm.breadcrumbsPath.push(dir); - vm.breadcrumbs.push(dir); - } else { - if (vm.isRoot) { - vm.breadcrumbsPath.pop(); - } - vm.breadcrumbsPath.push(dir); - vm.breadcrumbs.push(dir); - } - } else { - vm.breadcrumbsPath.push(dir); - vm.breadcrumbs.push(dir); - } - } - vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/')); - } else { - vm.breadcrumbs.push(dir); - vm.breadcrumbsPath.push(dir); - vm.breadcrumbsPath.unshift(''); - vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/')); - } + vm.breadcrumbs.push(dir); + vm.breadcrumbsPath.push(dir); + cleanPathQuery(vm.breadcrumbsPath.join('/')); + vm.Sites.contents(vm.copyR, vm.cleanedPath); vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1]; }; @@ -503,77 +481,51 @@ app.controller('websiteCtrl', [ vm.Sites.remove(r, opts); }; - vm.deleteFilesFrom = function (r, opts) { - var file = opts; + vm.deleteFilesFrom = function (r, file) { vm.pathRemoved = file; - var requestedPath; - if (r.shareAccess.path !== '/') { - if (vm.breadcrumbsPath.length === 0) { - requestedPath = r.shareAccess.path + '/' + file; - } else { - if (r.shareAccess.path !== '/' && vm.breadcrumbsPath.join('/') !== '') { - requestedPath = vm.breadcrumbsPath.join('/') + '/' + file; - } else { - requestedPath = vm.breadcrumbsPath.join('/') + '/' + file; - if (vm.breadcrumbsPath.join('/') === '') { - requestedPath = vm.strictPath + '/' + file; - } - } - } - } else { - if (vm.breadcrumbsPath.length === 0 && r.shareAccess.path === '/') { - requestedPath = r.shareAccess.path + file; - } else { - requestedPath = vm.breadcrumbsPath.join('/') + '/' + file; - } - } - opts = { - path: requestedPath - }; - vm.Sites.remove(r, opts); - }; - - vm.triggerDeleteFolder = function (path, r) { - vm.deletedFolder = true; + var path = vm.breadcrumbsPath.join('/'); + path = path + '/' + file; path = cleanPathQuery(path); var opts = { path: path }; + debugger; + vm.Sites.remove(r, opts); + }; + + vm.deleteFromInsideOfFolder = false; + vm.triggerDeleteFolder = function (path, r) { + removeFolderCrumbsCleanUp(path); + vm.deleteFromInsideOfFolder = true; + path = vm.previousSearchQuery; + var opts = { + path: path + }; + vm.cleanArrays(); vm.Sites.remove(r, opts); }; vm.Sites.remove = function (r, opts) { - var deletedFolder; + debugger; if (!window.confirm("Delete files for this site?")) { return; } var pkg = Auth.oauth3.pkg('www@daplie.com'); - if (opts.path.includes('.')) { - deletedFolder = false; - } else { - deletedFolder = true; - } return pkg.remove({ - hostname: r.domain, - domain: r.domain, - tld: r.tld, - sld: r.sld, - // sub: vm.record.sub, - path: opts.path || r.path, - confirm: opts.confirm || r.confirm + hostname: r.domain + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: vm.record.sub + , path: opts.path || r.path + , confirm: opts.confirm || r.confirm }).then(function (result) { - var msg = "'"+ vm.pathRemoved + "'" + ' has been removed.'; - vm.buildNotification(result, msg); - if (deletedFolder) { - vm.cleanArrays(); - debugger; - vm.Sites.allContents(vm.copyR); - // vm.Sites.contents(vm.copyR, vm.previousSearchQuery); + vm.cleanArrays(); + if (vm.deleteFromInsideOfFolder) { + cleanPathQuery(vm.copyR.fromFolder); + vm.Sites.contents(vm.copyR, vm.cleanedPath); } else { - vm.cleanArrays(); - debugger; - var path = vm.breadcrumbsPath.join('/'); - cleanPathQuery(path); + cleanPathQuery(vm.breadcrumbsPath.join('/')); vm.Sites.contents(vm.copyR, vm.cleanedPath); } }); @@ -611,55 +563,14 @@ app.controller('websiteCtrl', [ }; vm.createNewFolder = function (r) { - if (r.shareAccess.path !== '/') { - if (vm.breadcrumbsPath.length === 0) { - vm.breadcrumbsPath = vm.strictPath.split('/'); - vm.breadcrumbsPath.pop(); - } else { - vm.breadcrumbsPath.push(vm.folderName); - r.folderName = vm.breadcrumbsPath.join('/'); - r.folderName = r.folderName + '/'; - } - } else { - if (vm.breadcrumbsPath.join('/') === '') { - r.folderName = '/' + vm.folderName + '/'; - } else { - r.folderName = vm.breadcrumbsPath.join('/') + '/' + vm.folderName + '/'; - } - } + r.folderName = vm.folderName; + vm.breadcrumbsPath.push(r.folderName); }; - vm.count = 0; - vm.isRoot = true; - vm.deletedFolder = false; vm.Sites.upload = function (r) { var pkg = Auth.oauth3.pkg('www@daplie.com'); - //analyzeFile(r.newFile, r); - if (r.folderName !== '' && r.folderName !== undefined) { - cleanPathQuery(r.folderName); - r.uploadPath = vm.cleanedPath; - } else { - if (!Array.isArray(vm.breadcrumbsPath)) { - vm.breadcrumbsPath = vm.breadcrumbsPath.split('/'); - vm.breadcrumbsPath.pop(); - } else { - if (vm.breadcrumbsPath[0] !== '') { - if (r.shareAccess.path !== '/') { - r.uploadPath = r.shareAccess.path; - } else { - r.uploadPath = r.shareAccess.path; - } - vm.breadcrumbsPath.unshift(''); - } - } - if (vm.breadcrumbsPath.join('/') !== '') { - r.uploadPath = vm.breadcrumbsPath.join('/') + '/' + vm.folderName + '/'; - r.uploadPath = cleanPathQuery(r.uploadPath); - } - } - if (vm.copyR.newFile) { - vm.copyR.fAmount = vm.count++; - } + cleanPathQuery(vm.breadcrumbsPath.join('/')) + r.uploadPath = vm.cleanedPath; vm._uploadFile(pkg, r); }; @@ -787,6 +698,7 @@ app.controller('websiteCtrl', [ vm.domains = els; $scope.domain = vm.domains; }); + vm.listSites(); vm.triggerDropdown = function() { @@ -802,7 +714,7 @@ app.controller('websiteCtrl', [ vm.siteFiles = []; vm.siteDirectories = []; if (vm.previousSearchQuery === undefined) { - vm.previousSearchQuery = '/'; + vm.previousSearchQuery = ''; } var getBreadcrumbsPath = vm.previousSearchQuery; vm.breadcrumbsPath = getBreadcrumbsPath.split('/'); @@ -812,6 +724,13 @@ app.controller('websiteCtrl', [ vm.breadcrumbs.push(crumb); } }); + console.log('vm.breadcrumbs ->', vm.breadcrumbs.join('/')); + console.log('vm.breadcrumbsPath ->', vm.breadcrumbsPath.join('/')); + console.log('vm.previousSearchQuery ->', vm.previousSearchQuery); + if (vm.copyR.shareAccess.path === '/') { + vm.breadcrumbs.push('root'); + vm.breadcrumbsPath.push(''); + } }; vm.checkShareRights = function (r) { diff --git a/templates/website.html b/templates/website.html index b84c0da..ca1e56c 100644 --- a/templates/website.html +++ b/templates/website.html @@ -157,7 +157,7 @@
- +

Files

diff --git a/templates/widgets/filetree.html b/templates/widgets/filetree.html index c5e99a8..9cbebf3 100644 --- a/templates/widgets/filetree.html +++ b/templates/widgets/filetree.html @@ -29,7 +29,7 @@