From 2cea2b5bac1e50d0ba8168ace95d8fa2234cde24 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 13 Dec 2012 21:09:16 +0100 Subject: [PATCH] Fixed ACP worker Fixes #977 --- wcfsetup/install/files/acp/js/WCF.ACP.js | 73 +++++++++++-------- .../install/files/acp/templates/worker.tpl | 11 +-- .../acp/action/WorkerProxyAction.class.php | 30 +------- wcfsetup/install/lang/de.xml | 4 + 4 files changed, 54 insertions(+), 64 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index ff98f34143..5922a7167e 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -966,6 +966,12 @@ WCF.ACP.Options.Group = Class.extend({ * @param object options */ WCF.ACP.Worker = Class.extend({ + /** + * true, if worker was aborted + * @var boolean + */ + _aborted: false, + /** * dialog id * @var string @@ -978,16 +984,29 @@ WCF.ACP.Worker = Class.extend({ */ _dialog: null, + /** + * action proxy + * @var WCF.Action.Proxy + */ + _proxy: null, + /** * Initializes a new worker instance. * * @param string dialogID * @param string className - * @param object options + * @param string title + * @param object parameters */ - init: function(dialogID, className, options) { + init: function(dialogID, className, title, parameters) { + this._aborted = false; this._dialogID = dialogID + 'Worker'; - options = options || { }; + this._dialog = null; + this._proxy = new WCF.Action.Proxy({ + showLoadingOverlay: false, + success: $.proxy(this._success, this), + url: 'index.php/WorkerProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND + }); // initialize AJAX-based dialog WCF.showAJAXDialog(this._dialogID, true, { @@ -995,52 +1014,46 @@ WCF.ACP.Worker = Class.extend({ type: 'POST', data: { className: className, - parameters: options + parameters: parameters || { } }, - success: $.proxy(this._handleResponse, this), - - preventClose: true, - hideTitle: true + success: $.proxy(this._success, this), + onClose: $.proxy(function() { this._aborted = true; }, this), + title: title }); }, /** * Handles response from server. + * + * @param object data */ - _handleResponse: function($data) { + _success: function(data) { + if (this._aborted) { + return; + } + // init binding if (this._dialog === null) { this._dialog = $('#' + $.wcfEscapeID(this._dialogID)); } // update progress - this._dialog.find('#workerProgress').attr('value', $data.progress).text($data.progress + '%'); + this._dialog.find('progress').attr('value', data.progress).text(data.progress + '%').next('span').text(data.progress + '%'); // worker is still busy with it's business, carry on - if ($data.progress < 100) { + if (data.progress < 100) { // send request for next loop - $.ajax({ - url: 'index.php/WorkerProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND, - type: 'POST', - data: { - className: $data.className, - loopCount: $data.loopCount, - parameters: $data.parameters - }, - success: $.proxy(this._handleResponse, this), - error: function(transport) { - alert(transport.responseText); - } + this._proxy.setOption('data', { + className: data.className, + loopCount: data.loopCount, + parameter: data.parameters }); + this._proxy.sendRequest(); } else { - // display proceed button - var $proceedButton = $('').appendTo('#workerInnerContent'); - $proceedButton.click(function() { - window.location = $data.proceedURL; - }); - - $('#workerInnerContentContainer').wcfBlindIn(); + // display continue button + var $formSubmit = $('
').appendTo(this._dialog); + $('').appendTo($formSubmit).click(function() { window.location = data.proceedURL; }); this._dialog.wcfDialog('render'); } diff --git a/wcfsetup/install/files/acp/templates/worker.tpl b/wcfsetup/install/files/acp/templates/worker.tpl index a646d7b69d..73f6f1fcc2 100644 --- a/wcfsetup/install/files/acp/templates/worker.tpl +++ b/wcfsetup/install/files/acp/templates/worker.tpl @@ -1,14 +1,9 @@
-
-

Aufgaben werden ausgeführt …

-

Aktueller Schritt: {lang}wcf.package.installation.step.prepare{/lang}

-

0%

+
+

{lang}wcf.acp.worker.executing{/lang}

+ 0% 0%
- -
diff --git a/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php b/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php index 87a17ff470..f89366cb87 100644 --- a/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php @@ -1,6 +1,7 @@ getMessage()); - } - } - } - /** * @see wcf\action\IAction::readParameters() */ public function readParameters() { - parent::readParameters(); + AbstractSecureAction::readParameters(); if (isset($_POST['className'])) $this->className = $_POST['className']; if (isset($_POST['loopCount'])) $this->loopCount = intval($_POST['loopCount']); @@ -89,7 +67,7 @@ class WorkerProxyAction extends AbstractSecureAction { * @see wcf\action\IAction::execute() */ public function execute() { - parent::execute(); + AbstractSecureAction::execute(); if ($this->loopCount == -1) { $this->sendResponse(); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 1abea7785f..4468b912f0 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -518,6 +518,10 @@ + + + + -- 2.20.1