summaryrefslogtreecommitdiffstats
path: root/core/ajax
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-27 12:21:31 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-28 13:52:01 +0200
commit821d8736c89eae3ad35c0ddc726a583b0c0cf99c (patch)
tree02a96643204969d6927c9ac41cef9ecdcb1f4519 /core/ajax
parentbbd2a07525db6b70645720f4c022b5562543127e (diff)
downloadnextcloud-server-821d8736c89eae3ad35c0ddc726a583b0c0cf99c.tar.gz
nextcloud-server-821d8736c89eae3ad35c0ddc726a583b0c0cf99c.zip
Adding progress to web upgrade
Diffstat (limited to 'core/ajax')
-rw-r--r--core/ajax/update.php64
1 files changed, 58 insertions, 6 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 0e6c1176ac1..f673467f64a 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -39,6 +39,56 @@ $eventSource = \OC::$server->createEventSource();
// message
$eventSource->send('success', (string)$l->t('Preparing update'));
+class FeedBackHandler {
+ /** @var integer */
+ private $progressStateMax = 100;
+ /** @var integer */
+ private $progressStateStep = 0;
+ /** @var string */
+ private $currentStep;
+
+ public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) {
+ $this->eventSource = $eventSource;
+ $this->l10n = $l10n;
+ }
+
+ public function handleRepairFeedback($event) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+
+ switch ($event->getSubject()) {
+ case '\OC\Repair::startProgress':
+ $this->progressStateMax = $event->getArgument(0);
+ $this->progressStateStep = 0;
+ $this->currentStep = $event->getArgument(1);
+ break;
+ case '\OC\Repair::advance':
+ $this->progressStateStep += $event->getArgument(0);
+ $desc = $event->getArgument(1);
+ if (empty($desc)) {
+ $desc = $this->currentStep;
+ }
+ $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
+ break;
+ case '\OC\Repair::finishProgress':
+ $this->progressStateMax = $this->progressStateStep;
+ $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
+ break;
+ case '\OC\Repair::step':
+ break;
+ case '\OC\Repair::info':
+ break;
+ case '\OC\Repair::warning':
+ $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0));
+ break;
+ case '\OC\Repair::error':
+ $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0));
+ break;
+ }
+ }
+}
+
if (OC::checkUpgrade(false)) {
$config = \OC::$server->getSystemConfig();
@@ -73,6 +123,14 @@ if (OC::checkUpgrade(false)) {
$eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
}
});
+ $feedBack = new FeedBackHandler($eventSource, $l);
+ $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']);
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
@@ -107,12 +165,6 @@ if (OC::checkUpgrade(false)) {
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
});
- $updater->listen('\OC\Updater', 'repairWarning', function ($description) use ($eventSource, $l) {
- $eventSource->send('notice', (string)$l->t('Repair warning: ') . $description);
- });
- $updater->listen('\OC\Updater', 'repairError', function ($description) use ($eventSource, $l) {
- $eventSource->send('notice', (string)$l->t('Repair error: ') . $description);
- });
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
$incompatibleApps[]= $app;
});