Remove subscription setup modal, instead open cloudron.io directly

This commit is contained in:
Johannes Zellner
2020-02-14 14:16:04 +01:00
parent 9fcd049bdc
commit 21e7190b72
3 changed files with 34 additions and 73 deletions

View File

@@ -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