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 +++++++++++++++++++++++++++++++--------- core/templates/update.admin.php | 38 +++++++++++--- lib/base.php | 15 ++++++ 4 files changed, 133 insertions(+), 30 deletions(-) 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; }); }); diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index a652d5f195a..0b1ae7854de 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -1,6 +1,32 @@ -
    -
  • - t('Updating ownCloud to version %s, this may take a while.', - array($_['version']))); ?>

    -
  • -
+
+
+

+ t('%s will be updated to version %s.', + array($_['productName'], $_['version']))); ?> +

+ +
+
t('The following apps will be disabled during the upgrade:')) ?>
+
    + +
  • + +
+
+ + +
+
t('The theme %s has been disabled.', array($_['oldTheme']))) ?>
+
+ +
+
t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?>
+
+
+ +
+
+ + +
diff --git a/lib/base.php b/lib/base.php index a022b9d005b..455e8ad4613 100644 --- a/lib/base.php +++ b/lib/base.php @@ -284,11 +284,26 @@ class OC { public static function checkUpgrade($showTemplate = true) { if (self::needUpgrade()) { if ($showTemplate && !OC_Config::getValue('maintenance', false)) { + $version = OC_Util::getVersion(); + $oldTheme = OC_Config::getValue('theme'); OC_Config::setValue('theme', ''); OC_Util::addScript('config'); // needed for web root OC_Util::addScript('update'); $tmpl = new OC_Template('', 'update.admin', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); + + // get third party apps + $apps = OC_App::getEnabledApps(); + $incompatibleApps = array(); + foreach ($apps as $appId) { + $info = OC_App::getAppInfo($appId); + if(!OC_App::isAppCompatible($version, $info)) { + $incompatibleApps[] = $info['name']; + } + } + $tmpl->assign('appList', $incompatibleApps); + $tmpl->assign('productName', 'ownCloud'); // for now + $tmpl->assign('oldTheme', $oldTheme); $tmpl->printPage(); exit(); } else { -- cgit v1.2.3 From 02f682b156998a3f3f94fd506867c28eba878da9 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 27 May 2014 15:20:33 +0200 Subject: Now showing disabled apps as upgrade status line - Added app id in update overview. - Added status message for disabled app for CLI upgrade and web upgrade --- core/ajax/update.php | 8 ++++++++ core/command/upgrade.php | 3 +++ core/templates/update.admin.php | 4 ++-- lib/base.php | 2 +- lib/private/app.php | 8 ++++++++ lib/private/updater.php | 5 ++++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/ajax/update.php b/core/ajax/update.php index 55e8ab15ec2..84d7a21209e 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -15,6 +15,14 @@ if (OC::checkUpgrade(false)) { $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { $eventSource->send('success', (string)$l->t('Updated database')); }); + $updater->listen('\OC\Updater', 'disabledApps', function ($appList) use ($eventSource, $l) { + $list = array(); + foreach ($appList as $appId) { + $info = OC_App::getAppInfo($appId); + $list[] = $info['name'] . ' (' . $info['id'] . ')'; + } + $eventSource->send('success', (string)$l->t('Disabled incompatible apps: %s', implode(', ', $list))); + }); $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) { $eventSource->send('failure', $message); $eventSource->close(); diff --git a/core/command/upgrade.php b/core/command/upgrade.php index ed72d136e24..8ce8ef9b6e5 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -56,6 +56,9 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { $output->writeln('Updated database'); }); + $updater->listen('\OC\Updater', 'disabledApps', function ($appList) use($output) { + $output->writeln('Disabled incompatible apps: ' . implode(', ', $appList) . ''); + }); $updater->listen('\OC\Updater', 'failure', function ($message) use($output) { $output->writeln($message); diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index 0b1ae7854de..b9b0fdb7748 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -8,8 +8,8 @@
t('The following apps will be disabled during the upgrade:')) ?>
    - -
  • + +
  • ()
diff --git a/lib/base.php b/lib/base.php index 455e8ad4613..7bca1b7c877 100644 --- a/lib/base.php +++ b/lib/base.php @@ -298,7 +298,7 @@ class OC { foreach ($apps as $appId) { $info = OC_App::getAppInfo($appId); if(!OC_App::isAppCompatible($version, $info)) { - $incompatibleApps[] = $info['name']; + $incompatibleApps[] = $info; } } $tmpl->assign('appList', $incompatibleApps); diff --git a/lib/private/app.php b/lib/private/app.php index 50065197eb4..ea0453e58ea 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -889,8 +889,14 @@ class OC_App{ * ownCloud version. disable them if not. * This is important if you upgrade ownCloud and have non ported 3rd * party apps installed. + * + * @param array $apps optional app id list to check, uses all enabled apps + * when not specified + * + * @return array containing the list of ids of the disabled apps */ public static function checkAppsRequirements($apps = array()) { + $disabledApps = array(); if (empty($apps)) { $apps = OC_App::getEnabledApps(); } @@ -905,8 +911,10 @@ class OC_App{ OC_Log::ERROR); OC_App::disable( $app ); OC_Hook::emit('update', 'success', 'Disabled '.$info['name'].' app because it is not compatible'); + $disabledApps[] = $app; } } + return $disabledApps; } /** diff --git a/lib/private/updater.php b/lib/private/updater.php index d8694ac6ed5..58d3cab73aa 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -134,7 +134,10 @@ class Updater extends BasicEmitter { $this->emit('\OC\Updater', 'failure', array($exception->getMessage())); } \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); - \OC_App::checkAppsRequirements(); + $disabledApps = \OC_App::checkAppsRequirements(); + if (!empty($disabledApps)) { + $this->emit('\OC\Updater', 'disabledApps', array($disabledApps)); + } // load all apps to also upgrade enabled apps \OC_App::loadApps(); -- cgit v1.2.3 From ca45937d84266f63e9ccf4a37820ad1e254ba5d3 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 27 May 2014 16:36:21 +0200 Subject: Fixed styles in update overview page --- core/css/styles.css | 10 ++++++++++ core/templates/update.admin.php | 18 +++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index 423c40f6184..fdfe282198d 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -370,6 +370,16 @@ input[type="submit"].enabled { opacity: .6; } +#body-login .update .title { + font-weight: bold; + font-size: 18px; + margin-bottom: 30px; +} + +#body-login .infogroup { + margin-bottom: 15px; +} + #body-login p#message img { vertical-align: middle; padding: 5px; diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index b9b0fdb7748..acc9c26c662 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -1,12 +1,12 @@
-

+

t('%s will be updated to version %s.', array($_['productName'], $_['version']))); ?> -

+

-
-
t('The following apps will be disabled during the upgrade:')) ?>
+
+

t('The following apps will be disabled during the upgrade:')) ?>

  • ()
  • @@ -15,14 +15,14 @@
-
-
t('The theme %s has been disabled.', array($_['oldTheme']))) ?>
+
+

t('The theme %s has been disabled.', array($_['oldTheme']))) ?>

-
-
t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?>
+
+

t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?>

-
+
-- cgit v1.2.3 From 7e055a94044100c17ffa103c56e2d238f9b4e6ac Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 28 May 2014 11:29:22 +0200 Subject: Fixed DOM elements, styling and code style issues - Reduced number of DOM elements - Also added mention of "config" backup. --- core/css/styles.css | 2 +- core/js/update.js | 16 +++++++++------- core/templates/update.admin.php | 33 ++++++++++++++------------------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index fdfe282198d..c493941fed8 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -370,7 +370,7 @@ input[type="submit"].enabled { opacity: .6; } -#body-login .update .title { +#body-login .update h2 { font-weight: bold; font-size: 18px; margin-bottom: 30px; diff --git a/core/js/update.js b/core/js/update.js index abf2d6ae6db..cc0f541bd79 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -18,7 +18,6 @@ * @param $el progress list element */ start: function($el) { - var self = this; if (this._started) { return; } @@ -51,12 +50,16 @@ .addClass('error bold') .append('
') .append(t('core', 'The update was unsuccessful.' + - 'Please report this issue to the ownCloud community.')) + 'Please report this issue to the ' + + 'ownCloud community.')) .appendTo($el); }); - updateEventSource.listen('done', function(message) { + updateEventSource.listen('done', function() { // FIXME: use product name - $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($el); + $('').addClass('bold') + .append('
') + .append(t('core', 'The update was successful. Redirecting you to ownCloud now.')) + .appendTo($el); setTimeout(function () { OC.redirect(OC.webroot); }, 3000); @@ -73,11 +76,10 @@ })(); $(document).ready(function() { - $('.updateForm').on('submit', function(ev) { - ev.preventDefault(); + $('.updateButton').on('click', function() { var $progressEl = $('.updateProgress'); $progressEl.removeClass('hidden'); - $('.updateForm').addClass('hidden'); + $('.updateOverview').addClass('hidden'); OC.Update.start($progressEl); return false; }); diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php index acc9c26c662..a09e2d07bf4 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -1,32 +1,27 @@
-
-

- t('%s will be updated to version %s.', - array($_['productName'], $_['version']))); ?> -

+
+

t('%s will be updated to version %s.', + array($_['productName'], $_['version']))); ?>

-

t('The following apps will be disabled during the upgrade:')) ?>

+ t('The following apps will be disabled:')) ?>
    - -
  • ()
  • - + +
  • ()
  • +
-
-

t('The theme %s has been disabled.', array($_['oldTheme']))) ?>

+
+ t('The theme %s has been disabled.', array($_['oldTheme']))) ?>
-
-

t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?>

-
-
- +
+ t('Please make sure that the database, the config folder and the data folder have been backed up before proceeding.')) ?>
- - - + +
-- cgit v1.2.3