oops broke everything

This commit is contained in:
Jon Lambson 2017-10-02 15:25:23 -06:00
parent 5196f55629
commit 192a8b7933
2 changed files with 71 additions and 23 deletions

View File

@ -348,12 +348,54 @@ app.controller('websiteCtrl', [
vm.Sites.remove = function (r, opts) { 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) { function getPathToDelete(r, pathName) {
vm.autoPopulateWebPath; vm.autoPopulateWebPath;
if (vm.autoPopulateWebPath === undefined && opts !== undefined) { if (vm.autoPopulateWebPath === undefined && opts !== undefined) {
r.path = '/' + opts; r.path = '/' + opts;
} else { } else {
r.path = vm.autoPopulateWebPath + pathName; 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) { if (opts === undefined) {
opts = {}; opts = {};
@ -363,29 +405,35 @@ app.controller('websiteCtrl', [
opts.confirm = true; opts.confirm = true;
} }
} }
getPathToDelete(r, opts);
if (!window.confirm("Delete files for this site?")) {
return;
}
var pkg = Auth.oauth3.pkg('www@daplie.com');
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('the result', 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.breadcrumbs = ['Root']; vm.breadcrumbs = ['root'];
vm.breadcrumbsPath = ['/']; vm.breadcrumbsPath = ['/'];
vm.breadcrumbPathClicked = false; vm.breadcrumbPathClicked = false;
vm.webPathAutofill = '/'; vm.webPathAutofill = '/';
@ -407,8 +455,8 @@ app.controller('websiteCtrl', [
vm.autoPopulateWebPath = vm.autoPopulateWebPath.join(''); vm.autoPopulateWebPath = vm.autoPopulateWebPath.join('');
} }
if (vm.breadcrumbPathClicked) { if (vm.breadcrumbPathClicked) {
if (path === 'Root') { if (path === 'root') {
vm.breadcrumbs = ['Root']; vm.breadcrumbs = ['root'];
vm.breadcrumbsPath = ['/']; vm.breadcrumbsPath = ['/'];
vm.breadcrumbPathClicked = false; vm.breadcrumbPathClicked = false;
vm.autoPopulateWebPath = "/"; vm.autoPopulateWebPath = "/";

View File

@ -13,6 +13,7 @@
<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>
</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">
@ -52,7 +53,6 @@
</div> </div>
<div class="row"> <div class="row">
<div class="text-center"> <div class="text-center">
<span class="text-danger">TODO:// Fix functionality to delete ALL files...</span><br>
<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" ng-click="vm.Sites.remove(r)"><i class="fa fa-trash"></i> Remove all Files</button>
</div> </div>
</div> </div>