Skip to content

Commit

Permalink
feature: artifact support
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Oct 23, 2018
1 parent 7d65884 commit 05b4bf4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/ProcessManagerBundle/EventListener/ArtifactListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
30 changes: 30 additions & 0 deletions src/ProcessManagerBundle/Migrations/Version20181023141014.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace ProcessManagerBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Pimcore\Migrations\Migration\AbstractPimcoreMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20181023141014 extends AbstractPimcoreMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$processesTable = $schema->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");
}
}
7 changes: 7 additions & 0 deletions src/ProcessManagerBundle/Model/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class Process extends AbstractModel implements ProcessInterface
*/
public $completed;

/**
* @var null|Asset
*/
public $artifact;

/**
* @param string $name
* @param string|null $type
Expand Down Expand Up @@ -280,12 +285,14 @@ public function getPercentage() {
*/
public function setArtifact(Asset $artifact)
{
$this->artifact = $artifact;
}

/**
* @return null|Asset
*/
public function getArtifact()
{
return $this->artifact;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 05b4bf4

Please sign in to comment.