show cloudron account in the settings view

This commit is contained in:
Johannes Zellner
2017-06-06 11:16:56 +02:00
parent 95ba51dfb2
commit aa8b4f1fba
2 changed files with 54 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', 'Client', 'AppStore', function ($scope, $location, $rootScope, Client, AppStore) {
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', '$timeout', 'Client', 'AppStore', function ($scope, $location, $rootScope, $timeout, Client, AppStore) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
$scope.client = Client;
@@ -20,6 +20,8 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.availablePlans = [];
$scope.currentPlan = null;
$scope.currentSubscription = null;
// List is from http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
$scope.s3Regions = [
{ name: 'Asia Pacific (Mumbai)', value: 'ap-south-1' },
@@ -500,6 +502,17 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
});
}
function getSubscription() {
AppStore.getSubscription($scope.appstoreConfig, function (error, result) {
if (error) return console.error(error);
$scope.currentSubscription = result;
// check again to give more immediate feedback once a subscription was setup
if (result.plan.id === 'free') $timeout(getSubscription, 5000);
});
}
function getPlans() {
AppStore.getSizes(function (error, result) {
if (error) return console.error(error);
@@ -614,6 +627,8 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
if (error) return console.error(error);
$scope.appstoreConfig.profile = result;
getSubscription();
});
}
});