diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-05-29 21:28:47 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-05-29 21:28:47 +0200 |
commit | 705242d3903034c148b4ad7c717d52be592f3e6d (patch) | |
tree | f4d1f1fe7230f9c8fb5e5747aa1719c9d377d8a4 | |
parent | 32a50563d3a93c304d7879212f349e6930d5b5d6 (diff) | |
parent | 7e055a94044100c17ffa103c56e2d238f9b4e6ac (diff) | |
download | nextcloud-server-705242d3903034c148b4ad7c717d52be592f3e6d.tar.gz nextcloud-server-705242d3903034c148b4ad7c717d52be592f3e6d.zip |
Merge pull request #8727 from owncloud/upgrade-overview
Added update overview page
-rw-r--r-- | core/ajax/update.php | 8 | ||||
-rw-r--r-- | core/command/upgrade.php | 3 | ||||
-rw-r--r-- | core/css/styles.css | 10 | ||||
-rw-r--r-- | core/js/js.js | 4 | ||||
-rw-r--r-- | core/js/update.js | 108 | ||||
-rw-r--r-- | core/templates/update.admin.php | 33 | ||||
-rw-r--r-- | lib/base.php | 15 | ||||
-rw-r--r-- | lib/private/app.php | 8 | ||||
-rw-r--r-- | lib/private/updater.php | 5 |
9 files changed, 163 insertions, 31 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('<info>Updated database</info>'); }); + $updater->listen('\OC\Updater', 'disabledApps', function ($appList) use($output) { + $output->writeln('<info>Disabled incompatible apps: ' . implode(', ', $appList) . '</info>'); + }); $updater->listen('\OC\Updater', 'failure', function ($message) use($output) { $output->writeln($message); diff --git a/core/css/styles.css b/core/css/styles.css index 423c40f6184..c493941fed8 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -370,6 +370,16 @@ input[type="submit"].enabled { opacity: .6; } +#body-login .update h2 { + 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/js/js.js b/core/js/js.js index fde6018e9f4..3c3efc469bf 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..cc0f541bd79 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -1,26 +1,86 @@ -$(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) { + 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() { + // 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() { + $('.updateButton').on('click', function() { + var $progressEl = $('.updateProgress'); + $progressEl.removeClass('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 a652d5f195a..a09e2d07bf4 100644 --- a/core/templates/update.admin.php +++ b/core/templates/update.admin.php @@ -1,6 +1,27 @@ -<ul> - <li class='update'> - <?php p($l->t('Updating ownCloud to version %s, this may take a while.', - array($_['version']))); ?><br /><br /> - </li> -</ul> +<div class="update"> + <div class="updateOverview"> + <h2 class="title bold"><?php p($l->t('%s will be updated to version %s.', + array($_['productName'], $_['version']))); ?></h2> + <?php if (!empty($_['appList'])) { ?> + <div class="infogroup"> + <span class="bold"><?php p($l->t('The following apps will be disabled:')) ?></span> + <ul class="content appList"> + <?php foreach ($_['appList'] as $appInfo) { ?> + <li><?php p($appInfo['name']) ?> (<?php p($appInfo['id']) ?>)</li> + <?php } ?> + </ul> + </div> + <?php } ?> + <?php if (!empty($_['oldTheme'])) { ?> + <div class="infogroup bold"> + <?php p($l->t('The theme %s has been disabled.', array($_['oldTheme']))) ?> + </div> + <?php } ?> + <div class="infogroup bold"> + <?php p($l->t('Please make sure that the database, the config folder and the data folder have been backed up before proceeding.')) ?> + </div> + <input class="updateButton" type="button" value="<?php p($l->t('Start update')) ?>"> + </div> + + <div class="updateProgress hidden"></div> +</div> diff --git a/lib/base.php b/lib/base.php index 63df94319f6..882b587a6fd 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; + } + } + $tmpl->assign('appList', $incompatibleApps); + $tmpl->assign('productName', 'ownCloud'); // for now + $tmpl->assign('oldTheme', $oldTheme); $tmpl->printPage(); exit(); } else { 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(); |