diff --git a/src/app/organization/organizationBillingAdjustStorageController.js b/src/app/organization/organizationBillingAdjustStorageController.js new file mode 100644 index 0000000000..7363da1b84 --- /dev/null +++ b/src/app/organization/organizationBillingAdjustStorageController.js @@ -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'); + }; + }); diff --git a/src/app/organization/organizationBillingController.js b/src/app/organization/organizationBillingController.js index 796e90195a..c45e1e4d86 100644 --- a/src/app/organization/organizationBillingController.js +++ b/src/app/organization/organizationBillingController.js @@ -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.')) { diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index 1f8cde2ca8..1127a1988f 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -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: {} } diff --git a/src/app/settings/settingsBillingAdjustStorageController.js b/src/app/settings/settingsBillingAdjustStorageController.js new file mode 100644 index 0000000000..ceb1709c50 --- /dev/null +++ b/src/app/settings/settingsBillingAdjustStorageController.js @@ -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'); + }; + }); diff --git a/src/app/settings/views/settingsBillingAdjustStorage.html b/src/app/settings/views/settingsBillingAdjustStorage.html new file mode 100644 index 0000000000..7d1db06c11 --- /dev/null +++ b/src/app/settings/views/settingsBillingAdjustStorage.html @@ -0,0 +1,46 @@ + +
+ + +
diff --git a/src/index.html b/src/index.html index 6a63d13269..b2aa36835b 100644 --- a/src/index.html +++ b/src/index.html @@ -185,6 +185,7 @@ + @@ -214,6 +215,7 @@ +