From 146583a98d632fceaff1642cd9bc3b566c51615a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 26 May 2014 18:43:26 +0200 Subject: Added update overview page --- core/js/js.js | 4 +++ core/js/update.js | 106 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 86 insertions(+), 24 deletions(-) (limited to 'core/js') diff --git a/core/js/js.js b/core/js/js.js index 38b97590430..80cd0104fec 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -175,9 +175,13 @@ var OC={ PERMISSION_DELETE:8, PERMISSION_SHARE:16, PERMISSION_ALL:31, + /* jshint camelcase: false */ webroot:oc_webroot, appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, + config: oc_config, + appConfig: oc_appconfig || {}, + theme: oc_defaults || {}, coreApps:['', 'admin','log','search','settings','core','3rdparty'], /** diff --git a/core/js/update.js b/core/js/update.js index b1b7f6e37e8..abf2d6ae6db 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -1,26 +1,84 @@ -$(document).ready(function () { - var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); - updateEventSource.listen('success', function(message) { - $('').append(message).append('
').appendTo($('.update')); - }); - updateEventSource.listen('error', function(message) { - $('').addClass('error').append(message).append('
').appendTo($('.update')); - message = t('core', 'Please reload the page.'); - $('').addClass('error').append(message).append('
').appendTo($('.update')); - updateEventSource.close(); - }); - updateEventSource.listen('failure', function(message) { - $('').addClass('error').append(message).append('
').appendTo($('.update')); - $('') - .addClass('error bold') - .append('
') - .append(t('core', 'The update was unsuccessful. Please report this issue to the ownCloud community.')) - .appendTo($('.update')); - }); - updateEventSource.listen('done', function(message) { - $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update')); - setTimeout(function () { - window.location.href = OC.webroot; - }, 3000); +/* + * Copyright (c) 2014 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +(function() { + OC.Update = { + _started : false, + + /** + * Start the upgrade process. + * + * @param $el progress list element + */ + start: function($el) { + var self = this; + if (this._started) { + return; + } + + this.$el = $el; + + this._started = true; + this.addMessage(t( + 'core', + 'Updating {productName} to version {version}, this may take a while.', { + productName: OC.theme.name, + version: OC.config.versionstring + }), + 'bold' + ).append('
'); // FIXME: these should be ul/li with CSS paddings! + + var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); + updateEventSource.listen('success', function(message) { + $('').append(message).append('
').appendTo($el); + }); + updateEventSource.listen('error', function(message) { + $('').addClass('error').append(message).append('
').appendTo($el); + message = t('core', 'Please reload the page.'); + $('').addClass('error').append(message).append('
').appendTo($el); + updateEventSource.close(); + }); + updateEventSource.listen('failure', function(message) { + $('').addClass('error').append(message).append('
').appendTo($el); + $('') + .addClass('error bold') + .append('
') + .append(t('core', 'The update was unsuccessful.' + + 'Please report this issue to the ownCloud community.')) + .appendTo($el); + }); + updateEventSource.listen('done', function(message) { + // FIXME: use product name + $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($el); + setTimeout(function () { + OC.redirect(OC.webroot); + }, 3000); + }); + }, + + addMessage: function(message, className) { + var $span = $(''); + $span.addClass(className).append(message).append('
').appendTo(this.$el); + return $span; + } + }; + +})(); + +$(document).ready(function() { + $('.updateForm').on('submit', function(ev) { + ev.preventDefault(); + var $progressEl = $('.updateProgress'); + $progressEl.removeClass('hidden'); + $('.updateForm').addClass('hidden'); + OC.Update.start($progressEl); + return false; }); }); -- cgit v1.2.3