]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6639 redesign migration page, step 1
authorStas Vilchik <vilchiks@gmail.com>
Mon, 15 Jun 2015 13:36:35 +0000 (15:36 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 15 Jun 2015 13:51:04 +0000 (15:51 +0200)
25 files changed:
server/sonar-web/Gruntfile.coffee
server/sonar-web/src/main/js/apps/maintenance/app.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/main-view.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-down.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-up.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs [new file with mode: 0644]
server/sonar-web/src/main/less/components/page.less
server/sonar-web/src/main/less/init/misc.less
server/sonar-web/src/main/less/init/type.less
server/sonar-web/src/main/less/pages.less
server/sonar-web/src/main/less/pages/maintenance.less [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/nonav.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb

index be7a3ae2ab3f208ad212daa7833847db74dfdd06..831558a585b023deb8f133f21c6cb65ed1355cec 100644 (file)
@@ -125,6 +125,7 @@ module.exports = (grunt) ->
           'build-app:computation'
           'build-app:drilldown'
           'build-app:groups'
+          'build-app:maintenance'
           'build-app:markdown'
           'build-app:measures'
           'build-app:metrics'
@@ -232,6 +233,9 @@ module.exports = (grunt) ->
           '<%= BUILD_PATH %>/js/apps/metrics/templates.js': [
             '<%= SOURCE_PATH %>/js/apps/metrics/templates/**/*.hbs'
           ]
+          '<%= BUILD_PATH %>/js/apps/maintenance/templates.js': [
+            '<%= SOURCE_PATH %>/js/apps/maintenance/templates/**/*.hbs'
+          ]
 
 
     clean:
diff --git a/server/sonar-web/src/main/js/apps/maintenance/app.js b/server/sonar-web/src/main/js/apps/maintenance/app.js
new file mode 100644 (file)
index 0000000..cc7b016
--- /dev/null
@@ -0,0 +1,17 @@
+define([
+  './main-view'
+], function (MainView) {
+
+  var App = new Marionette.Application();
+
+  App.on('start', function (options) {
+    var viewOptions = _.extend(options, {
+      model: new Backbone.Model()
+    });
+    var mainView = new MainView(viewOptions);
+    mainView.render().refresh();
+  });
+
+  return App;
+
+});
diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js
new file mode 100644 (file)
index 0000000..ff445f9
--- /dev/null
@@ -0,0 +1,46 @@
+define([
+  './templates'
+], function () {
+
+  return Marionette.ItemView.extend({
+    template: Templates['maintenance-main'],
+
+    events: {
+      'click #start-migration': 'onStartMigrationClick'
+    },
+
+    initialize: function () {
+      this.requestOptions = { type: 'GET', url: baseUrl + '/api/system/status' };
+      setInterval(function () {
+        this.refresh();
+      }.bind(this), 5000);
+    },
+
+    refresh: function () {
+      return Backbone.ajax(this.requestOptions).done(function (r) {
+        if (r.status === 'DB_MIGRATION_RUNNING' && this.options.setup) {
+          // we are at setup page and migration is running
+          // so, let's switch to the migration status WS
+          return this.startMigration();
+        }
+        this.model.set(r);
+        this.render();
+      }.bind(this));
+    },
+
+    onStartMigrationClick: function (e) {
+      e.preventDefault();
+      this.startMigration();
+    },
+
+    startMigration: function () {
+      this.requestOptions = { type: 'POST', url: baseUrl + '/api/system/migrate_db' };
+      return this.refresh();
+    },
+
+    serializeData: function () {
+      return _.extend(this._super(), { setup: this.options.setup });
+    }
+  });
+
+});
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-down.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-down.hbs
new file mode 100644 (file)
index 0000000..6507cba
--- /dev/null
@@ -0,0 +1,5 @@
+<h1 class="maintenance-title text-danger">SonarQube is down</h1>
+<p class="maintenance-text">Something went wrong. Please contact your system administrator.</p>
+<p class="maintenance-text text-center">
+  <a href="{{link '/'}}">Try Again</a>
+</p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs
new file mode 100644 (file)
index 0000000..2392a0f
--- /dev/null
@@ -0,0 +1,2 @@
+<h1 class="maintenance-title text-danger">Upgrade Failed</h1>
+<p class="maintenance-text">Database connection cannot be established. Please check database status and JDBC settings.</p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs
new file mode 100644 (file)
index 0000000..ec59b03
--- /dev/null
@@ -0,0 +1,8 @@
+<h1 class="maintenance-title">Upgrade Database</h1>
+<p class="maintenance-text">The database upgrade can take several minutes.</p>
+<p class="maintenance-text">It is mandatory to <strong>back up database</strong> before upgrading.</p>
+<p class="maintenance-text"><strong>Copy the directory /extensions</strong> from previous version before upgrading.
+</p>
+<div class="maintenance-spinner">
+  <button id="start-migration">Upgrade</button>
+</div>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs
new file mode 100644 (file)
index 0000000..c139aa3
--- /dev/null
@@ -0,0 +1,2 @@
+<h1 class="maintenance-title text-danger">Migration not supported</h1>
+<p>Migration is not supported on embedded databases.</p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs
new file mode 100644 (file)
index 0000000..52702e2
--- /dev/null
@@ -0,0 +1,11 @@
+<h1 class="maintenance-title">Database Migration</h1>
+{{#if message}}
+  <p class="maintenance-text text-center">{{message}}</p>
+{{/if}}
+{{#if startedAt}}
+  <p class="maintenance-text text-center">
+    Started {{fromNow startedAt}}<br>
+    <small class="text-muted">{{dt startedAt}}</small>
+  </p>
+{{/if}}
+<p class="maintenance-spinner"><i class="spinner"></i></p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs
new file mode 100644 (file)
index 0000000..8b8c7b8
--- /dev/null
@@ -0,0 +1,9 @@
+<h1 class="maintenance-title text-success">Done</h1>
+<p>Database migration has run and has been successful.</p>
+{{#if startedAt}}
+  <p class="maintenance-text text-center">
+    Started {{fromNow startedAt}}<br>
+    <small class="text-muted">{{dt startedAt}}</small>
+  </p>
+{{/if}}
+<p class="maintenance-spinner"><i class="spinner"></i></p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration.hbs
new file mode 100644 (file)
index 0000000..c795739
--- /dev/null
@@ -0,0 +1,10 @@
+<h1 class="maintenance-title">SonarQube is under maintenance</h1>
+<p class="maintenance-text">Whilst waiting, you might want to check
+  <a href="http://redirect.sonarsource.com/doc/plugin-library.html">new plugins</a> to extend the current functionality.
+</p>
+<p class="maintenance-text">If you are an administrator and have no idea why this message is showing, you should read the
+  <a href="http://redirect.sonarsource.com/doc/upgrading.html">upgrade guide</a>.
+</p>
+{{#eq status 'DB_MIGRATION_RUNNING'}}
+  <p class="maintenance-spinner"><i class="spinner"></i></p>
+{{/eq}}
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs
new file mode 100644 (file)
index 0000000..ee20022
--- /dev/null
@@ -0,0 +1,4 @@
+<h1 class="maintenance-title">Database is up-to-date</h1>
+<p class="maintenance-text text-center">
+  <a href="{{link '/'}}">Go Home</a>
+</p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-up.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-up.hbs
new file mode 100644 (file)
index 0000000..01ca264
--- /dev/null
@@ -0,0 +1,5 @@
+<h1 class="maintenance-title">SonarQube is up</h1>
+<p class="maintenance-text text-center">All systems operational.</p>
+<p class="maintenance-text text-center">
+  <a href="{{link '/'}}">Go Home</a>
+</p>
diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs
new file mode 100644 (file)
index 0000000..668eaee
--- /dev/null
@@ -0,0 +1,23 @@
+{{#unless setup}}
+
+  {{#eq status 'UP'}}{{> '_maintenance-status-up'}}{{/eq}}
+  {{#eq status 'DOWN'}}{{> '_maintenance-status-down'}}{{/eq}}
+  {{#eq status 'DB_MIGRATION_NEEDED'}}{{> '_maintenance-status-migration'}}{{/eq}}
+  {{#eq status 'DB_MIGRATION_RUNNING'}}{{> '_maintenance-status-migration'}}{{/eq}}
+
+{{else}}
+
+  {{#notNull state}}
+    {{#eq state 'NO_MIGRATION'}}{{> '_maintenance-status-no-migration'}}{{/eq}}
+    {{#eq state 'NOT_SUPPORTED'}}{{> '_maintenance-status-migration-not-supported'}}{{/eq}}
+    {{#eq state 'MIGRATION_RUNNING'}}{{> '_maintenance-status-migration-running'}}{{/eq}}
+    {{#eq state 'MIGRATION_SUCCEEDED'}}{{> '_maintenance-status-migration-succeeded'}}{{/eq}}
+    {{#eq state 'MIGRATION_FAILED'}}{{> '_maintenance-status-migration-failed'}}{{/eq}}
+  {{else}}
+    {{#eq status 'UP'}}{{> '_maintenance-status-up'}}{{/eq}}
+    {{#eq status 'DOWN'}}{{> '_maintenance-status-down'}}{{/eq}}
+    {{#eq status 'DB_MIGRATION_NEEDED'}}{{> '_maintenance-status-migration-needed'}}{{/eq}}
+    {{#eq status 'DB_MIGRATION_RUNNING'}}{{> '_maintenance-status-migration-running'}}{{/eq}}
+  {{/notNull}}
+
+{{/unless}}
index 2b3faf8c067ab3250dfe1fd8facf20c6696a98c4..47730d7bffb0eafa158493e3e0794be2695c1092 100644 (file)
 }
 
 .page-simple {
-  margin: 50px 180px 0;
+  max-width: 400px;
+  margin: 50px auto 0;
+  padding: 40px;
+  border: 1px solid @barBorderColor;
+  background-color: #fff;
   text-align: left;
 }
 
index d9d5442cf206fc0525cb0da6ee1a1b4f34353c56..b5e41704b74a07096ca5823a7186713b026ffc8c 100644 (file)
@@ -48,6 +48,8 @@
 .big-spacer-bottom { margin-bottom: 16px; }
 .big-spacer-top    { margin-top: 16px; }
 
+.huge-spacer-top    { margin-top: 40px; }
+
 .little-spacer-left   { margin-left: 4px; }
 .little-spacer-right  { margin-right: 4px; }
 .little-spacer-bottom { margin-bottom: 4px; }
index 756597cf14add54c0834a7c9a894b102bb976587..490dd34e8955b513ce209f46da7b7a23f5e37183 100644 (file)
@@ -63,7 +63,7 @@ sub { vertical-align: text-bottom; }
 // Emphasising
 
 em     { font-style: italic; }
-strong { font-weight: bold; }
+strong { font-weight: 500; }
 
 
 // Quotes
index c9d1c235da9fe19afeead21357aa50879cbe08b1..79570a5f8d4865502f882a46c8f8006cfa160c15 100644 (file)
@@ -24,3 +24,4 @@
 @import "pages/issues";
 @import "pages/libraries";
 @import "pages/quality-gates";
+@import "pages/maintenance";
diff --git a/server/sonar-web/src/main/less/pages/maintenance.less b/server/sonar-web/src/main/less/pages/maintenance.less
new file mode 100644 (file)
index 0000000..bee10c6
--- /dev/null
@@ -0,0 +1,22 @@
+@import (reference) "../variables";
+@import (reference) "../init/links";
+
+.maintenance-title {
+  margin-bottom: 40px;
+  line-height: 1.5;
+  font-size: 24px;
+  font-weight: 300;
+  text-align: center;
+}
+
+.maintenance-text {
+  margin-bottom: 16px;
+  line-height: 1.5;
+  font-size: 16px;
+  font-weight: 300;
+}
+
+.maintenance-spinner {
+  margin-top: 40px;
+  text-align: center;
+}
index 2c76816b05c42b4efd7f399540c92c0ae0739a61..a2976adc994dce72d1a868543a1678891fd5a07a 100644 (file)
@@ -6,4 +6,9 @@
     </div>
   </div>
 </div>
+<script>
+  (function ($) {
+    $('html').addClass('dashboard-page');
+  })(window.jQuery);
+</script>
 </body></html>
index d325ed1165824113d4b20b8224753279dc20a2ff..fd604b7694fd9d053cc84337e35ee8ab90458e3a 100644 (file)
@@ -1,12 +1,8 @@
-<style>
-#maintenance {
-  padding: 10px;
-  border: 2px solid #4B9FD5;
-  background-color: #CAE3F2;
-}
-</style>
+<div id="maintenance"></div>
+
+<script>
+  require(['apps/maintenance/app'], function (App) {
+    App.start({ el: '#maintenance', setup: false });
+  });
+</script>
 
-<div id="maintenance">
-<h1>SonarQube is under maintenance. <a href="<%= ApplicationController.root_context -%>/">Please check back later.</a></h1>
-<p>Whilst waiting, you might want to check <a href="http://redirect.sonarsource.com/doc/plugin-library.html">new plugins</a> to extend the current functionality. </p><p>If you are an administrator and have no idea why this message is showing, you should read the <a href="http://redirect.sonarsource.com/doc/upgrading.html">upgrade guide</a>.</p>
-</div>
index 63b3c49006db4693604d320a691dea70a63348d0..cbe4b12434f8b580d754b5cd71076e9b61536bc4 100644 (file)
@@ -1,10 +1,9 @@
 <meta http-equiv='refresh' content='5;url=<%= home_path -%>'>
-
-<div class="notice migration" style="padding:10px">
-  <%= image_tag 'accept.png' -%> <b>Database is up-to-date.</b>
-  <br/>
-  <br/>
+<h1 class="maintenance-title text-success">Database is up-to-date</h1>
+<p class="maintenance-text">
   You will be redirected shortly to SonarQube.
-  <br/>
-  <i>(if this does not happen, you can <a href="<%= home_path -%>">click here to be redirected</a>)</i>
-</div>
\ No newline at end of file
+  <br>
+  <small class="text-muted">
+    (if this does not happen, you can <a href="<%= home_path -%>">click here to be redirected</a>)
+  </small>
+</p>
index 29aa2c67f1b71b6de9ced26134172621d4d85cfd..1040fb71839f42943db583c925b6154261dc779f 100644 (file)
@@ -1,6 +1,5 @@
-<div class="alert alert-danger">
-  <h3 class="text-danger">Fail to connect to database</h3>
-  <p>Database connection cannot be established. Please check database status and JDBC settings.</p>
-  <br/>
+<h1 class="maintenance-title text-danger">Fail to connect to database</h1>
+<p class="maintenance-text">Database connection cannot be established. Please check database status and JDBC settings.</p>
+<div class="maintenance-spinner">
   <%= button_to "Try again", { :action => "index" }, :method => :get %>
 </div>
index 5c4306fc70d07b6a9c871fc23b6eaa413580658f..36062451e1994df117275d5a41485392924c0f14 100644 (file)
@@ -1,7 +1,2 @@
-<div class="error migration" style="padding:10px">
-  <%= image_tag 'exclamation.png' -%>
-  <b>Impossible to upgrade database</b>
-  <br/>
-  <br/>
-  <%= DatabaseMigrationManager.instance.message -%>
-</div>
\ No newline at end of file
+<h1 class="maintenance-title text-danger">Impossible to upgrade database</h1>
+<p class="maintenance-text"><%= DatabaseMigrationManager.instance.message -%></p>
index 69a41abb6ac45a18d4ef0a0dbf2a192db7175eff..648083a90b18d64a45ec207d7a9671508325143f 100644 (file)
@@ -1,14 +1,10 @@
 <form action="<%= ApplicationController.root_context -%>/setup/setup_database" method="POST">
-<div class="admin migration">
-  <h1 class="marginbottom10">Upgrade database</h1>
-  <br/>
-  <h3>Important</h3>
-  <ul>
-    <li>The database upgrade can take several minutes.</li>
-    <li>It is mandatory to <b>back up database</b> before upgrading.</li>
-    <li><b>Copy the directory /extensions</b> from previous version before upgrading.</li>
-  </ul>
-  <br/>
-    <input     type="submit" value="Upgrade">
-</div>
+  <h1 class="maintenance-title">Upgrade database</h1>
+  <p class="maintenance-text">The database upgrade can take several minutes.</p>
+  <p class="maintenance-text">It is mandatory to <strong>back up database</strong> before upgrading.</p>
+  <p class="maintenance-text"><strong>Copy the directory /extensions</strong> from previous version before upgrading.
+  </p>
+  <div class="maintenance-spinner">
+    <input type="submit" value="Upgrade">
+  </div>
 </form>
index 6d4bc3b77461d9ebba37f932074a697290fd4986..d10ba7c65136ba0e17aec582b6c46171a3fc02d1 100644 (file)
@@ -1,13 +1,6 @@
 <meta http-equiv='refresh' content='5;'>
 
-<%
-  start_time = DatabaseMigrationManager.instance.migration_start_time
-%>
-
-<div class="admin migration" style="padding:10px">
-  <i class="spinner" style="vertical-align: text-bottom;"></i>
-  <b>SonarQube Database is currently upgrading.</b>
-  <br/>
-  <br/>
-  Started <%= distance_of_time_in_words(start_time, Time.now) -%> ago (<%= l start_time -%>)
-</div>
+<% start_time = DatabaseMigrationManager.instance.migration_start_time %>
+<h1 class="maintenance-title">Database is currently upgrading</h1>
+<p class="maintenance-text text-center">Started <%= distance_of_time_in_words(start_time, Time.now) -%> ago (<%= l start_time -%>)</p>
+<div class="maintenance-spinner"><i class="spinner"></i></div>