From ea4d772ddafe37eceba11c15ca2763111d45c954 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 11 Jul 2017 10:24:46 -0400 Subject: [PATCH] storage for org billing & signup --- src/app/constants.js | 9 +++++ .../organizationBillingController.js | 11 ++++++ .../views/organizationBilling.html | 26 ++++++++++++++ src/app/services/authService.js | 9 +++++ src/app/settings/settingsBillingController.js | 11 ++++++ .../settingsCreateOrganizationController.js | 11 ++++-- src/app/settings/settingsPremiumController.js | 9 +++-- src/app/settings/views/settingsBilling.html | 16 +++++---- .../views/settingsCreateOrganization.html | 35 +++++++++++++++++++ src/app/settings/views/settingsPremium.html | 4 +-- 10 files changed, 127 insertions(+), 14 deletions(-) diff --git a/src/app/constants.js b/src/app/constants.js index 77dffe75ea..6e1c59aa06 100644 --- a/src/app/constants.js +++ b/src/app/constants.js @@ -120,5 +120,14 @@ angular.module('bit') annualPlanType: 'enterpriseAnnually', upgradeSortOrder: 3 } + }, + storageGb: { + price: 0.33, + monthlyPrice: 0.50, + yearlyPrice: 4 + }, + premium: { + price: 10, + yearlyPrice: 10 } }); diff --git a/src/app/organization/organizationBillingController.js b/src/app/organization/organizationBillingController.js index 6703e8e807..796e90195a 100644 --- a/src/app/organization/organizationBillingController.js +++ b/src/app/organization/organizationBillingController.js @@ -103,6 +103,17 @@ seats: org.Seats }; + $scope.storage = null; + if ($scope && org.MaxStorageGb) { + $scope.storage = { + currentGb: org.StorageGb || 0, + maxGb: org.MaxStorageGb, + currentName: org.StorageName || '0 GB' + }; + + $scope.storage.percentage = +($scope.storage.currentGb / $scope.storage.maxGb).toFixed(2); + } + $scope.subscription = null; if (org.Subscription) { $scope.subscription = { diff --git a/src/app/organization/views/organizationBilling.html b/src/app/organization/views/organizationBilling.html index 7d6ff2cf46..14c6ebe277 100644 --- a/src/app/organization/views/organizationBilling.html +++ b/src/app/organization/views/organizationBilling.html @@ -99,6 +99,32 @@ +
+
+

Storage

+
+
+

+ You plan has a total of {{storage.maxGb}} GB of encrypted file storage. + You are currently using {{storage.currentName}}. +

+
+
+ {{storage.percentage}}% +
+
+
+ +

Payment Method

diff --git a/src/app/services/authService.js b/src/app/services/authService.js index d8bb9be523..a7787db4f3 100644 --- a/src/app/services/authService.js +++ b/src/app/services/authService.js @@ -217,6 +217,15 @@ angular }); }; + _service.updateProfilePremium = function (isPremium) { + return _service.getUserProfile().then(function (profile) { + if (profile) { + profile.premium = isPremium; + _userProfile = profile; + } + }); + }; + _service.isAuthenticated = function () { return tokenService.getToken() !== null; }; diff --git a/src/app/settings/settingsBillingController.js b/src/app/settings/settingsBillingController.js index 4aa1aac704..c55b75d396 100644 --- a/src/app/settings/settingsBillingController.js +++ b/src/app/settings/settingsBillingController.js @@ -87,6 +87,17 @@ var i = 0; + $scope.storage = null; + if (billing && billing.MaxStorageGb) { + $scope.storage = { + currentGb: billing.StorageGb || 0, + maxGb: billing.MaxStorageGb, + currentName: billing.StorageName || '0 GB' + }; + + $scope.storage.percentage = +($scope.storage.currentGb / $scope.storage.maxGb).toFixed(2); + } + $scope.subscription = null; if (billing && billing.Subscription) { $scope.subscription = { diff --git a/src/app/settings/settingsCreateOrganizationController.js b/src/app/settings/settingsCreateOrganizationController.js index e479a85b45..52227332c6 100644 --- a/src/app/settings/settingsCreateOrganizationController.js +++ b/src/app/settings/settingsCreateOrganizationController.js @@ -4,21 +4,25 @@ .controller('settingsCreateOrganizationController', function ($scope, $state, apiService, cryptoService, toastr, $analytics, authService, stripe, constants) { $scope.plans = constants.plans; + $scope.storageGb = constants.storageGb; $scope.model = { plan: 'free', additionalSeats: 0, interval: 'year', - ownedBusiness: false + ownedBusiness: false, + additionalStorageGb: null }; $scope.totalPrice = function () { if ($scope.model.interval === 'month') { - return ($scope.model.additionalSeats || 0) * ($scope.plans[$scope.model.plan].monthlySeatPrice || 0) + + return (($scope.model.additionalSeats || 0) * ($scope.plans[$scope.model.plan].monthlySeatPrice || 0)) + + (($scope.model.additionalStorageGb || 0) * $scope.storageGb.monthlyPrice) + ($scope.plans[$scope.model.plan].monthlyBasePrice || 0); } else { - return ($scope.model.additionalSeats || 0) * ($scope.plans[$scope.model.plan].annualSeatPrice || 0) + + return (($scope.model.additionalSeats || 0) * ($scope.plans[$scope.model.plan].annualSeatPrice || 0)) + + (($scope.model.additionalStorageGb || 0) * $scope.storageGb.yearlyPrice) + ($scope.plans[$scope.model.plan].annualBasePrice || 0); } }; @@ -65,6 +69,7 @@ key: shareKeyCt, paymentToken: response.id, additionalSeats: model.additionalSeats, + additionalStorageGb: model.additionalStorageGb, billingEmail: model.billingEmail, businessName: model.ownedBusiness ? model.businessName : null }; diff --git a/src/app/settings/settingsPremiumController.js b/src/app/settings/settingsPremiumController.js index 589d5f24f7..0fabff8f17 100644 --- a/src/app/settings/settingsPremiumController.js +++ b/src/app/settings/settingsPremiumController.js @@ -1,15 +1,16 @@ angular .module('bit.settings') - .controller('settingsPremiumController', function ($scope, $state, apiService, toastr, $analytics, authService, stripe) { + .controller('settingsPremiumController', function ($scope, $state, apiService, toastr, $analytics, authService, stripe, + constants) { authService.getUserProfile().then(function (profile) { if (profile.premium) { return $state.go('backend.user.settingsBilling'); } }); - $scope.storageGbPrice = 4; - $scope.premiumPrice = 10; + $scope.storageGbPrice = constants.storageGb.yearlyPrice; + $scope.premiumPrice = constants.premium.price; $scope.model = { additionalStorageGb: null @@ -28,6 +29,8 @@ return apiService.accounts.postPremium(request).$promise; }).then(function (result) { + return authService.updateProfilePremium(true); + }).then(function () { $analytics.eventTrack('Signed Up Premium'); return authService.refreshAccessToken(); }).then(function () { diff --git a/src/app/settings/views/settingsBilling.html b/src/app/settings/views/settingsBilling.html index 526c43e161..1a9cc55518 100644 --- a/src/app/settings/views/settingsBilling.html +++ b/src/app/settings/views/settingsBilling.html @@ -8,7 +8,7 @@
-
+
Status
{{(subscription && subscription.status) || '-'}}
@@ -16,7 +16,7 @@
{{nextInvoice ? ((nextInvoice.date | date: format: mediumDate) + ', ' + (nextInvoice.amount | currency:'$')) : '-'}}
-
+
Details
Loading... @@ -48,16 +48,20 @@
-
+

Storage

-

You membership has a total of x GB of encrypted file storage. You are currently using y GB.

+

+ You membership has a total of {{storage.maxGb}} GB of encrypted file storage. + You are currently using {{storage.currentName}}. +

- 56% + aria-valuenow="{{storage.percentage}}" aria-valuemin="0" aria-valuemax="1" + style="min-width: 50px; width: {{storage.percentage}}%;"> + {{storage.percentage}}%
diff --git a/src/app/settings/views/settingsCreateOrganization.html b/src/app/settings/views/settingsCreateOrganization.html index 1738b1084e..e3603600f0 100644 --- a/src/app/settings/views/settingsCreateOrganization.html +++ b/src/app/settings/views/settingsCreateOrganization.html @@ -75,6 +75,7 @@ For personal users such as families & friends. - Add and share with up to 10 users (5 included with base price) - Create unlimited collections + - 1 GB encrypted file storage - Priority customer support - 7 day free trial, cancel anytime @@ -90,6 +91,7 @@ For businesses and other team organizations. - Add and share with unlimited users - Create unlimited collections + - 1 GB encrypted file storage - Priority customer support - 7 day free trial, cancel anytime @@ -105,6 +107,7 @@ For businesses and other large organizations. - Add and share with unlimited users - Create unlimited collections + - 1 GB encrypted file storage - Control user access with groups - Sync your users and groups from a directory (AD, Azure AD, GSuite, LDAP) - Priority customer support @@ -166,6 +169,27 @@
+
+
+

Additional Storage

+
+
+
+

+ Your plan comes with 1 GB of encrypted file storage. You can add additional + storage for {{storageGb.price | currency:"$":2}} per GB /month. +

+
+
+ + +
+
+
+
+

Billing Summary

@@ -187,6 +211,12 @@ ×12 mo. = {{((model.additionalSeats || 0) * plans[model.plan].annualSeatPrice) | currency:"$":2}} /year + + Additional storage: + {{model.additionalStorageGb || 0}} GB × {{storageGb.price | currency:"$":2}} + ×12 mo. = + {{(model.additionalStorageGb || 0) * storageGb.yearlyPrice | currency:"$":2}} /year +
@@ -204,6 +234,11 @@ ×{{plans[model.plan].monthlySeatPrice | currency:"$":2}} = {{((model.additionalSeats || 0) * plans[model.plan].monthlySeatPrice) | currency:"$":2}} /month + + Additional storage: + {{model.additionalStorageGb || 0}} GB × {{storageGb.monthlyPrice | currency:"$":2}} = + {{(model.additionalStorageGb || 0) * storageGb.monthlyPrice | currency:"$":2}} /month +
diff --git a/src/app/settings/views/settingsPremium.html b/src/app/settings/views/settingsPremium.html index 633128f541..9de164df9b 100644 --- a/src/app/settings/views/settingsPremium.html +++ b/src/app/settings/views/settingsPremium.html @@ -64,9 +64,9 @@

Billing Summary

- Premium Membership: + Premium membership: {{premiumPrice | currency:"$"}}
- Additional Storage: + Additional storage: {{model.additionalStorageGb || 0}} GB × {{storageGbPrice | currency:"$"}} = {{(model.additionalStorageGb || 0) * storageGbPrice | currency:"$"}}