Added update overview page

This commit is contained in:
Vincent Petry 2014-05-26 18:43:26 +02:00
parent a9661962fe
commit 146583a98d
4 changed files with 133 additions and 30 deletions

View File

@ -175,9 +175,13 @@ var OC={
PERMISSION_DELETE:8, PERMISSION_DELETE:8,
PERMISSION_SHARE:16, PERMISSION_SHARE:16,
PERMISSION_ALL:31, PERMISSION_ALL:31,
/* jshint camelcase: false */
webroot:oc_webroot, webroot:oc_webroot,
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user: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'], coreApps:['', 'admin','log','search','settings','core','3rdparty'],
/** /**

View File

@ -1,26 +1,84 @@
$(document).ready(function () { /*
var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); * Copyright (c) 2014
updateEventSource.listen('success', function(message) { *
$('<span>').append(message).append('<br />').appendTo($('.update')); * This file is licensed under the Affero General Public License version 3
}); * or later.
updateEventSource.listen('error', function(message) { *
$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update')); * See the COPYING-README file.
message = t('core', 'Please reload the page.'); *
$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update')); */
updateEventSource.close();
}); (function() {
updateEventSource.listen('failure', function(message) { OC.Update = {
$('<span>').addClass('error').append(message).append('<br />').appendTo($('.update')); _started : false,
$('<span>')
.addClass('error bold') /**
.append('<br />') * Start the upgrade process.
.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')); * @param $el progress list element
}); */
updateEventSource.listen('done', function(message) { start: function($el) {
$('<span>').addClass('bold').append('<br />').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update')); var self = this;
setTimeout(function () { if (this._started) {
window.location.href = OC.webroot; return;
}, 3000); }
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;
}); });
}); });

View File

@ -1,6 +1,32 @@
<ul> <div class="update">
<li class='update'> <form name="updateForm" class="updateForm">
<?php p($l->t('Updating ownCloud to version %s, this may take a while.', <h2 class="title bold">
array($_['version']))); ?><br /><br /> <?php p($l->t('%s will be updated to version %s.',
</li> array($_['productName'], $_['version']))); ?>
</ul> </h2>
<?php if (!empty($_['appList'])) { ?>
<div class="section">
<div class="title bold"><?php p($l->t('The following apps will be disabled during the upgrade:')) ?></div>
<ul class="content appList">
<?php foreach ($_['appList'] as $appName) { ?>
<li><?php p($appName) ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
<?php if (!empty($_['oldTheme'])) { ?>
<div class="section">
<div class="title bold"><?php p($l->t('The theme %s has been disabled.', array($_['oldTheme']))) ?></div>
</div>
<?php } ?>
<div class="section">
<div class="title bold"><?php p($l->t('Please make sure that the database and the data folder have been backed up before proceeding.')) ?></div>
</div>
<div class="section">
<input type="submit" value="<?php p($l->t('Start upgrade')) ?>"></input>
</div>
</form>
<div class="updateProgress hidden">
</div>
</div>

View File

@ -284,11 +284,26 @@ class OC {
public static function checkUpgrade($showTemplate = true) { public static function checkUpgrade($showTemplate = true) {
if (self::needUpgrade()) { if (self::needUpgrade()) {
if ($showTemplate && !OC_Config::getValue('maintenance', false)) { if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
$version = OC_Util::getVersion();
$oldTheme = OC_Config::getValue('theme');
OC_Config::setValue('theme', ''); OC_Config::setValue('theme', '');
OC_Util::addScript('config'); // needed for web root OC_Util::addScript('config'); // needed for web root
OC_Util::addScript('update'); OC_Util::addScript('update');
$tmpl = new OC_Template('', 'update.admin', 'guest'); $tmpl = new OC_Template('', 'update.admin', 'guest');
$tmpl->assign('version', OC_Util::getVersionString()); $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(); $tmpl->printPage();
exit(); exit();
} else { } else {