diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-23 15:03:41 +0200 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-09-15 18:05:52 +0200 |
commit | 0e5944748df24fde54e34cb1fcc0f15fb0d734de (patch) | |
tree | 1db9950f0d21c4757947b6cb0ab1a920767b943c /apps/dashboard/lib/Controller | |
parent | ca747b91d4aa907b191119f080d213bfb5e60fd2 (diff) | |
download | nextcloud-server-0e5944748df24fde54e34cb1fcc0f15fb0d734de.tar.gz nextcloud-server-0e5944748df24fde54e34cb1fcc0f15fb0d734de.zip |
add dashboard api to list widgets
Signed-off-by: Robin Appelman <robin@icewind.nl>
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); + } } |