fixing way to delete site files

This commit is contained in:
Jon Lambson 2017-10-02 16:49:56 -06:00
parent 192a8b7933
commit fdc993f7b3
2 changed files with 39 additions and 84 deletions

View File

@ -346,92 +346,47 @@ app.controller('websiteCtrl', [
}); });
}; };
vm.Sites.remove = function (r, opts) { vm.Sites.remove = function (r, opts) {
var pkg = Auth.oauth3.pkg('www@daplie.com'); 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; 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 return pkg.remove({
// if (vm.currentDirectoryFilesCount === 1 && vm.currentDirectoryDirectoriesCount === 0) { hostname: r.domain
// debugger; , domain: r.domain
// r.path = vm.autoPopulateWebPath; , tld: r.tld
// return pkg.remove({ , sld: r.sld
// hostname: r.domain //, sub: vm.record.sub
// , domain: r.domain , path: opts.path || r.path
// , tld: r.tld , confirm: opts.confirm || r.confirm
// , sld: r.sld }).then(function (result) {
// //, sub: vm.record.sub window.alert(JSON.stringify(result));
// , 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;
}
}
}; };
vm.checkForOthers = function (r) { vm.deleteFilesFrom = function (r, path, opts) {
vm.isOtherDirectories = []; var confirmMessage;
vm.isOtherFiles = []; vm.autoPopulateWebPath;
vm.currentDirectoryDirectoriesCount = 0; opts = {};
vm.currentDirectoryFilesCount = 0; if (path === undefined) {
var pkg = Auth.oauth3.pkg('www@daplie.com'); confirmMessage = "Delete all files for this site?";
return pkg.contents({ opts.path = '/';
hostname: r.domain, opts.confirm = true;
domain: r.domain, } else if (path.includes(".")) {
tld: r.tld, confirmMessage = "Delete this file?";
sld: r.sld, if (vm.autoPopulateWebPath === undefined) {
//, sub: r.sub, opts.path = path;
path: vm.autoPopulateWebPath } else {
}).then(function (result) { opts.path = vm.autoPopulateWebPath + path;
result.data.forEach(function(file){ }
if (file.file) { } else {
vm.isOtherFiles.push(file); confirmMessage = "Delete all items in this folder?";
vm.currentDirectoryFilesCount = vm.isOtherFiles.length; opts.path = vm.autoPopulateWebPath + path;
} else if (file.directory) { }
vm.isOtherDirectories.push(file); if (!window.confirm(confirmMessage)) {
vm.currentDirectoryDirectoriesCount = vm.isOtherDirectories.length; return;
} }
}); vm.Sites.remove(r, opts)
}); };
}
vm.breadcrumbs = ['root']; vm.breadcrumbs = ['root'];
vm.breadcrumbsPath = ['/']; vm.breadcrumbsPath = ['/'];

View File

@ -11,13 +11,13 @@
<ul class="tree ls-none"> <ul class="tree ls-none">
<li class="directories-go-here" ng-repeat="directory in vm.siteDirectories track by $index"> <li class="directories-go-here" ng-repeat="directory in vm.siteDirectories track by $index">
<input type="checkbox" id="{{ r.challenge }}{{ $index }}" /> <input type="checkbox" id="{{ r.challenge }}{{ $index }}" />
<label class="tree_label" for="{{ r.challenge }}{{ $index }}" ng-click="vm.getDirectories(directory); vm.showUploadContainer = false" data="{{ directory }}">{{ directory }}</label> <label class="tree_label" for="{{ r.challenge }}{{ $index }}" ng-click="vm.getDirectories(directory); vm.showUploadContainer = false" data="{{ directory }}">{{ directory }}</label><span class="pull-right"><button type="button" class="btn btn-danger btn-xs" ng-click="vm.deleteFilesFrom(r, directory)" data="{{ directory }}" data="{{ r }}"><i class="fa fa-trash"></i> Folder</button></span>
</li> </li>
<li></li> <li></li>
</ul> </ul>
<ul class="tree files-only ls-none"> <ul class="tree files-only ls-none">
<li ng-repeat="file in vm.siteFiles track by $index"> <li ng-repeat="file in vm.siteFiles track by $index">
<span class="tree_label filez">{{ file }}</span><span class="pull-right"><button type="button" class="btn btn-danger btn-xs" ng-click="vm.Sites.remove(r, file)" data="{{ file }}" data="{{ r }}"><i class="fa fa-trash"></i></button></span> <span class="tree_label filez">{{ file }}</span><span class="pull-right"><button type="button" class="btn btn-danger btn-xs" ng-click="vm.deleteFilesFrom(r, file)" data="{{ file }}" data="{{ r }}"><i class="fa fa-trash"></i> File</button></span>
</li> </li>
<li class="move-back"> <li class="move-back">
<a ng-click="vm.showUploadContainer = true;"><i class="fa fa-plus"></i> Add Files</a> <a ng-click="vm.showUploadContainer = true;"><i class="fa fa-plus"></i> Add Files</a>
@ -52,8 +52,8 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="text-center"> <div class="">
<button type="button" class="btn btn-danger" ng-click="vm.Sites.remove(r)"><i class="fa fa-trash"></i> Remove all Files</button> <button type="button" class="btn btn-danger pull-right" ng-click="vm.deleteFilesFrom(r, path)"><i class="fa fa-trash"></i> Remove all Files</button>
</div> </div>
</div> </div>
</div> </div>