Permalink
Browse files

Set a correct message when enqueuing tasks in background.

Remove legacy JS code for managing background tasks client-side.
  • Loading branch information...
1 parent 1c8dc98 commit 7310b0607888f4f07d900b158d5bf401d64293e4 @cdujeu cdujeu committed Sep 26, 2016
Showing with 147 additions and 430 deletions.
  1. +0 −1 core/src/core/src/pydio/Core/Controller/CliRunner.php
  2. +0 −1 core/src/core/src/pydio/Core/Controller/Controller.php
  3. +0 −37 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  4. +8 −30 core/src/core/src/pydio/Core/Http/Message/{BgActionTrigger.php → JsActionTrigger.php}
  5. +4 −0 core/src/plugins/access.fs/FsAccessDriver.php
  6. +2 −4 core/src/plugins/access.fs/fsActions.xml
  7. +2 −0 core/src/plugins/access.ftp/FtpAccessDriver.php
  8. +3 −2 core/src/plugins/action.powerfs/PowerFSController.php
  9. +2 −4 core/src/plugins/action.quicksend/class.QuicksendManager.js
  10. +12 −0 core/src/plugins/cache.doctrine/src/PydioApcuCache.php
  11. +5 −4 core/src/plugins/core.access/src/AbstractAccessDriver.php
  12. +2 −1 core/src/plugins/core.ajaxplorer/i18n/ca.php
  13. +2 −1 core/src/plugins/core.ajaxplorer/i18n/cs.php
  14. +2 −1 core/src/plugins/core.ajaxplorer/i18n/da.php
  15. +2 −1 core/src/plugins/core.ajaxplorer/i18n/de.php
  16. +1 −0 core/src/plugins/core.ajaxplorer/i18n/en.php
  17. +2 −1 core/src/plugins/core.ajaxplorer/i18n/es.php
  18. +2 −1 core/src/plugins/core.ajaxplorer/i18n/et.php
  19. +2 −1 core/src/plugins/core.ajaxplorer/i18n/eus.php
  20. +2 −1 core/src/plugins/core.ajaxplorer/i18n/fi.php
  21. +8 −7 core/src/plugins/core.ajaxplorer/i18n/fr.php
  22. +2 −1 core/src/plugins/core.ajaxplorer/i18n/gr.php
  23. +2 −1 core/src/plugins/core.ajaxplorer/i18n/he.php
  24. +2 −1 core/src/plugins/core.ajaxplorer/i18n/hu.php
  25. +1 −0 core/src/plugins/core.ajaxplorer/i18n/it.php
  26. +1 −0 core/src/plugins/core.ajaxplorer/i18n/ja.php
  27. +2 −1 core/src/plugins/core.ajaxplorer/i18n/kr.php
  28. +2 −1 core/src/plugins/core.ajaxplorer/i18n/nl.php
  29. +2 −1 core/src/plugins/core.ajaxplorer/i18n/no.php
  30. +2 −1 core/src/plugins/core.ajaxplorer/i18n/pl.php
  31. +2 −1 core/src/plugins/core.ajaxplorer/i18n/pt-br.php
  32. +2 −1 core/src/plugins/core.ajaxplorer/i18n/pt.php
  33. +2 −1 core/src/plugins/core.ajaxplorer/i18n/ru.php
  34. +2 −1 core/src/plugins/core.ajaxplorer/i18n/si.php
  35. +2 −1 core/src/plugins/core.ajaxplorer/i18n/sv.php
  36. +2 −1 core/src/plugins/core.ajaxplorer/i18n/tr.php
  37. +2 −1 core/src/plugins/core.ajaxplorer/i18n/zh-tw.php
  38. +2 −1 core/src/plugins/core.ajaxplorer/i18n/zh.php
  39. +2 −0 core/src/plugins/core.index/CoreIndexer.php
  40. +4 −0 core/src/plugins/core.mq/src/MqManager.php
  41. +3 −3 core/src/plugins/core.tasks/js/react/PydioTasks.js
  42. +9 −0 core/src/plugins/core.tasks/src/Task.php
  43. +0 −2 core/src/plugins/gui.ajax/Gruntfile.js
  44. +1 −1 core/src/plugins/gui.ajax/res/js/ajaxplorer_boot.js
  45. +0 −1 core/src/plugins/gui.ajax/res/js/ajaxplorer_core.txt
  46. +0 −1 core/src/plugins/gui.ajax/res/js/ajaxplorer_ui.txt
  47. +0 −4 core/src/plugins/gui.ajax/res/js/es6/http/PydioApi.es6
  48. +0 −172 core/src/plugins/gui.ajax/res/js/es6/model/BackgroundTasksManager.es6
  49. +1 −8 core/src/plugins/gui.ajax/res/js/es6/model/Controller.es6
  50. +0 −83 core/src/plugins/gui.ajax/res/js/ui/prototype/class.BackgroundManagerPane.js
  51. +0 −2 core/src/plugins/gui.ajax/res/js/ui/prototype/class.PydioUI.js
  52. +0 −12 core/src/plugins/gui.ajax/res/js/ui/prototype/http/class.Connexion.js
  53. +6 −1 core/src/plugins/gui.ajax/res/themes/orbit/css/components/tasks.less
  54. +8 −1 core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css
  55. +1 −0 core/src/plugins/index.elasticsearch/ElasticSearchIndexer.php
  56. +2 −0 core/src/plugins/index.lucene/LuceneIndexer.php
  57. +3 −1 core/src/plugins/mailer.phpmailer-lite/PhpMailLite.php
  58. +4 −0 core/src/plugins/meta.syncable/ChangesTracker.php
  59. +2 −1 core/src/plugins/uploader.http/HttpDownload.php
  60. +6 −24 core/src/plugins/uploader.http/manifest.xml
