From 2b60af103b9abc47ea9ffdd7579d9442d0f4c8ab Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Fri, 12 Jun 2015 13:26:23 +0200 Subject: [PATCH] Initial rework of the upgrade view --- webadmin/src/theme.scss | 84 +++++++++++++++++++++++++++++++++ webadmin/src/views/upgrade.html | 77 +++++++++++++----------------- webadmin/src/views/upgrade.js | 34 +++++++++++-- 3 files changed, 146 insertions(+), 49 deletions(-) diff --git a/webadmin/src/theme.scss b/webadmin/src/theme.scss index 536a61ec7..d901968df 100644 --- a/webadmin/src/theme.scss +++ b/webadmin/src/theme.scss @@ -464,3 +464,87 @@ footer a { padding: 10px; } + +// ---------------------------- +// Upgrade +// ---------------------------- + +.region-select-map { + width: 600px; + height: 300px; + display: table; + margin: auto; + cursor: pointer; +} + +.region-selected { + opacity: 1 !important; +} + +.region-select { + display: inline-block; + float: left; + opacity: 0.5; + height: 300px; + transition: all 250ms; +} + +.region-select:hover { + opacity: 1; +} + +.region-pin { + position: relative; + top: 0; + opacity: 0; + transition: all 250ms cubic-bezier(0.430, 0.950, 0.810, 1.280); +} + +.region-pin-left { + left: -18px; +} + +.region-pin-right { + left: -132px; +} + +.region-pin-selected-left { + top: 95px; + opacity: 1; +} + +.region-pin-selected-right { + top: 73px; + opacity: 1; +} + +.cloudron-model-list { + display: table; + width: 100%; +} + +.cloudron-model-item { + display: table-cell; + padding: 10px; + margin: auto; + transition: all 250ms; + max-width: 200px; + transform: scale(0.95); + border-radius: 5px; + cursor: pointer; +} + +.cloudron-model-item:hover, +.cloudron-model-item-selected { + background-color: rgba(255, 255, 255, 0.5); + color: highlight !important; + transform: scale(1); +} + +.cloudron-model-item:hover h4, +.cloudron-model-item:hover h5, +.cloudron-model-item-selected h4, +.cloudron-model-item-selected h5, { + transition: all 250ms; + color: black; +} diff --git a/webadmin/src/views/upgrade.html b/webadmin/src/views/upgrade.html index ff8fa2fc9..0b5e28fb5 100644 --- a/webadmin/src/views/upgrade.html +++ b/webadmin/src/views/upgrade.html @@ -17,50 +17,39 @@ -
-
-

Upgrade

-
-
- -
-
-
-

Current

+
+
+
+
+

Choose a Model to upgrade to

+
+
+
+

{{ size.name }}

+
${{ size.price }}/mo
+
+
+
-
-
-
- Size: +
+
+
+

Choose your Region, in case you want to relocate your Cloudron

+
+
+ +
+
+ +
+
+

{{ migration.region.name || ' ' }}

+
-
- {{config.size}} +
+
+ +
-
-
-
- Region: -
-
- {{config.region}} -
-
-
- -
-
-
- -
-
- -
-
- -
-
-
+ +
\ No newline at end of file diff --git a/webadmin/src/views/upgrade.js b/webadmin/src/views/upgrade.js index bbcaf6ad5..538d5ad84 100644 --- a/webadmin/src/views/upgrade.js +++ b/webadmin/src/views/upgrade.js @@ -9,8 +9,8 @@ angular.module('Application').controller('UpgradeController', ['$scope', '$locat $scope.availableSizes = []; $scope.migration = { - regionSlug: '', - sizeSlug: '' + region: null, + size: null }; $scope.showMigrationConfirm = function () { @@ -18,24 +18,48 @@ angular.module('Application').controller('UpgradeController', ['$scope', '$locat }; $scope.doMigration = function () { - Client.migrate($scope.migration.sizeSlug, $scope.migration.regionSlug, function (error) { + Client.migrate($scope.migration.size.slug, $scope.migration.region.slug, function (error) { if (error) return console.error(error); $('#migrationModal').modal('hide'); }); }; + $scope.setRegion = function (regionSlug) { + $scope.availableRegions.forEach(function (region) { + if (region.slug.indexOf(regionSlug) === 0) $scope.migration.region = region; + }); + }; + + $scope.setSize = function (sizeSlug) { + $scope.availableSizes.forEach(function (size) { + if (size.slug.indexOf(sizeSlug) === 0) $scope.migration.size = size; + }); + }; + Client.onReady(function () { AppStore.getSizes(function (error, result) { if (error) return console.error(error); + // restult array is ordered by size + var found = false; + result = result.filter(function (size) { + if (size.slug === $scope.config.size) { + $scope.setSize($scope.config.size); + found = true; + return true; + } else { + return found; + } + }); angular.copy(result, $scope.availableSizes); - $scope.migration.sizeSlug = $scope.availableSizes[0].slug; AppStore.getRegions(function (error, result) { if (error) return console.error(error); angular.copy(result, $scope.availableRegions); - $scope.migration.regionSlug = $scope.availableRegions[0].slug; + + $scope.setRegion($scope.config.region); + $scope.setSize($scope.config.size); }); }); });