premium required for attachments

This commit is contained in:
Kyle Spearrin 2017-07-21 17:14:40 -04:00
parent 79383ed693
commit 24056163dd
3 changed files with 29 additions and 3 deletions

View File

@ -6,6 +6,7 @@
$analytics.eventTrack('organizationVaultAttachmentsController', { category: 'Modal' });
$scope.login = {};
$scope.loading = true;
$scope.isPremium = true;
var closing = false;
apiService.logins.getAdmin({ id: loginId }, function (login) {

View File

@ -2,13 +2,18 @@
.module('bit.vault')
.controller('vaultAttachmentsController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService,
loginId, $analytics, validationService, toastr, $timeout) {
loginId, $analytics, validationService, toastr, $timeout, authService, $uibModal) {
$analytics.eventTrack('vaultAttachmentsController', { category: 'Modal' });
$scope.login = {};
$scope.readOnly = true;
$scope.loading = true;
$scope.isPremium = true;
var closing = false;
authService.getUserProfile().then(function (profile) {
$scope.isPremium = profile.premium;
});
apiService.logins.get({ id: loginId }, function (login) {
$scope.login = cipherService.decryptLogin(login);
$scope.readOnly = !login.Edit;
@ -51,6 +56,13 @@
$scope.download = function (attachment) {
attachment.loading = true;
if (!$scope.login.organizationId && !$scope.isPremium) {
attachment.loading = false;
alert('Premium membership is required to use this feature.');
return;
}
cipherService.downloadAndDecryptAttachment(getKeyForLogin(), attachment, true).then(function (res) {
$timeout(function () {
attachment.loading = false;
@ -102,4 +114,12 @@
closing = true;
$uibModalInstance.close(!!$scope.login.attachments && $scope.login.attachments.length > 0);
});
$scope.showUpgrade = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/views/premiumRequired.html',
controller: 'premiumRequiredController'
});
};
});

View File

@ -48,13 +48,18 @@
<div ng-if="!readOnly">
<hr />
<h4>Add New Attachment</h4>
<div class="callout callout-warning" ng-if="!isPremium">
<h4>Premium Membership Required</h4>
<p>Premium membership is required to use this feature.</p>
<button type="button" class="btn btn-default btn-flat" ng-click="showUpgrade()">Learn More</button>
</div>
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
<h4>Errors have occurred</h4>
<ul>
<li ng-repeat="e in form.$errors">{{e}}</li>
</ul>
</div>
<div class="form-group" show-error>
<div class="form-group" show-error ng-if="isPremium">
<label for="file" class="sr-only">File</label>
<input type="file" id="file" name="file" />
<p class="help-block">Maximum size per file is 100 MB.</p>
@ -62,7 +67,7 @@
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading" ng-if="!readOnly">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading" ng-if="!readOnly && isPremium">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Save
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>