aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/maintenance
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-06-15 15:36:35 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-06-15 15:51:04 +0200
commit1982a35ea22ede4245131054cee6f16c10e52ba6 (patch)
tree7adfea96b4e54e8d99bbb3a4c09bac9f09d148e5 /server/sonar-web/src/main/js/apps/maintenance
parentcc9c0c54d3fe6ada071d20edae5b5e75abab37be (diff)
downloadsonarqube-1982a35ea22ede4245131054cee6f16c10e52ba6.tar.gz
sonarqube-1982a35ea22ede4245131054cee6f16c10e52ba6.zip
SONAR-6639 redesign migration page, step 1
Diffstat (limited to 'server/sonar-web/src/main/js/apps/maintenance')
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/app.js17
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/main-view.js46
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-down.hbs5
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs2
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs8
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs2
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs11
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs9
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration.hbs10
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs4
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-up.hbs5
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs23
12 files changed, 142 insertions, 0 deletions
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
index 00000000000..cc7b016bef0
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/app.js
@@ -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
index 00000000000..ff445f919d7
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js
@@ -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
index 00000000000..6507cbafa2e
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-down.hbs
@@ -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
index 00000000000..2392a0f243e
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs
@@ -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
index 00000000000..ec59b035dc1
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs
@@ -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
index 00000000000..c139aa32211
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs
@@ -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
index 00000000000..52702e27c31
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs
@@ -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
index 00000000000..8b8c7b8e307
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs
@@ -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
index 00000000000..c7957397871
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration.hbs
@@ -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
index 00000000000..ee20022fcc4
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs
@@ -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
index 00000000000..01ca264cb21
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-up.hbs
@@ -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
index 00000000000..668eaee8ba4
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs
@@ -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}}