From 41e33e71c8b5e87abc417be3ea2bc9426f32c2dd Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 28 Jun 2016 13:45:50 -0500 Subject: [PATCH] initial migrate UI --- webadmin/src/index.html | 20 ---------- webadmin/src/js/main.js | 17 -------- webadmin/src/views/appstore.js | 5 --- webadmin/src/views/settings.html | 51 ++++++++++++++++++++++-- webadmin/src/views/settings.js | 68 +++++++++++++++++++++++++++++++- 5 files changed, 114 insertions(+), 47 deletions(-) diff --git a/webadmin/src/index.html b/webadmin/src/index.html index 2ba390849..1cc8a1618 100644 --- a/webadmin/src/index.html +++ b/webadmin/src/index.html @@ -146,26 +146,6 @@ - - -
diff --git a/webadmin/src/js/main.js b/webadmin/src/js/main.js index 08abcd8a3..0682e94f7 100644 --- a/webadmin/src/js/main.js +++ b/webadmin/src/js/main.js @@ -77,23 +77,6 @@ angular.module('Application').controller('MainController', ['$scope', '$route', window.location.href = '/error.html'; }; - $scope.requestUpgrade = function () { - $scope.upgradeRequest.busy = true; - - var subject = 'User requested upgrade for ' + $scope.config.fqdn; - var description = 'User ' + $scope.user.email + ' requested an upgrade for ' + $scope.config.fqdn + '. Get back to him!!'; - - Client.feedback('upgrade_request', subject, description, function (error) { - $scope.upgradeRequest.busy = false; - - if (error) return Client.notify('Error', error.message, false, 'error'); - - Client.notify('Success', 'We will get back to you as soon as possible for the upgrade.', true, 'success'); - - $('#upgradeModal').modal('hide'); - }); - }; - $scope.showUpdateModal = function (form) { $scope.update.error.password = null; $scope.update.password = ''; diff --git a/webadmin/src/views/appstore.js b/webadmin/src/views/appstore.js index 5aa17edec..8d888b5c4 100644 --- a/webadmin/src/views/appstore.js +++ b/webadmin/src/views/appstore.js @@ -316,11 +316,6 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca $('#appNotFoundModal').modal('show'); }; - $scope.showRequestUpgrade = function () { - $('#appInstallModal').modal('hide'); - $('#upgradeModal').modal('show'); - }; - $scope.gotoApp = function (app) { $location.path('/appstore/' + app.manifest.id, false).search({ version : app.manifest.version }); }; diff --git a/webadmin/src/views/settings.html b/webadmin/src/views/settings.html index 3b2a347d4..ff3e1d24d 100644 --- a/webadmin/src/views/settings.html +++ b/webadmin/src/views/settings.html @@ -75,6 +75,28 @@
+ + +
@@ -107,14 +129,35 @@ {{ config.version }} -
-
-
-
+
+
+

Plans

+
+
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+

Backups

diff --git a/webadmin/src/views/settings.js b/webadmin/src/views/settings.js index 54a78a247..d75dcff41 100644 --- a/webadmin/src/views/settings.js +++ b/webadmin/src/views/settings.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', 'Client', function ($scope, $location, $rootScope, Client) { +angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', 'Client', 'AppStore', function ($scope, $location, $rootScope, Client, AppStore) { Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); }); $scope.client = Client; @@ -11,6 +11,20 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca $scope.lastBackup = null; $scope.backups = []; + $scope.currency = true ? '€' : '$'; + + $scope.availableRegions = []; + $scope.currentRegionSlug = null; + + $scope.availableSizes = []; + $scope.requestedSize = null; + $scope.currentSize = null; + + $scope.changePlan = { + busy: false, + error: {} + }; + $scope.developerModeChange = { busy: false, error: {}, @@ -109,6 +123,57 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca }); } + function getSizes() { + AppStore.getSizes(function (error, result) { + if (error) return console.error(error); + + // result array is ordered by size. only select higher sizes + var found = false; + result = result.filter(function (size) { + if (size.slug === $scope.config.size) { + $scope.currentSize = $scope.requestedSize = size; + found = true; + return true; + } else { + return found; + } + }); + angular.copy(result, $scope.availableSizes); + + AppStore.getRegions(function (error, result) { + if (error) return console.error(error); + + angular.copy(result, $scope.availableRegions); + + $scope.currentRegionSlug = $scope.config.region; + }); + }); + } + + $scope.setRequestedPlan = function (plan) { + $scope.requestedSize = plan; + }; + + $scope.showChangePlan = function () { + $('#changePlanModal').modal('show'); + }; + + $scope.doChangePlan = function () { + $scope.changePlan.busy = true; + + Client.migrate($scope.requestedSize.slug, $scope.currentRegionSlug, $scope.plans.password, function (error) { + $scope.changePlan.busy = false; + + if (error) { + return console.error(error); + } + + // we will get redirected at some point + $('#changePlanModal').modal('hide'); + $scope.changePlan.busy = false; + }); + }; + function developerModeChangeReset () { $scope.developerModeChange.error.password = null; $scope.developerModeChange.password = ''; @@ -260,6 +325,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca Client.onReady(function () { fetchBackups(); + getSizes(); }); // setup all the dialog focus handling