@@ -105,7 +105,6 @@ public static function applyActionInBackground(ContextInterface $ctx, $actionNam
$cmd .= " --$key=" . escapeshellarg($value);
}
}
- error_log($cmd);
$envSet = false;
if ($ctx->getRepository()->getContextOption($ctx, "USE_SESSION_CREDENTIALS")) {
$envSet = MemorySafe::setEnv();
@@ -387,7 +387,6 @@ private static function handleRequest($callback, ServerRequestInterface &$reques
$request = $request->withParsedBody($httpVars);
if(!empty($result)){
- error_log("Action has result " . $request->getAttribute("action").", wrapping in XML Doc");
$response->getBody()->write(XMLWriter::wrapDocument($result));
$response = $response->withHeader("Content-type", "text/xml; charset=UTF-8");
}
@@ -392,43 +392,6 @@ public static function requireAuth($print = true)
{
return XMLWriter::write("<require_auth/>", $print);
}
- /**
- * Triggers a background action client side
- * @static
- * @param $actionName
- * @param $parameters
- * @param $messageId
- * @param bool $print
- * @param int $delay
- * @return string
- */
- public static function triggerBgAction($actionName, $parameters, $messageId, $print=true, $delay = 0)
- {
- $messageId = StringHelper::xmlEntities($messageId);
- $data = XMLWriter::write("<trigger_bg_action name=\"$actionName\" messageId=\"$messageId\" delay=\"$delay\">", $print);
- foreach ($parameters as $paramName=>$paramValue) {
- $paramValue = StringHelper::xmlEntities($paramValue);
- $data .= XMLWriter::write("<param name=\"$paramName\" value=\"$paramValue\"/>", $print);
- }
- $data .= XMLWriter::write("</trigger_bg_action>", $print);
- return $data;
- }
-
- /**
- * Send directly JavaScript code to the client
- * @param $jsCode
- * @param $messageId
- * @param bool $print
- * @param int $delay
- * @return string
- */
- public static function triggerBgJSAction($jsCode, $messageId, $print=true, $delay = 0)
- {
- $data = XMLWriter::write("<trigger_bg_action name=\"javascript_instruction\" messageId=\"$messageId\" delay=\"$delay\">", $print);
- $data .= XMLWriter::write("<clientCallback><![CDATA[".$jsCode."]]></clientCallback>", $print);
- $data .= XMLWriter::write("</trigger_bg_action>", $print);
- return $data;
- }
/**
* List all bookmmarks as XML
@@ -30,51 +30,29 @@
* An XML response triggering a background action in Pydio UI.
* @package Pydio\Core\Http\Message
*/
-class BgActionTrigger implements XMLSerializableResponseChunk
+class JsActionTrigger implements XMLSerializableResponseChunk
{
- private $actionName;
- private $parameters;
- private $messageId;
private $delay;
-
private $javascriptCode;
/**
- * @param string $actionName
- * @param array $parameters
- * @param string $messageId
+ * @param string $jsCode
* @param int $delay
*/
- public function __construct($actionName, $parameters, $messageId, $delay = 0)
+ public function __construct($jsCode, $delay = 0)
{
- $this->actionName = $actionName;
- $this->parameters = $parameters;
- $this->messageId = $messageId;
+ $this->javascriptCode = $jsCode;
$this->delay = $delay;
}
/**
- * Factory for BgActionTrigger
- * @param string $jsCode
- * @param string $messageId
- * @param int $delay
- * @return BgActionTrigger
- */
- public static function createForJsAction($jsCode, $messageId, $delay = 0){
- $newOne = new BgActionTrigger("javascript_action", [], $messageId, $delay);
- $newOne->javascriptCode = $jsCode;
- return $newOne;
- }
-
- /**
* @return string
*/
public function toXML()
{
- if(isSet($this->javascriptCode)){
- return XMLWriter::triggerBgJSAction($this->javascriptCode, false, $this->delay);
- }else{
- return XMLWriter::triggerBgAction($this->actionName, $this->parameters, $this->messageId, false, $this->delay);
- }
+ $data = "<trigger_bg_action name=\"javascript_instruction\" delay=\"".$this->delay."\">";
+ $data .= "<clientCallback><![CDATA[".$this->javascriptCode."]]></clientCallback>";
+ $data .= "</trigger_bg_action>";
+ return $data;
}
}
@@ -785,6 +785,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$taskId = $request->getAttribute("pydio-task-id");
if($request->getAttribute("pydio-task-id") === null){
$task = TaskService::actionAsTask($ctx, $action, $httpVars);
+ $task->setActionLabel($mess, '313');
$task->setFlags(Task::FLAG_STOPPABLE);
$response = TaskService::getInstance()->enqueueTask($task, $request, $response);
break;
@@ -907,6 +908,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$taskId = $request->getAttribute("pydio-task-id");
if($taskId === null && ($size === -1 || $size > $bgSizeThreshold)){
$task = TaskService::actionAsTask($ctx, $action, $httpVars);
+ $task->setActionLabel($mess, '7');
if($size === -1 || $size > $bgWorkerThreshold){
$task->setSchedule(new Schedule(Schedule::TYPE_ONCE_DEFER));
}
@@ -932,6 +934,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$taskId = $request->getAttribute("pydio-task-id");
if($taskId === null && !ApplicationState::sapiIsCli()){
$task = TaskService::actionAsTask($ctx, $action, $httpVars);
+ $task->setActionLabel($mess, '221');
$response = TaskService::getInstance()->enqueueTask($task, $request, $response);
break;
}
@@ -991,6 +994,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
}
if($taskId === null && ($size === -1 || $size > $bgSizeThreshold)){
$task = TaskService::actionAsTask($ctx, $action, $httpVars);
+ $task->setActionLabel($mess, $action === 'copy' ? '66' : '70');
$task->setFlags(Task::FLAG_STOPPABLE);
if($size === -1 || $size > $bgWorkerThreshold){
$task->setSchedule(new Schedule(Schedule::TYPE_ONCE_DEFER));
@@ -146,10 +146,8 @@
}
if(pydio.getController().getActionByName("trigger_remote_copy")){
modal.setCloseAction(function(){
- ajaxplorer.fireContextRefresh();
- var bgManager = pydio.getController().getBackgroundTasksManager();
- bgManager.queueAction("trigger_remote_copy", {}, "Copying files to server");
- bgManager.next();
+ pydio.fireContextRefresh();
+ PydioApi.getClient().request({get_action:'trigger_remote_copy'});
});
}
if(uploader.dialogOnOpen){
@@ -161,6 +161,7 @@ public function uploadActions(ServerRequestInterface &$request, ResponseInterfac
if ($nextFile!='') {
//$x->addChunk(new BgActionTrigger("next_to_remote", array(), "Copying file ".TextEncoder::toUTF8($nextFile)." to remote server"));
$newTask = TaskService::actionAsTask($ctx, "next_to_remote", []);
+ $newTask->setLabel("Copying file " . $nextFile . " to remote server");
$response = TaskService::getInstance()->enqueueTask($newTask, $request, $response);
} else {
//$x->addChunk(new BgActionTrigger("reload_node", array(), "Upload done, reloading client."));
@@ -223,6 +224,7 @@ public function uploadActions(ServerRequestInterface &$request, ResponseInterfac
$this->writeUploadSuccess($request, ["PREVENT_NOTIF" => true]);
$task = TaskService::actionAsTask($ctx, "next_to_remote", []);
+ $task->setLabel("Copying file to remote server");
TaskService::getInstance()->enqueueTask($task, $request, $response);
} catch (\Exception $e) {
@@ -33,7 +33,7 @@
use Pydio\Core\PluginFramework\PluginsService;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
-use Pydio\Core\Http\Message\BgActionTrigger;
+use Pydio\Core\Http\Message\JsActionTrigger;
use Pydio\Tasks\Task;
use Pydio\Tasks\TaskService;
use RecursiveDirectoryIterator;
@@ -106,6 +106,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
if ($taskId === null) {
$task = TaskService::actionAsTask($ctx, $request->getAttribute("action"), $httpVars);
+ $task->setLabel($mess['powerfs.1']);
$task->setFlags(Task::FLAG_STOPPABLE | Task::FLAG_HAS_PROGRESS);
TaskService::getInstance()->enqueueTask($task, $request, $response);
return;
@@ -190,7 +191,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
} else {
$archiveName = str_replace("'", "\'", $originalArchiveParam);
$jsCode = " PydioApi.getClient().downloadSelection(null, $('download_form'), 'postcompress_download', {ope_id:'" . $opeId . "',archive_name:'" . $archiveName . "'}); ";
- $actionTrigger = BgActionTrigger::createForJsAction($jsCode, $mess["powerfs.3"]);
+ $actionTrigger = new JsActionTrigger($jsCode, 0);
Controller::applyHook("msg.instant", array($ctx, $actionTrigger->toXML()));
}
@@ -37,10 +37,8 @@ Class.create("QuicksendManager", AjxpPane, {
var uploader = uploaders[0];
if(pydio.getController().getActionByName("trigger_remote_copy")){
modal.setCloseAction(function(){
- ajaxplorer.fireContextRefresh();
- var bgManager = pydio.getController().getBackgroundTasksManager();
- bgManager.queueAction("trigger_remote_copy", {}, "Copying files to server");
- bgManager.next();
+ pydio.fireContextRefresh();
+ PydioApi.getClient().request({get_action:'trigger_remote_copy'});
});
}
if(uploader.dialogOnOpen){
@@ -67,4 +67,16 @@ public function setNamespace($namespace)
parent::setNamespace($namespace);
$this->internalNamespace = $namespace;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doFetchMultiple(array $keys)
+ {
+ $test = apcu_fetch($keys);
+ if($test === false) return [];
+ else return $test;
+ }
+
+
}
@@ -144,17 +144,18 @@ public function directoryUsage(AJXP_Node $node){
*/
public function crossRepositoryCopy(ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface)
{
- $httpVars = $requestInterface->getParsedBody();
+ $httpVars = $requestInterface->getParsedBody();
+ $mess = LocaleService::getMessages();
- $taskId = $requestInterface->getAttribute("pydio-task-id");
- $ctx = $requestInterface->getAttribute("ctx");
+ $taskId = $requestInterface->getAttribute("pydio-task-id");
+ $ctx = $requestInterface->getAttribute("ctx");
if(empty($taskId)){
$task = TaskService::actionAsTask($ctx, "cross_copy", $httpVars);
+ $task->setActionLabel($mess, isSet($httpVars["moving_files"]) ? '70' : '66');
$responseInterface = TaskService::getInstance()->enqueueTask($task, $requestInterface, $responseInterface);
return;
}
- $mess = LocaleService::getMessages();
$selection = UserSelection::fromContext($ctx, $httpVars);
$files = $selection->getFiles();
@@ -653,5 +653,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
-);
+);
@@ -650,4 +650,5 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
-);
+"556" => "Launching task %s in background",
+);
@@ -655,5 +655,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -657,6 +657,7 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
/* password strength tester */
-);
+);
@@ -652,4 +652,5 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
);
@@ -657,4 +657,5 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
-);
+"556" => "Launching task %s in background",
+);
@@ -653,5 +653,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -651,5 +651,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -653,5 +653,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -646,11 +646,12 @@
"546" => "Ce partage provient de %%OWNER%% d'un système distant. Souhaîtez-vous continuer ?",
"547" => "Accepter",
"548" => "Refuser",
- "549" => "Vaous avez précedemment accepté ce partage depuis un système distant (par %%OWNER%%). Désirez-vous le rejeter désormais?",
- "550" => "Rejeter ce partage",
- "551" => "Rejeter",
- "552" => "Please provide a password.",
- "553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
- "554" => "%s résultat(s) dans la Corbeille",
+"549" => "Vaous avez précedemment accepté ce partage depuis un système distant (par %%OWNER%%). Désirez-vous le rejeter désormais?",
+"550" => "Rejeter ce partage",
+"551" => "Rejeter",
+"552" => "Please provide a password.",
+"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
+"554" => "%s résultat(s) dans la Corbeille",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -650,5 +650,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -650,5 +650,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -655,5 +655,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
-);
+);
@@ -670,5 +670,6 @@
"552" => "Please provide password.",
"553" => "Invalid password, please try again. \\n Make sure your Caps Lock is not engaged!",
"554" => "%s result(s) in Recycle Bin",
+"556" => "Launching task %s in background",
/* END SENTENCE */
);
Oops, something went wrong.

0 comments on commit 7310b06

Please sign in to comment.