refactor(dashboard): Migrate saving layout and statuses to OCS

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/42973/head
provokateurin 4 months ago
parent 2d0c1c3137
commit d82fe6c7b4
No known key found for this signature in database

@ -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'],
]
];

@ -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]);
}
}

@ -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]);
}
}

@ -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": []

@ -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),
})
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save