mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
allow filtering dashboard items api by widgets
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
0e5944748d
commit
7f52a99ffb
1 changed files with 8 additions and 4 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue