Skip to content

Commit

Permalink
Get getNotificationsStatusLoop interval from YAML config (#1198)
Browse files Browse the repository at this point in the history
* Get getNotificationsStatusLoop interval from YAML config

* Get getNotificationsStatusLoop interval from YAML config

* Get getNotificationsStatusLoop interval from YAML config

* Get getNotificationsStatusLoop interval from YAML config

* Get getNotificationsStatusLoop interval from YAML config

* Get getNotificationsStatusLoop interval from YAML config
  • Loading branch information
adriendupuis authored May 10, 2024
1 parent a5e7552 commit 0d22dfd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/bundle/Controller/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function renderNotificationsPageAction(int $page): Response
'page' => $page,
'pagination' => $pagination,
'notifications' => $notifications,
'notifications_count_interval' => $this->configResolver->getParameter('notification_count.interval'),
'pager' => $pagerfanta,
])->getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
*
* Example configuration:
* ```yaml
* ezpublish:
* ibexa:
* system:
* admin_group: # configuration per siteaccess or siteaccess group
* notifications:
* warning: # type of notification
* timeout: 5000 # in milliseconds
* notification_count:
* interval: 60000 # in milliseconds
* ```
*/
class Notifications extends AbstractParser
Expand All @@ -32,26 +34,31 @@ class Notifications extends AbstractParser
*/
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
{
if (empty($scopeSettings['notifications'])) {
return;
}
if (!empty($scopeSettings['notifications'])) {
$settings = $scopeSettings['notifications'];
$nodes = ['timeout'];

$settings = $scopeSettings['notifications'];
$nodes = ['timeout'];
foreach ($settings as $type => $config) {
foreach ($nodes as $key) {
if (!isset($config[$key]) || empty($config[$key])) {
continue;
}

foreach ($settings as $type => $config) {
foreach ($nodes as $key) {
if (!isset($config[$key]) || empty($config[$key])) {
continue;
$contextualizer->setContextualParameter(
sprintf('notifications.%s.%s', $type, $key),
$currentScope,
$config[$key]
);
}

$contextualizer->setContextualParameter(
sprintf('notifications.%s.%s', $type, $key),
$currentScope,
$config[$key]
);
}
}
if (!empty($scopeSettings['notification_count']) && !empty($scopeSettings['notification_count']['interval'])) {
$contextualizer->setContextualParameter(
'notification_count.interval',
$currentScope,
$scopeSettings['notification_count']['interval']
);
}
}

/**
Expand All @@ -70,6 +77,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder)
->end()
->end()
->end()
->end()
->arrayNode('notification_count')
->children()
->scalarNode('interval')
->info('Time in milliseconds between notification count refreshment.')
->end()
->end()
->end();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ parameters:
ibexa.site_access.config.admin_group.subtree_operations.copy_subtree.limit: 100

# Notifications
ibexa.site_access.config.admin_group.notification_count.interval: 30000
ibexa.site_access.config.admin_group.notifications.error.timeout: 0
ibexa.site_access.config.admin_group.notifications.warning.timeout: 0
ibexa.site_access.config.admin_group.notifications.success.timeout: 5000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@

const notificationsTable = modal.querySelector(SELECTOR_TABLE);
currentPageLink = notificationsTable.dataset.notifications;
const interval = Number.parseInt(notificationsTable.dataset.notificationsCountInterval, 10) || INTERVAL;

modal.querySelectorAll(SELECTOR_MODAL_RESULTS).forEach((link) => link.addEventListener('click', handleModalResultsClick, false));

const getNotificationsStatusLoop = () => {
getNotificationsStatus().finally(() => {
global.setTimeout(getNotificationsStatusLoop, INTERVAL);
global.setTimeout(getNotificationsStatusLoop, interval);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
attr: {
'data-notifications': path('ibexa.notifications.render.page'),
'data-notifications-count': path('ibexa.notifications.count'),
'data-notifications-count-interval': notifications_count_interval,
'data-notifications-total': pager.nbResults,
}
} %}
Expand Down

0 comments on commit 0d22dfd

Please sign in to comment.