diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-23 16:04:13 +0300 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-09-15 19:05:52 +0300 |
commit | 7f52a99ffbecd23c8a93284b97b1285411a5ddca (patch) | |
tree | cb157b2df1e88ea5a3e1737aca2bcbc5484a6182 /apps | |
parent | 0e5944748df24fde54e34cb1fcc0f15fb0d734de (diff) |
allow filtering dashboard items api by widgets
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dashboard/lib/Controller/DashboardApiController.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/dashboard/lib/Controller/DashboardApiController.php b/apps/dashboard/lib/Controller/DashboardApiController.php index 2e80659a2fd..3a41c42cc9b 100644 --- a/apps/dashboard/lib/Controller/DashboardApiController.php +++ b/apps/dashboard/lib/Controller/DashboardApiController.php @@ -64,19 +64,23 @@ class DashboardApiController extends OCSController { * * @param array $sinceIds Array indexed by widget Ids, contains date/id from which we want the new items * @param int $limit Limit number of result items per widget + * @param string[] $widgets Limit results to specific widgets * * @NoAdminRequired * @NoCSRFRequired */ - public function getWidgetItems(array $sinceIds = [], int $limit = 7): DataResponse { + public function getWidgetItems(array $sinceIds = [], int $limit = 7, array $widgets = []): DataResponse { + $showWidgets = $widgets; $items = []; - $systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar'); - $userLayout = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault)); + if ($showWidgets === []) { + $systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar'); + $showWidgets = explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault)); + } $widgets = $this->dashboardManager->getWidgets(); foreach ($widgets as $widget) { - if ($widget instanceof IAPIWidget && in_array($widget->getId(), $userLayout)) { + if ($widget instanceof IAPIWidget && in_array($widget->getId(), $showWidgets)) { $items[$widget->getId()] = array_map(function (WidgetItem $item) { return $item->jsonSerialize(); }, $widget->getItems($this->userId, $sinceIds[$widget->getId()] ?? null, $limit)); |