fixing way to delete site files

This commit is contained in:
Jon Lambson 2017-10-02 16:49:56 -06:00
rodič 192a8b7933
revize fdc993f7b3
2 změnil soubory, kde provedl 39 přidání a 84 odebrání

Zobrazit soubor

@ -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 = ['/'];

Zobrazit soubor

@ -11,13 +11,13 @@
<ul class="tree ls-none">
<li class="directories-go-here" ng-repeat="directory in vm.siteDirectories track by $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>
</ul>
<ul class="tree files-only ls-none">
<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 class="move-back">
<a ng-click="vm.showUploadContainer = true;"><i class="fa fa-plus"></i> Add Files</a>
@ -52,8 +52,8 @@
</div>
</div>
<div class="row">
<div class="text-center">
<button type="button" class="btn btn-danger" ng-click="vm.Sites.remove(r)"><i class="fa fa-trash"></i> Remove all Files</button>
<div class="">
<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>