Skip to content

Commit

Permalink
Merge commit 'refs/pull/487/head' of github.com:alchemy-fr/phraseanet…
Browse files Browse the repository at this point in the history
…-services into w2445
  • Loading branch information
nmaillat committed Nov 18, 2024
2 parents 60f59a5 + 3ad3480 commit 4ac32c6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function configureCrud(Crud $crud): Crud
return parent::configureCrud($crud)
->setEntityLabelInSingular('Attribute')
->setEntityLabelInPlural('Attribute')
->setSearchFields(['id', 'locale', 'position', 'translationOriginHash', 'value', 'origin', 'originVendor', 'originUserId', 'originVendorContext', 'coordinates', 'status', 'confidence'])
->setSearchFields(['id', 'locale', 'position', 'value', 'origin', 'originVendor', 'originUserId', 'originVendorContext', 'status', 'confidence'])
->setPaginatorPageSize(20);
}

Expand Down
30 changes: 30 additions & 0 deletions databox/api/src/Listener/AssetIngestWorkflowListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Listener;

use Alchemy\CoreBundle\Pusher\PusherManager;
use Alchemy\Workflow\Listener\WorkflowUpdateEvent;
use Alchemy\Workflow\State\WorkflowState;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(event: WorkflowUpdateEvent::class, method: 'onWorkflowUpdate')]
final readonly class AssetIngestWorkflowListener
{
public function __construct(
private PusherManager $pusherManager,
)
{
}

public function onWorkflowUpdate(WorkflowUpdateEvent $event): void
{
$state = $event->getState();
if (str_starts_with($state->getWorkflowName(), 'asset-ingest:') && in_array($state->getStatus(), [
WorkflowState::STATUS_SUCCESS,
WorkflowState::STATUS_FAILURE,
])) {
$assetId = $state->getEvent()->getInputs()['assetId'];
$this->pusherManager->trigger('asset-'.$assetId, 'asset_ingested', [], direct: true);
}
}
}
2 changes: 1 addition & 1 deletion databox/client/src/components/Dialog/Workspace/Acl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function Acl({data, onClose, minHeight}: Props) {
objectType={PermissionObject.Workspace}
displayedPermissions={Object.keys(aclPermissions).filter(
p => p !== AclPermission.SHARE
)}
).concat([AclPermission.ALL])}
/>
</ContentTab>
);
Expand Down
14 changes: 13 additions & 1 deletion databox/client/src/components/Media/Asset/AssetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import AssetViewActions from './Actions/AssetViewActions.tsx';
import {Trans} from 'react-i18next';
import {getMediaBackgroundColor} from '../../../themes/base.ts';
import {useModalFetch} from '../../../hooks/useModalFetch.ts';
import {useChannelRegistration} from "../../../lib/pusher.ts";
import {queryClient} from "../../../lib/query.ts";

export type IntegrationOverlayCommonProps = {
dimensions: Dimensions;
Expand Down Expand Up @@ -50,8 +52,18 @@ export default function AssetView({modalIndex, open}: Props) {
AssetAnnotation[] | undefined
>();

const queryKey = ['assets', assetId];

useChannelRegistration(
`asset-${assetId}`,
`asset_ingested`,
() => {
queryClient.invalidateQueries({queryKey});
}
);

const {data, isSuccess} = useModalFetch({
queryKey: ['assets', assetId],
queryKey,
queryFn: () =>
Promise.all([
getAsset(assetId!),
Expand Down
18 changes: 18 additions & 0 deletions lib/php/workflow/src/Listener/WorkflowUpdateEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Alchemy\Workflow\Listener;

use Alchemy\Workflow\State\WorkflowState;

readonly class WorkflowUpdateEvent
{
public function __construct(
private WorkflowState $state,
) {
}

public function getState(): WorkflowState
{
return $this->state;
}
}
5 changes: 5 additions & 0 deletions lib/php/workflow/src/WorkflowOrchestrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Alchemy\Workflow\Date\MicroDateTime;
use Alchemy\Workflow\Event\WorkflowEvent;
use Alchemy\Workflow\Listener\WorkflowUpdateEvent;
use Alchemy\Workflow\Model\Job;
use Alchemy\Workflow\Model\Workflow;
use Alchemy\Workflow\Planner\Plan;
Expand All @@ -20,6 +21,7 @@
use Alchemy\Workflow\Trigger\JobTrigger;
use Alchemy\Workflow\Trigger\JobTriggerInterface;
use Alchemy\Workflow\Validator\EventValidatorInterface;
use Psr\EventDispatcher\EventDispatcherInterface;

final class WorkflowOrchestrator
{
Expand All @@ -33,6 +35,7 @@ public function __construct(
private readonly StateRepositoryInterface $stateRepository,
private readonly JobTriggerInterface $trigger,
private readonly EventValidatorInterface $eventValidator,
private readonly EventDispatcherInterface $eventDispatcher,
) {
}

Expand Down Expand Up @@ -185,6 +188,8 @@ private function doContinueWorkflow(WorkflowState $workflowState): void
$workflowState->setEndedAt(new MicroDateTime());
$workflowState->setStatus($workflowEndStatus);
$this->stateRepository->persistWorkflowState($workflowState);

$this->eventDispatcher->dispatch(new WorkflowUpdateEvent($workflowState));
}
}

Expand Down

0 comments on commit 4ac32c6

Please sign in to comment.