some validations

This commit is contained in:
Jon Lambson 2017-10-16 14:56:35 -06:00
parent 2c696b642b
commit 107b6549c9
3 changed files with 71 additions and 35 deletions

View File

@ -348,9 +348,9 @@ app.controller('websiteCtrl', [
};
vm.Sites.upload = function (r) {
if (r.uploadPath === undefined) {
r.uploadPath = vm.breadcrumbsPath.join('');
r.uploadPath = vm.breadcrumbsPath.join('/');
} else {
r.uploadPath = vm.breadcrumbsPath.join('') + vm.autoPopulateWebPath;
r.uploadPath = vm.breadcrumbsPath.join('/') + vm.autoPopulateWebPath;
}
vm.copyr = r;
var pkg = Auth.oauth3.pkg('www@daplie.com');
@ -376,14 +376,14 @@ app.controller('websiteCtrl', [
vm.Sites.remove = function (r, opts) {
var pkg = Auth.oauth3.pkg('www@daplie.com');
vm.pathRemoved = r.path || opts.path;
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 || r.path
, path: opts.path
, confirm: opts.confirm || r.confirm
}).then(function (result) {
var msg = "'"+ vm.pathRemoved + "'" + ' has been removed';
@ -403,7 +403,7 @@ app.controller('websiteCtrl', [
} else if (path.includes(".")) {
confirmMessage = "Delete this file?";
if (vm.autoPopulateWebPath === undefined) {
opts.path = path;
opts.path = r.shareAccess.path + path;
} else {
opts.path = vm.autoPopulateWebPath + path;
}
@ -465,7 +465,15 @@ app.controller('websiteCtrl', [
vm.breadcrumbs = breadcrumbs.splice(0,removeFromBreadcrumbs);
var updatebreadcrumbsPath = vm.breadcrumbsPath;
vm.autoPopulateWebPath = updatebreadcrumbsPath.join('');
vm.autoPopulateWebPath = vm.autoPopulateWebPath+"/";
vm.autoPopulateWebPath = vm.autoPopulateWebPath + '/';
vm.breadcrumbsPath.push('/');
}
}
if (site.shareAccess !== undefined) {
if (site.shareAccess.path !== '/') {
vm.breadcrumbsPath = site.shareAccess.path.split('/');
vm.breadcrumbs = site.shareAccess.path.split('/');
vm.breadcrumbs.splice(0,1,'root');
}
}
}
@ -519,6 +527,7 @@ app.controller('websiteCtrl', [
};
vm.getDirectories = function (path) {
debugger;
vm.displaySpinner = '';
vm.siteDirectories = [];
vm.siteFiles = [];
@ -530,6 +539,7 @@ app.controller('websiteCtrl', [
};
vm.getDirectoriesFromBreadcrumbs = function (dir) {
debugger;
if (dir === 'root') {
vm.showFolderAction = true;
vm.showUploadButton = true;
@ -702,6 +712,27 @@ app.controller('websiteCtrl', [
}, 0);
};
vm.checkShareRights = function (r) {
if (r.invitedBy) {
r.shareAccess = { write: false, read: false, invite: false };
if (r.mode.includes('w')) {
r.shareAccess.write = true;
}
if (r.mode.includes('r')) {
r.shareAccess.read = true;
}
if (r.mode.includes('x')) {
r.shareAccess.invite = true;
}
r.shareAccess.path = r.path;
console.log(r.shareAccess);
} else {
r.shareAccess = { write: true, read: true, invite: true, path: '/' };
}
};
$scope.$watch('vm.selectedDomain', function (domainSelected) {
if (domainSelected !== undefined) {
vm.dom = domainSelected.description;

View File

@ -120,7 +120,7 @@
<div class="card__content">
<div class="card__title text-center"><a ng-href="https://{{ r.domain }}" target="_blank" ng-bind="r.domain">example.com</a></div>
<div class="cards__title text-center"><span ng-if="r.pending" class="text-muted">(pending)</span></div>
<button class="btn btn--block card__btn" data-toggle="modal" data-target=".{{ r.challenge }}" ng-click="vm.closeAllOpenActions()">Edit</button>
<button class="btn btn--block card__btn" data-toggle="modal" data-target=".{{ r.challenge }}" ng-click="vm.closeAllOpenActions(); vm.checkShareRights(r);">Edit</button>
</div>
</div>
</li>
@ -157,7 +157,7 @@
</div>
<div class="col-md-3">
<div class="square-service-block">
<a ng-click="vm.showAction('files'); vm.Sites.contents(r)" class="cp trigger-files-list-refresh">
<a ng-click="vm.showAction('files'); vm.Sites.contents(r);" class="cp trigger-files-list-refresh">
<div class="ssb-icon"><i class="fa fa-sitemap" aria-hidden="true"></i></div>
<h2 class="ssb-title">Files</h2>
</a>
@ -192,28 +192,33 @@
</div>
</div>
<div ng-show="vm.showInviteContainer">
<h1><i class="fa fa-folder"></i> {{ vm.currentFolder | capitalize }}</h1>
<form class="form-horizontal">
<div ng-if="r.shareAccess.invite">
<h1><i class="fa fa-folder"></i> {{ vm.currentFolder | capitalize }}</h1>
<form class="form-horizontal">
<div class="form-group">
<label class="col-md-1 control-label" for="">To:</label>
<div class="col-md-8">
<input type="text" ng-model="r.shareEmail" class="form-control" placeholder="ex: john@example.com" />
<input type="hidden" ng-model="vm.autoPopulateWebPath" class="form-control" placeholder="/" disabled />
<div class="form-group">
<label class="col-md-1 control-label" for="">To:</label>
<div class="col-md-8">
<input type="text" ng-model="r.shareEmail" class="form-control" placeholder="ex: john@example.com" />
<input type="hidden" ng-model="vm.autoPopulateWebPath" class="form-control" placeholder="/" disabled />
</div>
<div class="col-md-3">
<multiselect class="input-xlarge" multiple="true"
ng-model="selectedAccess"
options="c.name for c in accessLevel"
change="selected()"
ng-change="showShareBtn = true">
</multiselect>
</div>
</div>
<div class="col-md-3">
<multiselect class="input-xlarge" multiple="true"
ng-model="selectedAccess"
options="c.name for c in accessLevel"
change="selected()"
ng-change="showShareBtn = true">
</multiselect>
<div class="text-right" ng-show="showShareBtn">
<button type="submit" class="btn btn-success text-center" ng-click="vm.Shares.invite(r)">Share</button>
</div>
</div>
<div class="text-right" ng-show="showShareBtn">
<button type="submit" class="btn btn-success text-center" ng-click="vm.Shares.invite(r)">Share</button>
</div>
</form>
</form>
</div>
<div ng-if="!r.shareAccess.invite">
<h3 class="text-muted">You do not have the correct permissions to invite or share files...</h3>
</div>
</div>
<div ng-show="vm.showSharesContainer">
<div class="text-center {{ vm.displaySpinner }}">

View File

@ -14,23 +14,23 @@
<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.cleanPath();" 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 }}" ><i class="fa fa-trash"></i></button></span>
<label class="tree_label" for="{{ r.challenge }}{{ $index }}" ng-click="vm.getDirectories(directory); vm.cleanPath();" data="{{ directory }}">{{ directory }}</label><span class="pull-right"><button ng-if="r.shareAccess.write" type="button" class="btn btn-danger btn-xs" ng-click="vm.deleteFilesFrom(r, directory)" data="{{ directory }}" ><i class="fa fa-trash"></i></button></span>
</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.deleteFilesFrom(r, file)" data="{{ file }}" ><i class="fa fa-trash"></i></button></span><br>
<span class="tree_label filez">{{ file }}</span><span class="pull-right"><button ng-if="r.shareAccess.write" type="button" class="btn btn-danger btn-xs" ng-click="vm.deleteFilesFrom(r, file)" data="{{ file }}" ><i class="fa fa-trash"></i></button></span><br>
</li>
</ul>
<div class="folder-actions">
<hr>
<div class="">
<button type="button" name="button" class="btn btn-block btn-primary" ng-click="vm.showUploadFilesContainer = true; vm.autoPopulateFolderName(); vm.showUploadFolderContainer = false" ng-show="vm.showUploadButton">Upload files</button>
<button type="button" name="button" class="btn btn-block btn-primary" ng-click="vm.showAction('invite');">Share folder</button>
<button ng-if="r.shareAccess.write" type="button" name="button" class="btn btn-block btn-primary" ng-click="vm.showUploadFilesContainer = true; vm.autoPopulateFolderName(); vm.showUploadFolderContainer = false" ng-show="vm.showUploadButton">Upload files</button>
<button ng-if="r.shareAccess.invite" type="button" name="button" class="btn btn-block btn-primary" ng-click="vm.showAction('invite');">Share folder</button>
<ul class="ls-none folder-actions-list">
<li class="" ng-hide="vm.showFolderAction"><span><i class="fa fa-upload cp"></i> <a ng-click="vm.showUploadFilesContainer = true; vm.autoPopulateFolderName(); vm.showUploadFolderContainer = false;" class="cp">Upload files</a></span></li>
<li class=""><span><i class="fa fa-folder cp"></i> <a ng-click="vm.cleanPath(); vm.showUploadFolderContainer = true; vm.showFileUploadBtn = false;" class="cp">New folder</a></span></li>
<li ng-hide="vm.showUploadButton"><span><i class="fa fa-trash cp"></i> <a ng-click="vm.triggerDeleteFolder(vm.currentFolder, r)" data="{{ vm.currentFolder }}" class="cp">Delete {{ vm.currentFolder | capitalize }} Folder</a></span></li>
<li ng-if="r.shareAccess.write" ng-hide="vm.showFolderAction"><span><i class="fa fa-upload cp"></i> <a ng-click="vm.showUploadFilesContainer = true; vm.autoPopulateFolderName(); vm.showUploadFolderContainer = false;" 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.cleanPath(); vm.showUploadFolderContainer = true; vm.showFileUploadBtn = false;" class="cp">New folder</a></span></li>
<li ng-hide="vm.showUploadButton" ng-if="r.shareAccess.write"><span><i class="fa fa-trash cp"></i> <a ng-click="vm.triggerDeleteFolder(vm.currentFolder, r)" data="{{ vm.currentFolder }}" class="cp">Delete {{ vm.currentFolder | capitalize }} Folder</a></span></li>
</ul>
</div>
</div>
@ -81,7 +81,7 @@
</div>
<div class="row">
<div class="padding-side-15">
<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>
<button ng-if="r.shareAccess.write" 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>