diff options
author | provokateurin <kate@provokateurin.de> | 2024-01-19 21:55:26 +0100 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-05-10 09:44:01 +0200 |
commit | d82fe6c7b406465d3ec903c1a69bc81adbfeb481 (patch) | |
tree | 9db6d3da3141724b58f5d819c55e03843d1d40be /apps/dashboard | |
parent | 2d0c1c313791420e963b0087fe4afa8fd6e577bd (diff) | |
download | nextcloud-server-d82fe6c7b406465d3ec903c1a69bc81adbfeb481.tar.gz nextcloud-server-d82fe6c7b406465d3ec903c1a69bc81adbfeb481.zip |
refactor(dashboard): Migrate saving layout and statuses to OCS
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/dashboard')
-rw-r--r-- | apps/dashboard/appinfo/routes.php | 4 | ||||
-rw-r--r-- | apps/dashboard/lib/Controller/DashboardApiController.php | 28 | ||||
-rw-r--r-- | apps/dashboard/lib/Controller/DashboardController.php | 21 | ||||
-rw-r--r-- | apps/dashboard/openapi.json | 156 | ||||
-rw-r--r-- | apps/dashboard/src/DashboardApp.vue | 4 |
5 files changed, 188 insertions, 25 deletions
diff --git a/apps/dashboard/appinfo/routes.php b/apps/dashboard/appinfo/routes.php index e872c47084b..21c8ea7b2de 100644 --- a/apps/dashboard/appinfo/routes.php +++ b/apps/dashboard/appinfo/routes.php @@ -28,12 +28,12 @@ declare(strict_types=1); return [ 'routes' => [ ['name' => 'dashboard#index', 'url' => '/', 'verb' => 'GET'], - ['name' => 'dashboard#updateLayout', 'url' => '/layout', 'verb' => 'POST'], - ['name' => 'dashboard#updateStatuses', 'url' => '/statuses', 'verb' => 'POST'], ], 'ocs' => [ ['name' => 'dashboardApi#getWidgets', 'url' => '/api/v1/widgets', 'verb' => 'GET'], ['name' => 'dashboardApi#getWidgetItems', 'url' => '/api/v1/widget-items', 'verb' => 'GET'], ['name' => 'dashboardApi#getWidgetItemsV2', 'url' => '/api/v2/widget-items', 'verb' => 'GET'], + ['name' => 'dashboardApi#updateLayout', 'url' => '/api/v3/layout', 'verb' => 'POST'], + ['name' => 'dashboardApi#updateStatuses', 'url' => '/api/v3/statuses', 'verb' => 'POST'], ] ]; diff --git a/apps/dashboard/lib/Controller/DashboardApiController.php b/apps/dashboard/lib/Controller/DashboardApiController.php index 329b045c461..62aeca4e607 100644 --- a/apps/dashboard/lib/Controller/DashboardApiController.php +++ b/apps/dashboard/lib/Controller/DashboardApiController.php @@ -189,4 +189,32 @@ class DashboardApiController extends OCSController { return new DataResponse($items); } + + /** + * Update the layout + * + * @NoAdminRequired + * @param string $layout The new layout + * @return DataResponse<Http::STATUS_OK, array{layout: string}, array{}> + * + * 200: Statuses updated successfully + */ + public function updateLayout(string $layout): DataResponse { + $this->config->setUserValue($this->userId, 'dashboard', 'layout', $layout); + return new DataResponse(['layout' => $layout]); + } + + /** + * Update the statuses + * + * @NoAdminRequired + * @param string $statuses The new statuses + * @return DataResponse<Http::STATUS_OK, array{statuses: string}, array{}> + * + * 200: Statuses updated successfully + */ + public function updateStatuses(string $statuses): DataResponse { + $this->config->setUserValue($this->userId, 'dashboard', 'statuses', $statuses); + return new DataResponse(['statuses' => $statuses]); + } } diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php index e5cda4adf11..f84dab491d8 100644 --- a/apps/dashboard/lib/Controller/DashboardController.php +++ b/apps/dashboard/lib/Controller/DashboardController.php @@ -33,7 +33,6 @@ namespace OCA\Dashboard\Controller; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\OpenAPI; -use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; use OCP\Dashboard\IManager; @@ -104,24 +103,4 @@ class DashboardController extends Controller { return $response; } - - /** - * @NoAdminRequired - * @param string $layout - * @return JSONResponse - */ - public function updateLayout(string $layout): JSONResponse { - $this->config->setUserValue($this->userId, 'dashboard', 'layout', $layout); - return new JSONResponse(['layout' => $layout]); - } - - /** - * @NoAdminRequired - * @param string $statuses - * @return JSONResponse - */ - public function updateStatuses(string $statuses): JSONResponse { - $this->config->setUserValue($this->userId, 'dashboard', 'statuses', $statuses); - return new JSONResponse(['statuses' => $statuses]); - } } diff --git a/apps/dashboard/openapi.json b/apps/dashboard/openapi.json index fb093d5d36f..21021be9df2 100644 --- a/apps/dashboard/openapi.json +++ b/apps/dashboard/openapi.json @@ -430,6 +430,162 @@ } } } + }, + "/ocs/v2.php/apps/dashboard/api/v3/layout": { + "post": { + "operationId": "dashboard_api-update-layout", + "summary": "Update the layout", + "tags": [ + "dashboard_api" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "layout", + "in": "query", + "description": "The new layout", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Statuses updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "object", + "required": [ + "layout" + ], + "properties": { + "layout": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/apps/dashboard/api/v3/statuses": { + "post": { + "operationId": "dashboard_api-update-statuses", + "summary": "Update the statuses", + "tags": [ + "dashboard_api" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "statuses", + "in": "query", + "description": "The new statuses", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Statuses updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "object", + "required": [ + "statuses" + ], + "properties": { + "statuses": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + } } }, "tags": [] diff --git a/apps/dashboard/src/DashboardApp.vue b/apps/dashboard/src/DashboardApp.vue index 18dc0a6c467..c7143335078 100644 --- a/apps/dashboard/src/DashboardApp.vue +++ b/apps/dashboard/src/DashboardApp.vue @@ -349,12 +349,12 @@ export default { } }, saveLayout() { - axios.post(generateUrl('/apps/dashboard/layout'), { + axios.post(generateOcsUrl('/apps/dashboard/api/v3/layout'), { layout: this.layout.join(','), }) }, saveStatuses() { - axios.post(generateUrl('/apps/dashboard/statuses'), { + axios.post(generateOcsUrl('/apps/dashboard/api/v3/statuses'), { statuses: JSON.stringify(this.enabledStatuses), }) }, |