From 369cca98b51a1a6cb05c0df0613f6bd14792c677 Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Fri, 27 Oct 2017 17:11:28 -0600 Subject: [PATCH] better restrecited searches --- js/controllers/website-controller.js | 45 ++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 019340a..83769f7 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -360,6 +360,7 @@ app.controller('websiteCtrl', [ vm.Sites.allContents = function (r) { vm.copyR = r; var pkg = Auth.oauth3.pkg('www@daplie.com'); + debugger; return pkg.contents({ hostname: r.domain , domain: r.domain @@ -368,6 +369,8 @@ app.controller('websiteCtrl', [ //, sub: r.sub , path: r.shareAccess.path }).then(function (result) { + vm.cleanArrays(); + debugger; vm.folderStructure = result; result.data.forEach(function(data){ if (data.file) { @@ -395,11 +398,13 @@ app.controller('websiteCtrl', [ vm.Sites.contents = function (r, dir) { vm.siteFiles = []; vm.siteDirectories = []; + dir = dir + '/'; cleanPathQuery(dir); dir = vm.cleanedPath; vm.previousSearchQuery = dir; vm.displaySpinner = ''; var pkg = Auth.oauth3.pkg('www@daplie.com'); + debugger; return pkg.contents({ hostname: r.domain, domain: r.domain, @@ -419,6 +424,7 @@ app.controller('websiteCtrl', [ vm.siteDirectories.push(data.name); } }); + vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1]; }); }; @@ -426,10 +432,27 @@ app.controller('websiteCtrl', [ var str2arryQuery = cleanPathQuery(vm.breadcrumbsPath.join('/')); var str2arry = vm.breadcrumbs; str2arryQuery = str2arryQuery.split('/'); - var removeFromBreadcrumbsQuery = str2arryQuery.indexOf(crumb) + 1; - var removeFromBreadcrumbs = str2arry.indexOf(crumb) + 1; - vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery); - vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); + if (vm.copyR.shareAccess.path !== '/') { + var removeFromBreadcrumbsQuery = str2arryQuery.indexOf(crumb) + 1; + var removeFromBreadcrumbs = str2arry.indexOf(crumb) + 1; + vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery); + vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); + var strictPath = vm.strictPath.slice(0, -1); + if (vm.breadcrumbsPath.join('/').indexOf(strictPath) !== 0) { + vm.breadcrumbsPath = strictPath.split('/'); + vm.breadcrumbs = strictPath.split('/'); + vm.breadcrumbs.shift(); + var result = { data: { warning: true } }; + vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 2]; + var msg = "You can only view " + "'" + vm.currentFolder + "'"; + vm.buildNotification(result, msg); + } + } else { + var removeFromBreadcrumbsQuery = str2arryQuery.indexOf(crumb) + 1; + var removeFromBreadcrumbs = str2arry.indexOf(crumb) + 1; + vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery); + vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); + } }; var removeFolderCrumbsCleanUp = function (crumb) { @@ -441,6 +464,7 @@ app.controller('websiteCtrl', [ vm.breadcrumbsPath = str2arryQuery.splice(0,removeFromBreadcrumbsQuery); vm.breadcrumbs = str2arry.splice(0,removeFromBreadcrumbs); vm.copyR.fromFolder = vm.breadcrumbsPath.join('/'); + vm.currentFolder = vm.breadcrumbs[vm.breadcrumbs.length - 1]; }; vm.getDirectoriesFromBreadcrumbs = function (dir) { @@ -539,8 +563,9 @@ app.controller('websiteCtrl', [ sharePath = cleanPathQuery(vm.breadcrumbsPath.join('/')); sharePath = sharePath + '/'; } + cleanPathQuery(sharePath); opts = { - sharePath: sharePath, + sharePath: vm.cleanedPath, shareMode: vm.copiedShareMode }; vm.Shares.invite(r, opts); @@ -799,7 +824,15 @@ app.controller('websiteCtrl', [ hidden: '', message: msg }; - } else { + } else if (result.data.warning) { + vm.alertNotification = { + className: 'warning', + title: 'Warning', + hidden: '', + message: msg + }; + } + else { vm.alertNotification = { className: 'success', title: 'Success',