fixing a bunch of ifs
This commit is contained in:
parent
e2517c3c1e
commit
1fda0db360
|
@ -358,29 +358,17 @@ app.controller('websiteCtrl', [
|
||||||
vm.folderName = '';
|
vm.folderName = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.breadcrumbs = [];
|
|
||||||
vm.breadcrumbsPath = [''];
|
|
||||||
vm.siteDirectories = [];
|
|
||||||
vm.siteFiles = [];
|
|
||||||
vm.Sites.allContents = function (r) {
|
vm.Sites.allContents = function (r) {
|
||||||
vm.copyR = r;
|
vm.copyR = r;
|
||||||
vm.strictPath = r.shareAccess.path;
|
|
||||||
vm.previousSearchQuery = vm.strictPath;
|
|
||||||
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
||||||
return pkg.contents({
|
return pkg.contents({
|
||||||
hostname: r.domain,
|
hostname: r.domain
|
||||||
domain: r.domain,
|
, domain: r.domain
|
||||||
tld: r.tld,
|
, tld: r.tld
|
||||||
sld: r.sld,
|
, sld: r.sld
|
||||||
// sub: r.sub,
|
//, sub: r.sub
|
||||||
path: r.shareAccess.path
|
, path: r.shareAccess.path
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
debugger;
|
|
||||||
if (r.shareAccess.path !== '/') {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
vm.breadcrumbs.push('root');
|
|
||||||
}
|
|
||||||
vm.folderStructure = result;
|
vm.folderStructure = result;
|
||||||
result.data.forEach(function(data){
|
result.data.forEach(function(data){
|
||||||
if (data.file) {
|
if (data.file) {
|
||||||
|
@ -395,8 +383,22 @@ app.controller('websiteCtrl', [
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var cleanPathQuery = function (path) {
|
vm.Sites.contents = function (r) {
|
||||||
debugger;
|
debugger;
|
||||||
|
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: r.newPath
|
||||||
|
}).then(function (result) {
|
||||||
|
debugger;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var cleanPathQuery = function (path) {
|
||||||
vm.cleanedPath = path.replace(/\/+/g, '/');
|
vm.cleanedPath = path.replace(/\/+/g, '/');
|
||||||
return vm.cleanedPath;
|
return vm.cleanedPath;
|
||||||
};
|
};
|
||||||
|
@ -445,53 +447,29 @@ app.controller('websiteCtrl', [
|
||||||
vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs);
|
vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var removeFolderCrumbsCleanUp = function (crumb) {
|
||||||
|
var str2arryQuery = cleanPathQuery(vm.breadcrumbsPath.join('/'));
|
||||||
|
var str2arry = vm.breadcrumbs;
|
||||||
|
str2arryQuery = str2arryQuery.split('/');
|
||||||
|
var removeFromBreadcrumbsQuery = str2arryQuery.indexOf(crumb);
|
||||||
|
var removeFromBreadcrumbs = str2arry.indexOf(crumb);
|
||||||
|
vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery);
|
||||||
|
vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs);
|
||||||
|
vm.copyR.fromFolder = vm.breadcrumbsPath.join('/');
|
||||||
|
};
|
||||||
|
|
||||||
vm.getDirectoriesFromBreadcrumbs = function (dir) {
|
vm.getDirectoriesFromBreadcrumbs = function (dir) {
|
||||||
vm.isRoot = false;
|
crumbsCleanUp(dir);
|
||||||
if (vm.copyR.shareAccess.path !== '/') {
|
cleanPathQuery(vm.breadcrumbsPath.join('/'));
|
||||||
var strictArray = vm.copyR.shareAccess.path.split('/');
|
vm.Sites.contents(vm.copyR, vm.cleanedPath);
|
||||||
if (vm.breadcrumbsPath.join('/') === '') {
|
|
||||||
vm.breadcrumbsPath = strictArray;
|
|
||||||
} else {
|
|
||||||
crumbsCleanUp(dir);
|
|
||||||
}
|
|
||||||
vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/'));
|
|
||||||
} else {
|
|
||||||
crumbsCleanUp(dir);
|
|
||||||
vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/'));
|
|
||||||
}
|
|
||||||
vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1];
|
vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.getDirectories = function (dir) {
|
vm.getDirectories = function (dir) {
|
||||||
if (vm.copyR.shareAccess.path !== '/') {
|
vm.breadcrumbs.push(dir);
|
||||||
if (vm.breadcrumbsPath.length === 0) {
|
vm.breadcrumbsPath.push(dir);
|
||||||
var breadcrumblies = vm.strictPath + dir;
|
cleanPathQuery(vm.breadcrumbsPath.join('/'));
|
||||||
vm.breadcrumbsPath = breadcrumblies.split('/');
|
vm.Sites.contents(vm.copyR, vm.cleanedPath);
|
||||||
vm.breadcrumbs.push(dir);
|
|
||||||
} else {
|
|
||||||
if (vm.copyR.shareAccess.path !== '/' && vm.copyR.newFile) {
|
|
||||||
if (vm.count === 1) {
|
|
||||||
vm.breadcrumbsPath.push(dir);
|
|
||||||
vm.breadcrumbs.push(dir);
|
|
||||||
} else {
|
|
||||||
if (vm.isRoot) {
|
|
||||||
vm.breadcrumbsPath.pop();
|
|
||||||
}
|
|
||||||
vm.breadcrumbsPath.push(dir);
|
|
||||||
vm.breadcrumbs.push(dir);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vm.breadcrumbsPath.push(dir);
|
|
||||||
vm.breadcrumbs.push(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/'));
|
|
||||||
} else {
|
|
||||||
vm.breadcrumbs.push(dir);
|
|
||||||
vm.breadcrumbsPath.push(dir);
|
|
||||||
vm.breadcrumbsPath.unshift('');
|
|
||||||
vm.Sites.contents(vm.copyR, vm.breadcrumbsPath.join('/'));
|
|
||||||
}
|
|
||||||
vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1];
|
vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -503,77 +481,51 @@ app.controller('websiteCtrl', [
|
||||||
vm.Sites.remove(r, opts);
|
vm.Sites.remove(r, opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.deleteFilesFrom = function (r, opts) {
|
vm.deleteFilesFrom = function (r, file) {
|
||||||
var file = opts;
|
|
||||||
vm.pathRemoved = file;
|
vm.pathRemoved = file;
|
||||||
var requestedPath;
|
var path = vm.breadcrumbsPath.join('/');
|
||||||
if (r.shareAccess.path !== '/') {
|
path = path + '/' + file;
|
||||||
if (vm.breadcrumbsPath.length === 0) {
|
|
||||||
requestedPath = r.shareAccess.path + '/' + file;
|
|
||||||
} else {
|
|
||||||
if (r.shareAccess.path !== '/' && vm.breadcrumbsPath.join('/') !== '') {
|
|
||||||
requestedPath = vm.breadcrumbsPath.join('/') + '/' + file;
|
|
||||||
} else {
|
|
||||||
requestedPath = vm.breadcrumbsPath.join('/') + '/' + file;
|
|
||||||
if (vm.breadcrumbsPath.join('/') === '') {
|
|
||||||
requestedPath = vm.strictPath + '/' + file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (vm.breadcrumbsPath.length === 0 && r.shareAccess.path === '/') {
|
|
||||||
requestedPath = r.shareAccess.path + file;
|
|
||||||
} else {
|
|
||||||
requestedPath = vm.breadcrumbsPath.join('/') + '/' + file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opts = {
|
|
||||||
path: requestedPath
|
|
||||||
};
|
|
||||||
vm.Sites.remove(r, opts);
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.triggerDeleteFolder = function (path, r) {
|
|
||||||
vm.deletedFolder = true;
|
|
||||||
path = cleanPathQuery(path);
|
path = cleanPathQuery(path);
|
||||||
var opts = {
|
var opts = {
|
||||||
path: path
|
path: path
|
||||||
};
|
};
|
||||||
|
debugger;
|
||||||
|
vm.Sites.remove(r, opts);
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.deleteFromInsideOfFolder = false;
|
||||||
|
vm.triggerDeleteFolder = function (path, r) {
|
||||||
|
removeFolderCrumbsCleanUp(path);
|
||||||
|
vm.deleteFromInsideOfFolder = true;
|
||||||
|
path = vm.previousSearchQuery;
|
||||||
|
var opts = {
|
||||||
|
path: path
|
||||||
|
};
|
||||||
|
vm.cleanArrays();
|
||||||
vm.Sites.remove(r, opts);
|
vm.Sites.remove(r, opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.Sites.remove = function (r, opts) {
|
vm.Sites.remove = function (r, opts) {
|
||||||
var deletedFolder;
|
debugger;
|
||||||
if (!window.confirm("Delete files for this site?")) {
|
if (!window.confirm("Delete files for this site?")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
||||||
if (opts.path.includes('.')) {
|
|
||||||
deletedFolder = false;
|
|
||||||
} else {
|
|
||||||
deletedFolder = true;
|
|
||||||
}
|
|
||||||
return pkg.remove({
|
return pkg.remove({
|
||||||
hostname: r.domain,
|
hostname: r.domain
|
||||||
domain: r.domain,
|
, domain: r.domain
|
||||||
tld: r.tld,
|
, tld: r.tld
|
||||||
sld: r.sld,
|
, sld: r.sld
|
||||||
// sub: vm.record.sub,
|
//, sub: vm.record.sub
|
||||||
path: opts.path || r.path,
|
, path: opts.path || r.path
|
||||||
confirm: opts.confirm || r.confirm
|
, confirm: opts.confirm || r.confirm
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
var msg = "'"+ vm.pathRemoved + "'" + ' has been removed.';
|
vm.cleanArrays();
|
||||||
vm.buildNotification(result, msg);
|
if (vm.deleteFromInsideOfFolder) {
|
||||||
if (deletedFolder) {
|
cleanPathQuery(vm.copyR.fromFolder);
|
||||||
vm.cleanArrays();
|
vm.Sites.contents(vm.copyR, vm.cleanedPath);
|
||||||
debugger;
|
|
||||||
vm.Sites.allContents(vm.copyR);
|
|
||||||
// vm.Sites.contents(vm.copyR, vm.previousSearchQuery);
|
|
||||||
} else {
|
} else {
|
||||||
vm.cleanArrays();
|
cleanPathQuery(vm.breadcrumbsPath.join('/'));
|
||||||
debugger;
|
|
||||||
var path = vm.breadcrumbsPath.join('/');
|
|
||||||
cleanPathQuery(path);
|
|
||||||
vm.Sites.contents(vm.copyR, vm.cleanedPath);
|
vm.Sites.contents(vm.copyR, vm.cleanedPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -611,55 +563,14 @@ app.controller('websiteCtrl', [
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.createNewFolder = function (r) {
|
vm.createNewFolder = function (r) {
|
||||||
if (r.shareAccess.path !== '/') {
|
r.folderName = vm.folderName;
|
||||||
if (vm.breadcrumbsPath.length === 0) {
|
vm.breadcrumbsPath.push(r.folderName);
|
||||||
vm.breadcrumbsPath = vm.strictPath.split('/');
|
|
||||||
vm.breadcrumbsPath.pop();
|
|
||||||
} else {
|
|
||||||
vm.breadcrumbsPath.push(vm.folderName);
|
|
||||||
r.folderName = vm.breadcrumbsPath.join('/');
|
|
||||||
r.folderName = r.folderName + '/';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (vm.breadcrumbsPath.join('/') === '') {
|
|
||||||
r.folderName = '/' + vm.folderName + '/';
|
|
||||||
} else {
|
|
||||||
r.folderName = vm.breadcrumbsPath.join('/') + '/' + vm.folderName + '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.count = 0;
|
|
||||||
vm.isRoot = true;
|
|
||||||
vm.deletedFolder = false;
|
|
||||||
vm.Sites.upload = function (r) {
|
vm.Sites.upload = function (r) {
|
||||||
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
var pkg = Auth.oauth3.pkg('www@daplie.com');
|
||||||
//analyzeFile(r.newFile, r);
|
cleanPathQuery(vm.breadcrumbsPath.join('/'))
|
||||||
if (r.folderName !== '' && r.folderName !== undefined) {
|
r.uploadPath = vm.cleanedPath;
|
||||||
cleanPathQuery(r.folderName);
|
|
||||||
r.uploadPath = vm.cleanedPath;
|
|
||||||
} else {
|
|
||||||
if (!Array.isArray(vm.breadcrumbsPath)) {
|
|
||||||
vm.breadcrumbsPath = vm.breadcrumbsPath.split('/');
|
|
||||||
vm.breadcrumbsPath.pop();
|
|
||||||
} else {
|
|
||||||
if (vm.breadcrumbsPath[0] !== '') {
|
|
||||||
if (r.shareAccess.path !== '/') {
|
|
||||||
r.uploadPath = r.shareAccess.path;
|
|
||||||
} else {
|
|
||||||
r.uploadPath = r.shareAccess.path;
|
|
||||||
}
|
|
||||||
vm.breadcrumbsPath.unshift('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vm.breadcrumbsPath.join('/') !== '') {
|
|
||||||
r.uploadPath = vm.breadcrumbsPath.join('/') + '/' + vm.folderName + '/';
|
|
||||||
r.uploadPath = cleanPathQuery(r.uploadPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vm.copyR.newFile) {
|
|
||||||
vm.copyR.fAmount = vm.count++;
|
|
||||||
}
|
|
||||||
vm._uploadFile(pkg, r);
|
vm._uploadFile(pkg, r);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -787,6 +698,7 @@ app.controller('websiteCtrl', [
|
||||||
vm.domains = els;
|
vm.domains = els;
|
||||||
$scope.domain = vm.domains;
|
$scope.domain = vm.domains;
|
||||||
});
|
});
|
||||||
|
|
||||||
vm.listSites();
|
vm.listSites();
|
||||||
|
|
||||||
vm.triggerDropdown = function() {
|
vm.triggerDropdown = function() {
|
||||||
|
@ -802,7 +714,7 @@ app.controller('websiteCtrl', [
|
||||||
vm.siteFiles = [];
|
vm.siteFiles = [];
|
||||||
vm.siteDirectories = [];
|
vm.siteDirectories = [];
|
||||||
if (vm.previousSearchQuery === undefined) {
|
if (vm.previousSearchQuery === undefined) {
|
||||||
vm.previousSearchQuery = '/';
|
vm.previousSearchQuery = '';
|
||||||
}
|
}
|
||||||
var getBreadcrumbsPath = vm.previousSearchQuery;
|
var getBreadcrumbsPath = vm.previousSearchQuery;
|
||||||
vm.breadcrumbsPath = getBreadcrumbsPath.split('/');
|
vm.breadcrumbsPath = getBreadcrumbsPath.split('/');
|
||||||
|
@ -812,6 +724,13 @@ app.controller('websiteCtrl', [
|
||||||
vm.breadcrumbs.push(crumb);
|
vm.breadcrumbs.push(crumb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('vm.breadcrumbs ->', vm.breadcrumbs.join('/'));
|
||||||
|
console.log('vm.breadcrumbsPath ->', vm.breadcrumbsPath.join('/'));
|
||||||
|
console.log('vm.previousSearchQuery ->', vm.previousSearchQuery);
|
||||||
|
if (vm.copyR.shareAccess.path === '/') {
|
||||||
|
vm.breadcrumbs.push('root');
|
||||||
|
vm.breadcrumbsPath.push('');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.checkShareRights = function (r) {
|
vm.checkShareRights = function (r) {
|
||||||
|
|
|
@ -157,7 +157,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="square-service-block">
|
<div class="square-service-block">
|
||||||
<a ng-click="vm.cleanArrays(); vm.showAction('files'); vm.Sites.allContents(r); vm.closeFileUploadsContainers();" class="cp trigger-files-list-refresh">
|
<a ng-click="vm.showAction('files'); vm.Sites.allContents(r); vm.cleanArrays(); vm.closeFileUploadsContainers();" class="cp trigger-files-list-refresh">
|
||||||
<div class="ssb-icon"><i class="fa fa-sitemap" aria-hidden="true"></i></div>
|
<div class="ssb-icon"><i class="fa fa-sitemap" aria-hidden="true"></i></div>
|
||||||
<h2 class="ssb-title">Files</h2>
|
<h2 class="ssb-title">Files</h2>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<ul class="ls-none folder-actions-list">
|
<ul class="ls-none folder-actions-list">
|
||||||
<li ng-if="r.shareAccess.write"><span><i class="fa fa-upload cp"></i> <a ng-click="vm.autoPopulateFolderName(); vm.uploadFileContainer = true; vm.uploadFolderContainer = false; vm.cleanUploads(r);" class="cp">Upload files</a></span></li>
|
<li ng-if="r.shareAccess.write"><span><i class="fa fa-upload cp"></i> <a ng-click="vm.autoPopulateFolderName(); vm.uploadFileContainer = true; vm.uploadFolderContainer = false; vm.cleanUploads(r);" class="cp">Upload files</a></span></li>
|
||||||
<li ng-if="r.shareAccess.write"><span><i class="fa fa-folder cp"></i> <a ng-click="vm.uploadFolderContainer = true; vm.uploadFileContainer = false; vm.cleanUploads(r);" class="cp">New folder</a></span></li>
|
<li ng-if="r.shareAccess.write"><span><i class="fa fa-folder cp"></i> <a ng-click="vm.uploadFolderContainer = true; vm.uploadFileContainer = false; vm.cleanUploads(r);" class="cp">New folder</a></span></li>
|
||||||
<li ng-if="r.shareAccess.write"><span><i class="fa fa-trash cp"></i> <a ng-click="vm.triggerDeleteFolder(vm.breadcrumbsPath.join('/'), r); vm.cleanUploads(r);" data="{{ vm.currentFolder }}" class="cp">Delete {{ vm.currentFolder | capitalize }} Folder</a></span></li>
|
<li ng-if="r.shareAccess.write"><span><i class="fa fa-trash cp"></i> <a ng-click="vm.triggerDeleteFolder(vm.currentFolder, r); vm.cleanUploads(r);" data="{{ vm.currentFolder }}" class="cp">Delete {{ vm.currentFolder | capitalize }} Folder</a></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue