From fdc993f7b33701d90b343f3d127a7726766d4647 Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Mon, 2 Oct 2017 16:49:56 -0600 Subject: [PATCH] fixing way to delete site files --- js/controllers/website-controller.js | 115 ++++++++------------------- templates/widgets/filetree.html | 8 +- 2 files changed, 39 insertions(+), 84 deletions(-) diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 75e1163..357133d 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -346,92 +346,47 @@ app.controller('websiteCtrl', [ }); }; - vm.Sites.remove = function (r, opts) { var pkg = Auth.oauth3.pkg('www@daplie.com'); - - getPathToDelete(r, opts); - - if (!window.confirm("Delete files for this site?")) { - return; - } - - vm.checkForOthers(r); - // 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 - // }).then(function (result) { - // window.alert(JSON.stringify(result)); - // }); debugger; - function getPathToDelete(r, pathName) { - vm.autoPopulateWebPath; - if (vm.autoPopulateWebPath === undefined && opts !== undefined) { - r.path = '/' + opts; - } else { - r.path = vm.autoPopulateWebPath + pathName; - // Delete the directory if there is no other files or directories inside - // if (vm.currentDirectoryFilesCount === 1 && vm.currentDirectoryDirectoriesCount === 0) { - // debugger; - // r.path = vm.autoPopulateWebPath; - // 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 - // }).then(function (result) { - // // console.log('result', result); - // }); - // } else { - // console.log('do it'); - // } - - - } - if (opts === undefined) { - opts = {}; - r.path = '/'; - opts.path = '/'; - r.confirm = true; - opts.confirm = 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 + }).then(function (result) { + window.alert(JSON.stringify(result)); + }); }; - vm.checkForOthers = function (r) { - vm.isOtherDirectories = []; - vm.isOtherFiles = []; - vm.currentDirectoryDirectoriesCount = 0; - vm.currentDirectoryFilesCount = 0; - 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: vm.autoPopulateWebPath - }).then(function (result) { - result.data.forEach(function(file){ - if (file.file) { - vm.isOtherFiles.push(file); - vm.currentDirectoryFilesCount = vm.isOtherFiles.length; - } else if (file.directory) { - vm.isOtherDirectories.push(file); - vm.currentDirectoryDirectoriesCount = vm.isOtherDirectories.length; - } - }); - }); - } + vm.deleteFilesFrom = function (r, path, opts) { + var confirmMessage; + vm.autoPopulateWebPath; + opts = {}; + if (path === undefined) { + confirmMessage = "Delete all files for this site?"; + opts.path = '/'; + opts.confirm = true; + } else if (path.includes(".")) { + confirmMessage = "Delete this file?"; + if (vm.autoPopulateWebPath === undefined) { + opts.path = path; + } else { + opts.path = vm.autoPopulateWebPath + path; + } + } else { + confirmMessage = "Delete all items in this folder?"; + opts.path = vm.autoPopulateWebPath + path; + } + if (!window.confirm(confirmMessage)) { + return; + } + vm.Sites.remove(r, opts) + }; vm.breadcrumbs = ['root']; vm.breadcrumbsPath = ['/']; diff --git a/templates/widgets/filetree.html b/templates/widgets/filetree.html index 7444728..5fb2c6c 100644 --- a/templates/widgets/filetree.html +++ b/templates/widgets/filetree.html @@ -11,13 +11,13 @@