diff --git a/Classes/Controller/HistoryController.php b/Classes/Controller/HistoryController.php index d811132..ff9b518 100644 --- a/Classes/Controller/HistoryController.php +++ b/Classes/Controller/HistoryController.php @@ -10,6 +10,7 @@ use Neos\Neos\Controller\Module\AbstractModuleController; use Neos\Neos\Domain\Repository\DomainRepository; use Neos\Neos\Domain\Repository\SiteRepository; +use Neos\Neos\Domain\Service\ConfigurationContentDimensionPresetSource; use Neos\Neos\Domain\Service\UserService; use Neos\Neos\EventLog\Domain\Model\EventsOnDate; use Neos\Neos\EventLog\Domain\Model\NodeEvent; @@ -56,6 +57,12 @@ class HistoryController extends AbstractModuleController */ protected $userService; + /** + * @Flow\Inject + * @var ConfigurationContentDimensionPresetSource + */ + protected $configurationContentDimensionPresetSource; + /** * Show event overview. * @@ -64,15 +71,19 @@ class HistoryController extends AbstractModuleController * @param string|null $siteIdentifier * @param string|null $nodeIdentifier * @param string|null $accountIdentifier - * + * @param string|null $dimensionsHash * @return void + * @throws \Neos\Flow\Http\Exception + * @throws \Neos\Flow\Mvc\Routing\Exception\MissingActionNameException + * @throws \Neos\Neos\Domain\Exception */ public function indexAction( int $offset = 0, int $limit = 25, string $siteIdentifier = null, string $nodeIdentifier = null, - string $accountIdentifier = null + string $accountIdentifier = null, + string $dimensionsHash = null ) { if ($nodeIdentifier === '') { $nodeIdentifier = null; @@ -99,6 +110,25 @@ public function indexAction( $accounts[$identifier] = $user ? $user->getName()->getFullName() : $identifier; } + $dimensions = []; + + $savedDimensions = $this->nodeEventRepository->findUniqueDimensions(); + + if (!empty($savedDimensions)) { + $dimensionPresets = $this->configurationContentDimensionPresetSource->getAllPresets(); + + foreach ($savedDimensions as $savedDimensionData) { + $label = ''; + foreach ($savedDimensionData['dimension'] as $dimension => $value) { + $presetLabel = str_replace(' ', '-', $dimensionPresets[$dimension]['presets'][$value[0]]['label']); + $label .= $presetLabel . '_'; + } + + $dimensions[$savedDimensionData['dimensionsHash']] = rtrim($label, '_'); + } + + } + /** @var NodeEvent[] $events */ $events = $this->nodeEventRepository ->findRelevantEventsByWorkspace( @@ -107,7 +137,8 @@ public function indexAction( 'live', $siteIdentifier ?: null, $nodeIdentifier, - $accountIdentifier ?: null + $accountIdentifier ?: null, + $dimensionsHash ?: null ) ->toArray() ; @@ -126,9 +157,7 @@ public function indexAction( 'nodeIdentifier' => $nodeIdentifier, 'offset' => $offset + $limit, 'siteIdentifier' => $siteIdentifier, - ], - 'History', - 'Neos.Neos' + ] ) ; } @@ -166,6 +195,7 @@ public function indexAction( $this->view->assignMultiple([ 'accountIdentifier' => $accountIdentifier, + 'dimensionsHash' => $dimensionsHash, 'eventsByDate' => $eventsByDate, 'firstEvent' => $firstEvent, 'nextPage' => $nextPage, @@ -173,6 +203,7 @@ public function indexAction( 'siteIdentifier' => $siteIdentifier, 'sites' => $sites, 'accounts' => $accounts, + 'dimensions' => $dimensions, ]); } diff --git a/Classes/Domain/Repository/NodeEventRepository.php b/Classes/Domain/Repository/NodeEventRepository.php index 073e362..b46ef57 100644 --- a/Classes/Domain/Repository/NodeEventRepository.php +++ b/Classes/Domain/Repository/NodeEventRepository.php @@ -24,7 +24,7 @@ class NodeEventRepository extends EventRepository * @param string|null $siteIdentifier * @param string|null $nodeIdentifier * @param string|null $accountIdentifier - * + * @param string|null $dimensionsHash * @return QueryResultInterface */ public function findRelevantEventsByWorkspace( @@ -33,7 +33,8 @@ public function findRelevantEventsByWorkspace( $workspaceName, string $siteIdentifier = null, string $nodeIdentifier = null, - string $accountIdentifier = null + string $accountIdentifier = null, + string $dimensionsHash = null ) : QueryResultInterface { $query = $this->prepareRelevantEventsQuery(); $queryBuilder = $query->getQueryBuilder(); @@ -61,6 +62,12 @@ public function findRelevantEventsByWorkspace( ->setParameter('accountIdentifier', $accountIdentifier) ; } + if ($dimensionsHash !== null) { + $queryBuilder + ->andWhere('e.dimensionsHash = :dimensionsHash') + ->setParameter('dimensionsHash', $dimensionsHash) + ; + } $queryBuilder->setFirstResult($offset); $queryBuilder->setMaxResults($limit); @@ -110,8 +117,19 @@ public function findAccountIdentifiers( $dqlQuery = $this->createDqlQuery($dql); $dqlQuery->setParameters($query->getParameters()); - return array_map(function($result) { + return array_map(static function ($result) { return $result['accountIdentifier']; }, $dqlQuery->execute()); } + + public function findUniqueDimensions(): array + { + $queryBuilder = $this->createQueryBuilder('event'); + $queryBuilder + ->select('event.dimension') + ->addSelect('event.dimensionsHash') + ->where($queryBuilder->expr()->isNotNull('event.dimension')); + $queryBuilder->groupBy('event.dimensionsHash'); + return $queryBuilder->getQuery()->getArrayResult(); + } } diff --git a/Resources/Private/Fusion/Root.fusion b/Resources/Private/Fusion/Root.fusion index 29fdb4d..bf43b0c 100644 --- a/Resources/Private/Fusion/Root.fusion +++ b/Resources/Private/Fusion/Root.fusion @@ -3,6 +3,7 @@ include: resource://Neos.Neos/Private/Fusion/Backend/History/Root.fusion AE.History.HistoryController.index = AE.History:Template { accountIdentifier = ${accountIdentifier} + dimensionsHash = ${dimensionsHash} eventsByDate = ${eventsByDate} firstEvent = ${firstEvent} nextPage = ${nextPage} @@ -10,6 +11,7 @@ AE.History.HistoryController.index = AE.History:Template { siteIdentifier = ${siteIdentifier} sites = ${sites} accounts = ${accounts} + dimensions = ${dimensions} eventRenderer = Neos.Neos:History.EventRenderer } diff --git a/Resources/Private/Templates/History/Index.html b/Resources/Private/Templates/History/Index.html index b303354..9ad6257 100644 --- a/Resources/Private/Templates/History/Index.html +++ b/Resources/Private/Templates/History/Index.html @@ -44,6 +44,24 @@
+ + + +
+
+
+