From f8319a23d935528d1f4e6ebfeaa8b25751c7f5b2 Mon Sep 17 00:00:00 2001 From: Joseph Cohen Date: Tue, 6 Jan 2015 13:08:15 -0600 Subject: [PATCH] Implement wizard setup --- app/assets/js/start.js | 46 +++++++ app/assets/sass/main.scss | 1 + app/assets/sass/pages/_setup.scss | 66 +++++++++ app/lang/en/setup.php | 4 +- app/lang/fr/setup.php | 4 +- app/views/auth/login.blade.php | 2 +- app/views/setup.blade.php | 166 +++++++++++++---------- src/Http/Controllers/SetupController.php | 37 ++++- 8 files changed, 252 insertions(+), 74 deletions(-) create mode 100644 app/assets/sass/pages/_setup.scss diff --git a/app/assets/js/start.js b/app/assets/js/start.js index fe167967..8e71f9b4 100644 --- a/app/assets/js/start.js +++ b/app/assets/js/start.js @@ -126,4 +126,50 @@ $(function() { $('#banner-view').remove(); $('input[name=remove_banner]').val('1'); }); + + // Setup wizard + $('.wizard-next').on('click', function () { + var $form = $('#setup-form'), + $btn = $(this), + current = $btn.data('currentBlock'), + next = $btn.data('nextBlock'); + + $btn.button('loading'); + + // Only validate going forward. If current group is invalid, do not go further + if (next > current) { + var url = '/setup/step' + current; + $.post(url, $form.serializeObject()) + .done(function(response) { + goForward(current, next); + }) + .fail(function(response) { + var errors = _.toArray(response.responseJSON.errors); + _.each(errors, function(error) { + (new CachetHQ.Notifier()).notify(error); + }); + }) + .always(function() { + $btn.button('reset'); + }); + + return false; + } + }); + + function goForward(current, next) { + // validation was ok. We can go on next step. + $('.block-' + current) + .removeClass('show') + .addClass('hidden'); + + $('.block-' + next) + .removeClass('hidden') + .addClass('show'); + + $('.steps .step') + .removeClass("active") + .filter(":lt(" + (next) + ")") + .addClass("active"); + } }); diff --git a/app/assets/sass/main.scss b/app/assets/sass/main.scss index 028e7d63..7d05a46b 100644 --- a/app/assets/sass/main.scss +++ b/app/assets/sass/main.scss @@ -22,6 +22,7 @@ html, body { // Styles for specific page @import "pages/login"; +@import "pages/setup"; // Styles for plugins @import "plugins/messenger"; diff --git a/app/assets/sass/pages/_setup.scss b/app/assets/sass/pages/_setup.scss new file mode 100644 index 00000000..1fdc3ebf --- /dev/null +++ b/app/assets/sass/pages/_setup.scss @@ -0,0 +1,66 @@ +.setup-page { + padding-top: 60px; + .logo { + display: block; + margin: 0 auto 30px; + } + .steps { + @extend .row; + margin: 0 auto; + border-radius: 2px 2px 0 0; + margin-bottom: 20px; + .step { + @extend .col-xs-4; + padding: 20px 0; + text-align: center; + position: relative; + font-size: 13px; + &:not(:last-child):after { + content: ''; + position: absolute; + bottom: 31px; + left: 55%; + display: block; + height: 1px; + background: #94A1B8; + width: 100%; + } + span { + width: 23px; + height: 23px; + display: block; + position: relative; + margin: 0 auto; + margin-top: 13px; + border-radius: 25px; + background: $cachet-base-medium; + border: 1px solid #94A1B8; + -webkit-transition: all 0.2s linear; + -moz-transition: all 0.2s linear; + -ms-transition: all 0.2s linear; + -o-transition: all 0.2s linear; + transition: all 0.2s linear; + } + + &.active { + span { + background: $cachet-primary; + } + } + } + } + .setup-success { + text-align: center; + i { + font-size: 47px; + } + h3 { + margin-top: 25px; + font-size: 21px; + color: #556579; + } + .btn { + margin-top: 40px; + } + } +} diff --git a/app/lang/en/setup.php b/app/lang/en/setup.php index 27d455ca..af0d654b 100644 --- a/app/lang/en/setup.php +++ b/app/lang/en/setup.php @@ -7,5 +7,7 @@ return [ 'status_page_setup' => 'Status Page Setup', 'show_support' => 'Show support for Cachet? Places a link in the footer linking to Cachet.', 'admin_account' => 'Administrator Account', - 'complete_setup' => 'Complete Setup' + 'complete_setup' => 'Complete Setup', + 'completed' => 'Cachet has been configured successfully!', + 'finish_setup' => 'Go to dashboard', ]; diff --git a/app/lang/fr/setup.php b/app/lang/fr/setup.php index f2d0c30f..c9b52d03 100644 --- a/app/lang/fr/setup.php +++ b/app/lang/fr/setup.php @@ -7,5 +7,7 @@ return [ 'status_page_setup' => 'Installation de la page de statut', 'show_support' => 'Show support for Cachet? Places a link in the footer linking to Cachet.', 'admin_account' => 'Compte administrateur', - 'complete_setup' => 'Terminer l\'installation' + 'complete_setup' => 'Terminer l\'installation', + 'completed' => 'Cachet a été configuré avec succès !', + 'finish_setup' => 'Aller au tableau de bord', ]; diff --git a/app/views/auth/login.blade.php b/app/views/auth/login.blade.php index e1e4fdbb..060016f0 100644 --- a/app/views/auth/login.blade.php +++ b/app/views/auth/login.blade.php @@ -1,7 +1,7 @@ @extends('layout.clean') @section('content') -
+