diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-07-31 14:06:14 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-08-03 09:29:15 +0200 |
commit | 5adfc76bd08520e6184199c76562cea038d4c49b (patch) | |
tree | 30d58351f9d99894939eabce866217d4552078f2 /server/sonar-web | |
parent | 846f71127fdf498c69090157f748517c5eb22888 (diff) | |
download | sonarqube-5adfc76bd08520e6184199c76562cea038d4c49b.tar.gz sonarqube-5adfc76bd08520e6184199c76562cea038d4c49b.zip |
SONAR-6660 rewrite setup page
Diffstat (limited to 'server/sonar-web')
16 files changed, 45 insertions, 87 deletions
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 index 65bcc701939..281f6872b8f 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js +++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js @@ -2,12 +2,21 @@ define([ './templates' ], function () { + var $ = jQuery; + return Marionette.ItemView.extend({ template: Templates['maintenance-main'], + events: { + 'click #start-migration': 'startMigration' + }, + initialize: function () { var that = this; - this.requestOptions = { type: 'GET', url: baseUrl + '/api/system/status' }; + this.requestOptions = { + type: 'GET', + url: baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') + }; setInterval(function () { that.refresh(); }, 5000); @@ -21,6 +30,21 @@ define([ }); }, + startMigration: function () { + var that = this; + Backbone.ajax({ + url: baseUrl + '/api/system/migrate_db', + type: 'POST' + }).done(function (r) { + that.model.set(r); + that.render(); + }) + }, + + onRender: function () { + $('.page-simple').toggleClass('panel-warning', this.model.get('state') === 'MIGRATION_REQUIRED'); + }, + serializeData: function () { return _.extend(this._super(), { setup: this.options.setup }); } 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-state-migration-failed.hbs index 2392a0f243e..2392a0f243e 100644 --- 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-state-migration-failed.hbs 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-state-migration-not-supported.hbs index c139aa32211..c139aa32211 100644 --- 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-state-migration-not-supported.hbs 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-state-migration-required.hbs index ec59b035dc1..ec59b035dc1 100644 --- 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-state-migration-required.hbs 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-state-migration-running.hbs index 52702e27c31..52702e27c31 100644 --- 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-state-migration-running.hbs diff --git a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-succeeded.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-succeeded.hbs new file mode 100644 index 00000000000..ee14eb8cb21 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-succeeded.hbs @@ -0,0 +1,4 @@ +<h1 class="maintenance-title text-success">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-no-migration.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-no-migration.hbs index ee20022fcc4..ee20022fcc4 100644 --- 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-state-no-migration.hbs 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 deleted file mode 100644 index 8b8c7b8e307..00000000000 --- a/server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs +++ /dev/null @@ -1,9 +0,0 @@ -<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-main.hbs b/server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs index 668eaee8ba4..4e99545bc55 100644 --- 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 @@ -7,17 +7,11 @@ {{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}} + {{#eq state 'NO_MIGRATION'}}{{> '_maintenance-state-no-migration'}}{{/eq}} + {{#eq state 'MIGRATION_REQUIRED'}}{{> '_maintenance-state-migration-required'}}{{/eq}} + {{#eq state 'NOT_SUPPORTED'}}{{> '_maintenance-state-migration-not-supported'}}{{/eq}} + {{#eq state 'MIGRATION_RUNNING'}}{{> '_maintenance-state-migration-running'}}{{/eq}} + {{#eq state 'MIGRATION_SUCCEEDED'}}{{> '_maintenance-state-migration-succeeded'}}{{/eq}} + {{#eq state 'MIGRATION_FAILED'}}{{> '_maintenance-state-migration-failed'}}{{/eq}} {{/unless}} diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb index 2ea401ffd3f..9223009f5d4 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb @@ -21,34 +21,9 @@ class SetupController < ApplicationController skip_before_filter :check_database_version, :check_authentication SECTION=Navigation::SECTION_CONFIGURATION - - verify :method => :post, :only => [ :setup_database ], :redirect_to => { :action => :index } - - def index - if !ActiveRecord::Base.connected? - render :template => 'setup/dbdown', :layout => 'nonav' - elsif DatabaseMigrationManager.instance.requires_migration? - render :template => 'setup/form', :layout => 'nonav' - elsif DatabaseMigrationManager.instance.migration_running? - render :template => 'setup/migration_running', :layout => 'nonav' - elsif DatabaseMigrationManager.instance.migration_failed? - render :template => 'setup/failed', :layout => 'nonav' - else - # migration succeeded, or no need for migration - render :template => 'setup/db_uptodate', :layout => 'nonav' - end - end - def setup_database - # Ask the DB migration manager to start the migration - # => No need to check for authorizations (actually everybody can run the upgrade) - # nor concurrent calls (this is handled directly by DatabaseMigrationManager) - DatabaseMigrationManager.instance.start_migration - redirect_to :action => :index - end - - def maintenance - render :template => 'setup/maintenance', :layout => 'nonav' + def index + render :template => 'setup/index', :layout => 'nonav' end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb deleted file mode 100644 index cbe4b12434f..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<meta http-equiv='refresh' content='5;url=<%= home_path -%>'> -<h1 class="maintenance-title text-success">Database is up-to-date</h1> -<p class="maintenance-text"> - You will be redirected shortly to SonarQube. - <br> - <small class="text-muted"> - (if this does not happen, you can <a href="<%= home_path -%>">click here to be redirected</a>) - </small> -</p> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb deleted file mode 100644 index 1040fb71839..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<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> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb deleted file mode 100644 index 36062451e19..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<h1 class="maintenance-title text-danger">Impossible to upgrade database</h1> -<p class="maintenance-text"><%= DatabaseMigrationManager.instance.message -%></p> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb deleted file mode 100644 index 032d9c39a18..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<form action="<%= ApplicationController.root_context -%>/setup/setup_database" method="POST"> - <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> - -<script> - (function () { - document.querySelector('.page-simple').className += ' panel-warning'; - })(); -</script> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/index.html.erb new file mode 100644 index 00000000000..d3dacd3e7f3 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/index.html.erb @@ -0,0 +1,8 @@ +<% content_for :extra_script do %> + <script> + require(['apps/maintenance/app'], function (App) { + App.start({ el: '#content', setup: true }); + }); + </script> +<% end %> + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb deleted file mode 100644 index d10ba7c6513..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<meta http-equiv='refresh' content='5;'> - -<% 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> |