From 8e91ce11fc85593d05b29b8ac2f728da26569d4e Mon Sep 17 00:00:00 2001 From: Sean Li Date: Fri, 12 Sep 2014 22:44:04 -0700 Subject: [PATCH] Added a feature to recover Kitematic setup. --- meteor/client/lib/installer.js | 3 +++ meteor/client/main.js | 4 ++-- .../dashboard/settings/dashboard-settings.html | 9 +++++++++ .../dashboard/settings/dashboard-settings.js | 14 ++++++++++++++ .../views/dashboard/setup/setup-finish.js | 2 +- .../views/dashboard/setup/setup-install.html | 7 ------- .../views/dashboard/setup/setup-install.js | 18 ------------------ .../views/dashboard/setup/setup-intro.js | 9 ++++++++- 8 files changed, 37 insertions(+), 29 deletions(-) diff --git a/meteor/client/lib/installer.js b/meteor/client/lib/installer.js index 8ff6cd2aff..d4f8352138 100644 --- a/meteor/client/lib/installer.js +++ b/meteor/client/lib/installer.js @@ -131,6 +131,7 @@ Installer.steps = [ }, pastMessage: 'Started the Kitematic VM', message: 'Starting the Kitematic VM', + subMessage: '(This may take a few minutes)', futureMessage: 'Start the Kitematic VM' }, @@ -164,6 +165,7 @@ Installer.steps = [ ]; Installer.run = function (callback) { + Session.set('installing', true); var currentStep = 0; Session.set('currentInstallStep', currentStep); Session.set('numberOfInstallSteps', this.steps.length); @@ -191,6 +193,7 @@ Installer.run = function (callback) { callback(err); } else { // Setup Finished + Session.set('installing', false); console.log('Setup finished.'); callback(); } diff --git a/meteor/client/main.js b/meteor/client/main.js index 0e5c44ce7c..33b0a1c216 100755 --- a/meteor/client/main.js +++ b/meteor/client/main.js @@ -63,7 +63,7 @@ Handlebars.registerHelper('timeSince', function (date) { return moment(date).fromNow(); }); -Handlebars.registerHelper('isUpdating', function (date) { +Handlebars.registerHelper('isUpdating', function () { return Session.get('isUpdating'); }); @@ -145,7 +145,7 @@ Meteor.setInterval(function () { }, 5000); Meteor.setInterval(function () { - if (Installer.isUpToDate()) { + if (!Session.get('installing')) { Sync.resolveWatchers(function () {}); if (!Session.get('boot2dockerOff')) { fixBoot2DockerVM(function (err) { diff --git a/meteor/client/views/dashboard/settings/dashboard-settings.html b/meteor/client/views/dashboard/settings/dashboard-settings.html index 67cc58fb9e..6af4cccf75 100644 --- a/meteor/client/views/dashboard/settings/dashboard-settings.html +++ b/meteor/client/views/dashboard/settings/dashboard-settings.html @@ -52,4 +52,13 @@ {{/if}} +
+
+

Repair Kitematic

+

You can repair Kitematic installation if the app stops working properly.

+
+ +
diff --git a/meteor/client/views/dashboard/settings/dashboard-settings.js b/meteor/client/views/dashboard/settings/dashboard-settings.js index 2028f2edd6..dc811bc175 100644 --- a/meteor/client/views/dashboard/settings/dashboard-settings.js +++ b/meteor/client/views/dashboard/settings/dashboard-settings.js @@ -1,3 +1,6 @@ +var remote = require('remote'); +var dialog = remote.require('dialog'); + Template.dashboard_settings.events({ 'click .btn-start-boot2docker': function (e) { var $btn = $(e.currentTarget); @@ -36,6 +39,17 @@ Template.dashboard_settings.events({ tracking: false } }); + }, + 'click .btn-repair': function () { + dialog.showMessageBox({ + message: 'Repairing Kitematic will clear your current Docker VM and the state of the app. Please make sure your work is backed up. Do you wish to continue?', + buttons: ['Repair', 'Cancel'] + }, function (index) { + if (index !== 0) { + return; + } + Router.go('setup_intro'); + }); } }); diff --git a/meteor/client/views/dashboard/setup/setup-finish.js b/meteor/client/views/dashboard/setup/setup-finish.js index 05dce0cccd..ee0b1c0d41 100644 --- a/meteor/client/views/dashboard/setup/setup-finish.js +++ b/meteor/client/views/dashboard/setup/setup-finish.js @@ -1,6 +1,6 @@ Template.setup_finish.events({ 'click .finish-button': function (e) { - var enableDiagnostics = $('.install-diagonistics input').attr('checked') ? true : false; + var enableDiagnostics = $('.install-diagonistics input').prop('checked'); var status = enableDiagnostics ? 'on' : 'off'; ga('send', 'event', 'link', 'click', 'turn ' + status + ' usage analytics'); Installs.insert({version: Installer.CURRENT_VERSION}); diff --git a/meteor/client/views/dashboard/setup/setup-install.html b/meteor/client/views/dashboard/setup/setup-install.html index 9f16050b26..6f837f7c42 100644 --- a/meteor/client/views/dashboard/setup/setup-install.html +++ b/meteor/client/views/dashboard/setup/setup-install.html @@ -52,12 +52,5 @@ {{/each}} -
- {{#if installComplete}} - - Start Using Kitematic - - {{/if}} -
diff --git a/meteor/client/views/dashboard/setup/setup-install.js b/meteor/client/views/dashboard/setup/setup-install.js index b4026b8351..59ac37286c 100644 --- a/meteor/client/views/dashboard/setup/setup-install.js +++ b/meteor/client/views/dashboard/setup/setup-install.js @@ -1,18 +1,3 @@ -var installStarted = false; -Template.setup_install.rendered = function() { - if(!installStarted) { - installStarted = true; - Installer.run(function (err) { - if (err) { - console.log('Setup failed.'); - console.log(err); - } else { - Router.go('setup_finish'); - } - }); - } -}; - Template.setup_install.steps = function () { return Installer.steps.map(function (step, index) { step.index = index; @@ -27,9 +12,6 @@ Template.setup_install.helpers({ currentInstallStepProgress: function () { return Session.get('currentInstallStepProgress'); }, - installComplete: function () { - return Session.get('currentInstallStep') === Installer.steps.length; - }, failedStep: function () { return Session.get('failedStep'); }, diff --git a/meteor/client/views/dashboard/setup/setup-intro.js b/meteor/client/views/dashboard/setup/setup-intro.js index 035945b7ec..3b5963be1e 100644 --- a/meteor/client/views/dashboard/setup/setup-intro.js +++ b/meteor/client/views/dashboard/setup/setup-intro.js @@ -1,9 +1,16 @@ Template.setup_intro.events({ 'click .continue-button': function (e) { Router.go('setup_install'); + Installer.run(function (err) { + if (err) { + console.log('Setup failed.'); + console.log(err); + } else { + Router.go('setup_finish'); + } + }); e.preventDefault(); e.stopPropagation(); return false; } }); -