@@ -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 }); | |||
} |
@@ -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> |
@@ -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> |
@@ -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}} |
@@ -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 |
@@ -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> |
@@ -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> |
@@ -1,2 +0,0 @@ | |||
<h1 class="maintenance-title text-danger">Impossible to upgrade database</h1> | |||
<p class="maintenance-text"><%= DatabaseMigrationManager.instance.message -%></p> |
@@ -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> |
@@ -0,0 +1,8 @@ | |||
<% content_for :extra_script do %> | |||
<script> | |||
require(['apps/maintenance/app'], function (App) { | |||
App.start({ el: '#content', setup: true }); | |||
}); | |||
</script> | |||
<% end %> | |||
@@ -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> |