diff --git a/src/index.html b/src/index.html
index 3d6dcad33..48ce06c71 100644
--- a/src/index.html
+++ b/src/index.html
@@ -95,24 +95,6 @@
Cloudron is offline. Reconnecting...
-
-
-
@@ -131,15 +113,11 @@
-
- -
-
- Setup Subscription
-
-
- -
-
- Subscription expired
+
+ -
+
+ Setup Subscription
+ Reactivate Subscription
-
diff --git a/src/js/main.js b/src/js/main.js
index bf4b37bb4..2dd6aba28 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -12,9 +12,10 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.client = Client;
$scope.subscription = {};
$scope.notifications = [];
-
$scope.hideNavBarActions = $location.path() === '/logs';
+ var waitingForPlanSelection = false;
+
$scope.isActive = function (url) {
if (!$route.current) return false;
return $route.current.$$route.originalPath.indexOf(url) === 0;
@@ -26,23 +27,13 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
Client.logout();
};
- $scope.waitingForPlanSelection = false;
- $('#setupSubscriptionModal').on('hide.bs.modal', function () {
- $scope.waitingForPlanSelection = false;
-
- // check for updates to stay in sync
- Client.checkForUpdates(function (error) {
- if (error) return console.error(error);
-
- Client.refreshConfig();
- });
- });
-
- $scope.showSubscriptionModal = function () {
- $('#setupSubscriptionModal').modal('show');
+ // NOTE: this function is exported and called from the settings.js
+ $scope.pollSubscriptionStatus = function () {
+ if (waitingForPlanSelection) return; // prevent double polling
+ waitingForPlanSelection = true;
function checkPlan() {
- if (!$scope.waitingForPlanSelection) return;
+ if (!waitingForPlanSelection) return;
Client.getSubscription(function (error, subscription) {
if (error) return console.error(error);
@@ -51,28 +42,23 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
if (subscription.plan.id === 'free' || subscription.plan.id === 'expired') {
$timeout(checkPlan, 5000);
} else {
- $scope.waitingForPlanSelection = false;
- $('#setupSubscriptionModal').modal('hide');
+ waitingForPlanSelection = false;
$scope.subscription = subscription;
+
+ // check for updates to stay in sync
+ Client.checkForUpdates(function (error) {
+ if (error) return console.error(error);
+
+ Client.refreshConfig();
+ });
}
});
}
- $scope.waitingForPlanSelection = true;
-
checkPlan();
};
- function refreshNotifications() {
- Client.getNotifications(false, 1, 20, function (error, results) {
- if (error) console.error(error);
- else $scope.notifications = results;
-
- $timeout(refreshNotifications, 60 * 1000);
- });
- }
-
- // NOTE: this function is exported and called from the settings.js
+ // NOTE: this function is exported and called from the appstore.js
$scope.updateSubscriptionStatus = function () {
if (!Client.getUserInfo().admin) return;
@@ -84,6 +70,15 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
});
};
+ function refreshNotifications() {
+ Client.getNotifications(false, 1, 20, function (error, results) {
+ if (error) console.error(error);
+ else $scope.notifications = results;
+
+ $timeout(refreshNotifications, 60 * 1000);
+ });
+ }
+
// update state of acknowledged notification
$scope.notificationAcknowledged = function (notificationId) {
// remove notification from list
diff --git a/src/views/settings.js b/src/views/settings.js
index 378fca6d7..d14937174 100644
--- a/src/views/settings.js
+++ b/src/views/settings.js
@@ -34,11 +34,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.update.error.generic = null;
$scope.update.busy = false;
- if (!$scope.config.update.box.sourceTarballUrl) {
- $('#setupSubscriptionModal').modal('show');
- } else {
- $('#updateModal').modal('show');
- }
+ $('#updateModal').modal('show');
},
stopUpdate: function () {
@@ -359,18 +355,10 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
$scope.pollSubscriptionStatus = function () {
- Client.getSubscription(function (error, result) {
- if (error && error.statusCode === 412) return; // not yet registered
- if (error) return console.error(error);
- if (!$scope.$parent) return; // user changed view. otherwise we get an error that $scope.$parent is null
+ if (!$scope.$parent) return; // user changed view. otherwise we get an error that $scope.$parent is null
- $scope.subscription = result;
-
- // also reload the subscription on the main controller
- $scope.$parent.updateSubscriptionStatus();
-
- $timeout($scope.pollSubscriptionStatus, 10 * 1000);
- });
+ // poll on the main controller
+ $scope.$parent.pollSubscriptionStatus();
};
$('#avatarFileInput').get(0).onchange = function (event) {