From 3ec3f172bb2fcad6dbf0a5df82d43e1d516cfc77 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 28 Jun 2016 14:36:19 -0500 Subject: [PATCH] migrate UI fixes --- webadmin/src/views/settings.html | 18 +++++++------ webadmin/src/views/settings.js | 44 +++++++++++++++++++------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/webadmin/src/views/settings.html b/webadmin/src/views/settings.html index 11468ae43..629e22ddc 100644 --- a/webadmin/src/views/settings.html +++ b/webadmin/src/views/settings.html @@ -84,11 +84,13 @@ @@ -105,7 +107,7 @@ @@ -157,10 +159,10 @@
-
@@ -168,7 +170,7 @@
- +
diff --git a/webadmin/src/views/settings.js b/webadmin/src/views/settings.js index c03f01c76..b2143305a 100644 --- a/webadmin/src/views/settings.js +++ b/webadmin/src/views/settings.js @@ -16,11 +16,11 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca $scope.availableRegions = []; $scope.currentRegionSlug = null; - $scope.availableSizes = []; - $scope.requestedSize = null; - $scope.currentSize = null; + $scope.availablePlans = []; + $scope.requestedPlan = null; + $scope.currentPlan = null; - $scope.changePlan = { + $scope.planChange = { busy: false, error: {}, password: '' @@ -124,7 +124,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca }); } - function getSizes() { + function getPlans() { AppStore.getSizes(function (error, result) { if (error) return console.error(error); @@ -132,14 +132,14 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca var found = false; result = result.filter(function (size) { if (size.slug === $scope.config.size) { - $scope.currentSize = $scope.requestedSize = size; + $scope.currentPlan = $scope.requestedPlan = size; found = true; return true; } else { return found; } }); - angular.copy(result, $scope.availableSizes); + angular.copy(result, $scope.availablePlans); AppStore.getRegions(function (error, result) { if (error) return console.error(error); @@ -152,14 +152,14 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca } $scope.setRequestedPlan = function (plan) { - $scope.requestedSize = plan; + $scope.requestedPlan = plan; }; $scope.showChangePlan = function () { $('#planChangeModal').modal('show'); }; - function changePlanReset() { + function planChangeReset() { $scope.planChange.error.password = null; $scope.planChange.password = ''; @@ -168,19 +168,27 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca } $scope.doChangePlan = function () { - $scope.changePlan.busy = true; + $scope.planChange.busy = true; - Client.migrate($scope.requestedSize.slug, $scope.currentRegionSlug, $scope.changePlan.password, function (error) { - $scope.changePlan.busy = false; + Client.migrate($scope.requestedPlan.slug, $scope.currentRegionSlug, $scope.planChange.password, function (error) { + $scope.planChange.busy = false; if (error) { - return console.error(error); + if (error.statusCode === 403) { + $scope.planChange.error.password = true; + $scope.planChange.password = ''; + $scope.planChangeForm.password.$setPristine(); + $('#inputPlanChangePassword').focus(); + } else { + console.error('Unable to change plan.', error); + } + } else { + planChangeReset(); + + $('#planChangeModal').modal('hide'); } - // we will get redirected at some point - changePlanReset(); - $('#planChangeModal').modal('hide'); - $scope.changePlan.busy = false; + $scope.planChange.busy = false; }); }; @@ -335,7 +343,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca Client.onReady(function () { fetchBackups(); - getSizes(); + getPlans(); }); // setup all the dialog focus handling