mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
storage adjustment
This commit is contained in:
parent
ea4d772dda
commit
1dbf831bda
@ -0,0 +1,37 @@
|
||||
angular
|
||||
.module('bit.organization')
|
||||
|
||||
.controller('organizationBillingAdjustStorageController', function ($scope, $state, $uibModalInstance, apiService,
|
||||
$analytics, toastr, add) {
|
||||
$analytics.eventTrack('organizationBillingAdjustStorageController', { category: 'Modal' });
|
||||
$scope.add = add;
|
||||
$scope.storageAdjustment = 0;
|
||||
|
||||
$scope.submit = function () {
|
||||
var request = {
|
||||
storageGbAdjustment: $scope.storageAdjustment
|
||||
};
|
||||
|
||||
if (!add) {
|
||||
request.storageGbAdjustment *= -1;
|
||||
}
|
||||
|
||||
$scope.submitPromise = apiService.organizations.putStorage({ id: $state.params.orgId }, request)
|
||||
.$promise.then(function (response) {
|
||||
if (add) {
|
||||
$analytics.eventTrack('Added Organization Storage');
|
||||
toastr.success('You have added ' + $scope.storageAdjustment + ' GB.');
|
||||
}
|
||||
else {
|
||||
$analytics.eventTrack('Removed Organization Storage');
|
||||
toastr.success('You have removed ' + $scope.storageAdjustment + ' GB.');
|
||||
}
|
||||
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
@ -63,6 +63,23 @@
|
||||
});
|
||||
};
|
||||
|
||||
$scope.adjustStorage = function (add) {
|
||||
var modal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/settings/views/settingsBillingAdjustStorage.html',
|
||||
controller: 'organizationBillingAdjustStorageController',
|
||||
resolve: {
|
||||
add: function () {
|
||||
return add;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
modal.result.then(function () {
|
||||
load();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
if (!confirm('Are you sure you want to cancel? All users will lose access to the organization ' +
|
||||
'at the end of this billing cycle.')) {
|
||||
|
@ -64,6 +64,7 @@
|
||||
put: { method: 'POST', params: { id: '@id' } },
|
||||
putPayment: { url: _apiUri + '/organizations/:id/payment', method: 'POST', params: { id: '@id' } },
|
||||
putSeat: { url: _apiUri + '/organizations/:id/seat', method: 'POST', params: { id: '@id' } },
|
||||
putStorage: { url: _apiUri + '/organizations/:id/storage', method: 'POST', params: { id: '@id' } },
|
||||
putUpgrade: { url: _apiUri + '/organizations/:id/upgrade', method: 'POST', params: { id: '@id' } },
|
||||
putCancel: { url: _apiUri + '/organizations/:id/cancel', method: 'POST', params: { id: '@id' } },
|
||||
putReinstate: { url: _apiUri + '/organizations/:id/reinstate', method: 'POST', params: { id: '@id' } },
|
||||
@ -125,6 +126,7 @@
|
||||
'import': { url: _apiUri + '/accounts/import', method: 'POST', params: {} },
|
||||
postDelete: { url: _apiUri + '/accounts/delete', method: 'POST', params: {} },
|
||||
postPremium: { url: _apiUri + '/accounts/premium', method: 'POST', params: {} },
|
||||
putStorage: { url: _apiUri + '/accounts/storage', method: 'POST', params: {} },
|
||||
putCancelPremium: { url: _apiUri + '/accounts/cancel-premium', method: 'POST', params: {} },
|
||||
putReinstatePremium: { url: _apiUri + '/accounts/reinstate-premium', method: 'POST', params: {} },
|
||||
getBilling: { url: _apiUri + '/accounts/billing', method: 'GET', params: {} }
|
||||
|
37
src/app/settings/settingsBillingAdjustStorageController.js
Normal file
37
src/app/settings/settingsBillingAdjustStorageController.js
Normal file
@ -0,0 +1,37 @@
|
||||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsBillingAdjustStorageController', function ($scope, $state, $uibModalInstance, apiService,
|
||||
$analytics, toastr, add) {
|
||||
$analytics.eventTrack('settingsBillingAdjustStorageController', { category: 'Modal' });
|
||||
$scope.add = add;
|
||||
$scope.storageAdjustment = 0;
|
||||
|
||||
$scope.submit = function () {
|
||||
var request = {
|
||||
storageGbAdjustment: $scope.storageAdjustment
|
||||
};
|
||||
|
||||
if (!add) {
|
||||
request.storageGbAdjustment *= -1;
|
||||
}
|
||||
|
||||
$scope.submitPromise = apiService.accounts.putStorage(null, request)
|
||||
.$promise.then(function (response) {
|
||||
if (add) {
|
||||
$analytics.eventTrack('Added Storage');
|
||||
toastr.success('You have added ' + $scope.storageAdjustment + ' GB.');
|
||||
}
|
||||
else {
|
||||
$analytics.eventTrack('Removed Storage');
|
||||
toastr.success('You have removed ' + $scope.storageAdjustment + ' GB.');
|
||||
}
|
||||
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
46
src/app/settings/views/settingsBillingAdjustStorage.html
Normal file
46
src/app/settings/views/settingsBillingAdjustStorage.html
Normal file
@ -0,0 +1,46 @@
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">
|
||||
<i class="fa fa-database"></i>
|
||||
{{add ? 'Add Storage' : 'Remove Storage'}}
|
||||
</h4>
|
||||
</div>
|
||||
<form name="form" ng-submit="form.$valid && submit()" api-form="submitPromise">
|
||||
<div class="modal-body">
|
||||
<div class="callout callout-default" ng-show="add">
|
||||
<h4><i class="fa fa-dollar"></i> Note About Charges</h4>
|
||||
<p>
|
||||
Adding storage to your plan will result in adjustments to your billing totals and immediately charge your
|
||||
payment method on file. The first charge will be prorated for the remainder of the current billing cycle.
|
||||
</p>
|
||||
</div>
|
||||
<div class="callout callout-default" ng-show="!add">
|
||||
<h4><i class="fa fa-dollar"></i> Note About Charges</h4>
|
||||
<p>
|
||||
Removing storage will result in adjustments to your billing totals that will be prorated as credits
|
||||
to your next billing charge.
|
||||
</p>
|
||||
</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="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="gb">{{add ? 'GB of Storage To Add' : 'GB of Storage To Remove'}}</label>
|
||||
<input type="number" id="gb" name="StroageGbAdjustment" ng-model="storageAdjustment" class="form-control"
|
||||
required min="0" max="99" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading">
|
||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Submit
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
@ -185,6 +185,7 @@
|
||||
<script src="app/organization/organizationBillingController.js"></script>
|
||||
<script src="app/organization/organizationBillingChangePaymentController.js"></script>
|
||||
<script src="app/organization/organizationBillingAdjustSeatsController.js"></script>
|
||||
<script src="app/organization/organizationBillingAdjustStorageController.js"></script>
|
||||
<script src="app/organization/organizationDeleteController.js"></script>
|
||||
<script src="app/organization/organizationBillingChangePlanController.js"></script>
|
||||
<script src="app/organization/organizationVaultController.js"></script>
|
||||
@ -214,6 +215,7 @@
|
||||
<script src="app/settings/settingsDeleteController.js"></script>
|
||||
<script src="app/settings/settingsCreateOrganizationController.js"></script>
|
||||
<script src="app/settings/settingsBillingController.js"></script>
|
||||
<script src="app/settings/settingsBillingAdjustStorageController.js"></script>
|
||||
<script src="app/settings/settingsUpdateKeyController.js"></script>
|
||||
<script src="app/settings/settingsPremiumController.js"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user