Browse Source

SONAR-6660 rewrite setup page

tags/5.2-RC1
Stas Vilchik 8 years ago
parent
commit
5adfc76bd0
16 changed files with 45 additions and 87 deletions
  1. 25
    1
      server/sonar-web/src/main/js/apps/maintenance/main-view.js
  2. 0
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-failed.hbs
  3. 0
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-not-supported.hbs
  4. 0
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-required.hbs
  5. 0
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-running.hbs
  6. 4
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-succeeded.hbs
  7. 0
    0
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-no-migration.hbs
  8. 0
    9
      server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs
  9. 6
    12
      server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs
  10. 2
    27
      server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb
  11. 0
    9
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb
  12. 0
    5
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb
  13. 0
    2
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb
  14. 0
    16
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb
  15. 8
    0
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/index.html.erb
  16. 0
    6
      server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb

+ 25
- 1
server/sonar-web/src/main/js/apps/maintenance/main-view.js View File

@@ -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 });
}

server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-failed.hbs → server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-failed.hbs View File


server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-not-supported.hbs → server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-not-supported.hbs View File


server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-needed.hbs → server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-required.hbs View File


server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-running.hbs → server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-running.hbs View File


+ 4
- 0
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-migration-succeeded.hbs View File

@@ -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>

server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-no-migration.hbs → server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-state-no-migration.hbs View File


+ 0
- 9
server/sonar-web/src/main/js/apps/maintenance/templates/_maintenance-status-migration-succeeded.hbs View File

@@ -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>

+ 6
- 12
server/sonar-web/src/main/js/apps/maintenance/templates/maintenance-main.hbs View File

@@ -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}}

+ 2
- 27
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb View File

@@ -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

+ 0
- 9
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/db_uptodate.html.erb View File

@@ -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>

+ 0
- 5
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/dbdown.html.erb View File

@@ -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>

+ 0
- 2
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/failed.html.erb View File

@@ -1,2 +0,0 @@
<h1 class="maintenance-title text-danger">Impossible to upgrade database</h1>
<p class="maintenance-text"><%= DatabaseMigrationManager.instance.message -%></p>

+ 0
- 16
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/form.html.erb View File

@@ -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>

+ 8
- 0
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/index.html.erb View File

@@ -0,0 +1,8 @@
<% content_for :extra_script do %>
<script>
require(['apps/maintenance/app'], function (App) {
App.start({ el: '#content', setup: true });
});
</script>
<% end %>


+ 0
- 6
server/sonar-web/src/main/webapp/WEB-INF/app/views/setup/migration_running.html.erb View File

@@ -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>

Loading…
Cancel
Save