summaryrefslogtreecommitdiffstats
path: root/core/js/update.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-26 18:43:26 +0200
committerVincent Petry <pvince81@owncloud.com>2014-05-27 14:53:08 +0200
commit146583a98d632fceaff1642cd9bc3b566c51615a (patch)
treec79d45cf52d7ceb146ee1cc3099785cff49a6bde /core/js/update.js
parenta9661962fef21ef7a6aaf9e14ffc9c02e22c3d72 (diff)
downloadnextcloud-server-146583a98d632fceaff1642cd9bc3b566c51615a.tar.gz
nextcloud-server-146583a98d632fceaff1642cd9bc3b566c51615a.zip
Added update overview page
Diffstat (limited to 'core/js/update.js')
-rw-r--r--core/js/update.js106
1 files changed, 82 insertions, 24 deletions
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) {
- $('<span>').append(message).append('<br />').appendTo($('.update'));
- });
- updateEventSource.listen('error', function(message) {
- $('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
- message = t('core', 'Please reload the page.');
- $('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
- updateEventSource.close();
- });
- updateEventSource.listen('failure', function(message) {
- $('<span>').addClass('error').append(message).append('<br />').appendTo($('.update'));
- $('<span>')
- .addClass('error bold')
- .append('<br />')
- .append(t('core', 'The update was unsuccessful. Please report this issue to the <a href="https://github.com/owncloud/core/issues" target="_blank">ownCloud community</a>.'))
- .appendTo($('.update'));
- });
- updateEventSource.listen('done', function(message) {
- $('<span>').addClass('bold').append('<br />').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('<br />'); // 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) {
+ $('<span>').append(message).append('<br />').appendTo($el);
+ });
+ updateEventSource.listen('error', function(message) {
+ $('<span>').addClass('error').append(message).append('<br />').appendTo($el);
+ message = t('core', 'Please reload the page.');
+ $('<span>').addClass('error').append(message).append('<br />').appendTo($el);
+ updateEventSource.close();
+ });
+ updateEventSource.listen('failure', function(message) {
+ $('<span>').addClass('error').append(message).append('<br />').appendTo($el);
+ $('<span>')
+ .addClass('error bold')
+ .append('<br />')
+ .append(t('core', 'The update was unsuccessful.' +
+ 'Please report this issue to the <a href="https://github.com/owncloud/core/issues" target="_blank">ownCloud community</a>.'))
+ .appendTo($el);
+ });
+ updateEventSource.listen('done', function(message) {
+ // FIXME: use product name
+ $('<span>').addClass('bold').append('<br />').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>');
+ $span.addClass(className).append(message).append('<br />').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;
});
});