Fix plan selection

This commit is contained in:
Girish Ramakrishnan
2016-06-30 10:27:29 -05:00
parent f06c218bd1
commit 412243e656
2 changed files with 11 additions and 13 deletions

View File

@@ -85,7 +85,7 @@
<h4 class="modal-title">Cloudron Change Plan</h4>
</div>
<div class="modal-body">
This will change your plan from <b>{{ currentPlan.name }}</b> to <b>{{ requestedPlan.name }}</b>.
This will change your plan from <b>{{ currentPlan.name }}</b> to <b>{{ planChange.requestedPlan.name }}</b>.
<br/>
<br/>
Your apps and data will be migrated to the new Cloudron and will take around 15 minutes.
@@ -162,9 +162,9 @@
<div class="col-xs-10 plans" style="margin-left: 20px">
<div class="btn-group" data-toggle="buttons">
<label class="radio" ng-repeat="plan in availablePlans">
<input type="radio" name="options" autocomplete="off" ng-checked="currentPlan.slug === plan.slug" ng-click="setRequestedPlan(plan)">
<input type="radio" name="options" autocomplete="off" ng-model="planChange.requestedPlan" ng-value="plan">
{{ plan.name }} ({{ plan.slug | uppercase }}) - {{ plan.price/100 }}{{ currency }}/month
<span ng-show="currentPlan.slug === plan.slug" style="font-weight: bold"> (current plan)
<span ng-show="currentPlan.name === plan.name" style="font-weight: bold"> (current plan)
</span>
</label>
</div>
@@ -173,7 +173,7 @@
<div class="row">
<div class="col-xs-12">
<button class="btn btn-primary pull-right" ng-disabled="requestedPlan.name === currentPlan.name" ng-click="showChangePlan()">Change Plan</button>
<button class="btn btn-primary pull-right" ng-disabled="planChange.requestedPlan.name === currentPlan.name" ng-click="showChangePlan()">Change Plan</button>
</div>
</div>
</div>

View File

@@ -17,13 +17,13 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.currentRegionSlug = null;
$scope.availablePlans = [];
$scope.requestedPlan = null;
$scope.currentPlan = null;
$scope.planChange = {
busy: false,
error: {},
password: ''
password: '',
requestedPlan: null
};
$scope.developerModeChange = {
@@ -128,11 +128,10 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
AppStore.getSizes(function (error, result) {
if (error) return console.error(error);
// result array is ordered by size. only select higher sizes
// result array is ordered by size. only select higher plans
var found = false;
result = result.filter(function (size) {
if (size.slug === $scope.config.size) {
$scope.currentPlan = $scope.requestedPlan = size;
if (size.name === $scope.config.plan.name) {
found = true;
return true;
} else {
@@ -140,6 +139,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
});
angular.copy(result, $scope.availablePlans);
$scope.planChange.requestedPlan = $scope.availablePlans[0]; // need the reference
AppStore.getRegions(function (error, result) {
if (error) return console.error(error);
@@ -151,10 +151,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
});
}
$scope.setRequestedPlan = function (plan) {
$scope.requestedPlan = plan;
};
$scope.showChangePlan = function () {
$('#planChangeModal').modal('show');
};
@@ -346,6 +342,8 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
Client.onReady(function () {
fetchBackups();
getPlans();
$scope.currentPlan = $scope.config.plan;
});
// setup all the dialog focus handling