diff --git a/src/ProcessManagerBundle/EventListener/ArtifactListener.php b/src/ProcessManagerBundle/EventListener/ArtifactListener.php index 9546d3f..959e46e 100644 --- a/src/ProcessManagerBundle/EventListener/ArtifactListener.php +++ b/src/ProcessManagerBundle/EventListener/ArtifactListener.php @@ -24,14 +24,23 @@ public function onProcessLogEvent(ProcessLogEvent $event) return; } + // TODO: need asset path in Executable config, hardcoded for now + $artifactAssetPath = '/exports'; + /** @var ProcessInterface $process */ $process = $record['extra']['process']; $artifactPath = $record['context']['artifact']; - - // TODO: copy $artifactPath in place of this asset $artifact = new Asset(); + // TODO: how to do this better? + // this loads the entire file in memory instead of just moving the file using the filesystem + $artifact->setData(file_get_contents($artifactPath)); + $artifact->setFilename(pathinfo($artifactPath, PATHINFO_FILENAME)); + $artifact->setParent(Asset\Service::createFolderByPath($artifactAssetPath)); + $artifact->addMetadata('process_manager.process', 'number', $process->getId()); + $artifact->save(); + $process->setArtifact($artifact); $process->save(); } diff --git a/src/ProcessManagerBundle/Migrations/Version20181023141014.php b/src/ProcessManagerBundle/Migrations/Version20181023141014.php new file mode 100644 index 0000000..8d34af1 --- /dev/null +++ b/src/ProcessManagerBundle/Migrations/Version20181023141014.php @@ -0,0 +1,30 @@ +getTable("process_manager_processes"); + $processesTable->addColumn("artifact", "asset", ['notnull' => true]); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $processesTable = $schema->getTable("process_manager_processes"); + $processesTable->dropColumn("artifact"); + } +} diff --git a/src/ProcessManagerBundle/Model/Process.php b/src/ProcessManagerBundle/Model/Process.php index 5c75f44..13a2b56 100644 --- a/src/ProcessManagerBundle/Model/Process.php +++ b/src/ProcessManagerBundle/Model/Process.php @@ -60,6 +60,11 @@ class Process extends AbstractModel implements ProcessInterface */ public $completed; + /** + * @var null|Asset + */ + public $artifact; + /** * @param string $name * @param string|null $type @@ -280,6 +285,7 @@ public function getPercentage() { */ public function setArtifact(Asset $artifact) { + $this->artifact = $artifact; } /** @@ -287,5 +293,6 @@ public function setArtifact(Asset $artifact) */ public function getArtifact() { + return $this->artifact; } } diff --git a/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js b/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js index da660c9..5fa5342 100644 --- a/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js +++ b/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js @@ -53,7 +53,8 @@ pimcore.plugin.processmanager.processes = Class.create({ { name:'progress' }, { name:'total' }, { name:'started' }, - { name:'completed' } + { name:'completed' }, + { name:'artifact' } ]); var store = new Ext.data.Store({ @@ -207,6 +208,21 @@ pimcore.plugin.processmanager.processes = Class.create({ } ] }, + { + text : t('processmanager_artifact_download'), + xtype:'actioncolumn', + width:50, + items: [ + { + iconCls : 'pimcore_icon_download', + tooltip: t('processmanager_artifact_download'), + handler: function(grid, rowIndex) { + var id = grid.getStore().getAt(rowIndex).get('id'); + pimcore.helpers.download("/admin/asset/download?id=" + id) + }.bind(this) + } + ] + }, { xtype:'actioncolumn', width:50, diff --git a/src/ProcessManagerBundle/Resources/translations/admin.en.yml b/src/ProcessManagerBundle/Resources/translations/admin.en.yml index 6297dfe..c414aea 100644 --- a/src/ProcessManagerBundle/Resources/translations/admin.en.yml +++ b/src/ProcessManagerBundle/Resources/translations/admin.en.yml @@ -14,5 +14,6 @@ processmanager_executable_started: 'Executable started' processmanager_cron: 'Cron' processmanager_report: 'Report' processmanager_log_download: 'Log Download' +processmanager_artifact_download: 'Artifact Download' processmanager_started: 'Started' processmanager_completed: 'Completed'