diff options
Diffstat (limited to 'apps/dashboard/lib/Controller')
-rw-r--r-- | apps/dashboard/lib/Controller/DashboardApiController.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/dashboard/lib/Controller/DashboardApiController.php b/apps/dashboard/lib/Controller/DashboardApiController.php index bb329888b09..2e80659a2fd 100644 --- a/apps/dashboard/lib/Controller/DashboardApiController.php +++ b/apps/dashboard/lib/Controller/DashboardApiController.php @@ -28,7 +28,9 @@ namespace OCA\Dashboard\Controller; use OCP\AppFramework\OCSController; use OCP\AppFramework\Http\DataResponse; +use OCP\Dashboard\IIconWidget; use OCP\Dashboard\IManager; +use OCP\Dashboard\IWidget; use OCP\IConfig; use OCP\IRequest; @@ -83,4 +85,28 @@ class DashboardApiController extends OCSController { return new DataResponse($items); } + + /** + * Example request with Curl: + * curl -u user:passwd http://my.nc/ocs/v2.php/apps/dashboard/api/v1/widgets + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function getWidgets(): DataResponse { + $widgets = $this->dashboardManager->getWidgets(); + + $items = array_map(function(IWidget $widget) { + return [ + 'id' => $widget->getId(), + 'title' => $widget->getTitle(), + 'order' => $widget->getOrder(), + 'icon_class' => $widget->getIconClass(), + 'icon_url' => ($widget instanceof IIconWidget) ? $widget->getIconUrl() : '', + 'url' => $widget->getUrl(), + ]; + }, $widgets); + + return new DataResponse($items); + } } |