remove all stupid javascript

This commit is contained in:
Jon Lambson 2017-10-17 10:22:21 -06:00
parent 1e934927a4
commit 5314114b4b
1 changed files with 7 additions and 202 deletions

View File

@ -337,29 +337,17 @@ app.controller('websiteCtrl', [
}); });
}; };
vm.Sites.setUpload = function (r) { vm.Sites.setUpload = function (r) {
console.log("Hey! At least it can tell if there's a change!"); console.log("Hey! At least it can tell if there's a change!");
if (r.newFile === undefined) {
r.newFile = vm.newFile;
}
analyzeFile(r.newFile, r); analyzeFile(r.newFile, r);
vm.showCompleteFileUploadBtn = true;
console.log(r); console.log(r);
}; };
vm.Sites.upload = function (r) {
if (r.uploadPath === undefined) {
r.uploadPath = vm.breadcrumbsPath.join('/');
} else {
r.uploadPath = vm.breadcrumbsPath.join('/') + vm.autoPopulateWebPath;
}
vm.copyr = r;
var pkg = Auth.oauth3.pkg('www@daplie.com');
//analyzeFile(r.newFile, r);
vm._uploadFile(pkg, r);
};
vm.Sites.archive = function (r) { vm.Sites.archive = function (r) {
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
return pkg.archive({ return pkg.archive({
hostname: r.domain hostname: r.domain
, domain: r.domain , domain: r.domain
@ -374,199 +362,13 @@ app.controller('websiteCtrl', [
}); });
}; };
vm.Sites.remove = function (r, opts) {
var pkg = Auth.oauth3.pkg('www@daplie.com');
vm.pathRemoved = opts.path;
return pkg.remove({
hostname: r.domain
, domain: r.domain
, tld: r.tld
, sld: r.sld
//, sub: vm.record.sub
, path: opts.path
, confirm: opts.confirm || r.confirm
}).then(function (result) {
var msg = "'"+ vm.pathRemoved + "'" + ' has been removed';
vm.buildNotification(result, msg);
// window.alert(JSON.stringify(result));
});
};
vm.deleteFilesFrom = function (r, path, opts) {
var confirmMessage;
opts = {};
if (path === undefined) {
confirmMessage = "Delete all files for this site?";
opts.path = '/';
opts.confirm = true;
vm.deleteAll = 'true';
} else if (path.includes(".")) {
confirmMessage = "Delete this file?";
if (vm.autoPopulateWebPath === undefined) {
opts.path = r.shareAccess.path + path;
} else {
opts.path = vm.autoPopulateWebPath + path;
}
} else {
confirmMessage = "Delete all items in this folder?";
if (vm.autoPopulateWebPath === undefined) {
opts.path = path;
} else if (vm.autoPopulateWebPath.includes(path)) {
opts.path = vm.autoPopulateWebPath;
} else {
opts.path = vm.autoPopulateWebPath + path;
}
opts.confirm = true;
}
if (!window.confirm(confirmMessage)) {
return;
}
vm.Sites.remove(r, opts);
};
vm.breadcrumbs = ['root'];
vm.breadcrumbsPath = ['/'];
vm.breadcrumbPathClicked = false;
vm.webPathAutofill = '/';
vm.Sites.contents = function (r) {
vm.siteResults = r;
vm.directoryPath = r.newPath;
vm.siteDirectories = [];
vm.siteFiles = [];
var pkg = Auth.oauth3.pkg('www@daplie.com');
vm.getSiteContents = function (site, newPath) {
newPath = site;
site = vm.siteResults;
function updatePath (path) {
vm.currentFolder = path;
if (typeof path !== 'object') {
vm.breadcrumbs.push(path);
vm.breadcrumbsPath.push(path);
vm.autoPopulateWebPath = vm.breadcrumbsPath;
vm.autoPopulateWebPath.push('/');
vm.autoPopulateWebPath = vm.autoPopulateWebPath.join('');
} else {
vm.currentFolder = "hidden";
}
if (vm.breadcrumbPathClicked) {
if (path === 'root') {
vm.breadcrumbs = ['root'];
vm.breadcrumbsPath = ['/'];
vm.breadcrumbPathClicked = false;
vm.autoPopulateWebPath = "/";
vm.showUploadContainer = false;
} else {
var breadcrumbsPath = vm.breadcrumbsPath;
var breadcrumbs = vm.breadcrumbs;
var removeFromBreadcrumbsPath = breadcrumbsPath.indexOf(path) + 1;
var removeFromBreadcrumbs = breadcrumbs.indexOf(path) + 1;
vm.breadcrumbsPath = breadcrumbsPath.splice(0,removeFromBreadcrumbsPath);
vm.breadcrumbs = breadcrumbs.splice(0,removeFromBreadcrumbs);
var updatebreadcrumbsPath = vm.breadcrumbsPath;
vm.autoPopulateWebPath = updatebreadcrumbsPath.join('');
vm.autoPopulateWebPath = vm.autoPopulateWebPath + '/';
vm.breadcrumbsPath.push('/');
debugger;
}
}
if (site.shareAccess !== undefined) {
if (site.shareAccess.path !== '/') {
vm.strictBreadcrumbs = site.shareAccess.path;
vm.breadcrumbsPath = site.shareAccess.path.split('/');
vm.breadcrumbs = site.shareAccess.path.split('/');
if (vm.requestSearchPath !== undefined && vm.requestSearchPath.includes(vm.strictBreadcrumbs)) {
vm.breadcrumbsPath = vm.requestSearchPath.split('/');
var lastItem = vm.breadcrumbsPath[vm.breadcrumbsPath.length - 1];
vm.breadcrumbs.pop();
vm.breadcrumbs.push(lastItem);
}
if (vm.breadcrumbPathClicked) {
debugger
}
}
}
}
updatePath(newPath);
return pkg.contents({
hostname: site.domain,
domain: site.domain,
tld: site.tld,
sld: site.sld,
//, sub: r.sub,
path: vm.breadcrumbsPath.join('/')
}).then(function (result) {
vm.displaySpinner = 'hidden';
vm.folderStructure = result;
result.data.forEach(function(file) {
if (file.directory) {
vm.siteDirectories.push(file.name);
} else if (file.file) {
vm.siteFiles.push(file.name);
}
});
});
};
vm.getSiteContents(r);
};
vm.cleanPath = function () {
vm.savedPath = vm.autoPopulateWebPath;
vm.autoPopulateWebPath = '';
vm.hideFolderInput = '';
vm.showUploadFilesContainer = false;
vm.showCompleteFileUploadBtn = false;
vm.showUploadFolderContainer = false;
};
vm.showUploadButton = true;
vm.showFolderAction = true;
vm.createNewFolder = function (r) {
if (vm.savedPath === undefined) {
vm.savedPath = '/';
}
vm.hideFolderInput = 'hidden';
vm.showFileUploadBtn = true;
r.uploadPath = vm.savedPath + vm.autoPopulateWebPath;
};
vm.autoPopulateFolderName = function () {
if (vm.currentFolder === 'hidden') {
vm.autoPopulateWebPath = '/';
}
};
vm.getDirectories = function (path) {
vm.displaySpinner = '';
vm.siteDirectories = [];
vm.siteFiles = [];
var site = vm.siteResults;
vm.directoryPath = path;
path = site.shareAccess.path + path;
vm.requestSearchPath = path;
vm.getSiteContents(path, site);
vm.showUploadButton = false;
vm.showFolderAction = false;
};
vm.getDirectoriesFromBreadcrumbs = function (dir) {
if (dir === 'root') {
vm.showFolderAction = true;
vm.showUploadButton = true;
} else {
vm.showFolderAction = false;
vm.showUploadButton = false;
}
vm.breadcrumbPathClicked = true;
vm.siteDirectories = [];
vm.siteFiles = [];
vm.getSiteContents(dir);
};
vm.triggerDeleteFolder = function (folder, r) {
vm.deleteFilesFrom(r, folder);
};
vm.doSomething = function (r) { vm.doSomething = function (r) {
window.alert("Fix me"); window.alert("Fix me");
@ -612,6 +414,7 @@ app.controller('websiteCtrl', [
// window.alert(JSON.stringify(result.data)); // window.alert(JSON.stringify(result.data));
}); });
}; };
vm.Shares.accept = function () { vm.Shares.accept = function () {
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
return pkg.acceptInvite({ return pkg.acceptInvite({
@ -621,6 +424,7 @@ app.controller('websiteCtrl', [
vm.listSites(); vm.listSites();
}); });
}; };
vm.Shares.list = function (r) { vm.Shares.list = function (r) {
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
return pkg.listShares({ return pkg.listShares({
@ -641,6 +445,7 @@ app.controller('websiteCtrl', [
//r.usersnames = r.sharedWith.map().join(','); //r.usersnames = r.sharedWith.map().join(',');
}); });
}; };
vm.Shares.remove = function (r, s) { vm.Shares.remove = function (r, s) {
console.log('Shares.remove'); console.log('Shares.remove');
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');