Browse Source
refactor(dashboard): Migrate saving layout and statuses to OCS
Signed-off-by: provokateurin <kate@provokateurin.de>
pull/42973/head
provokateurin
2 years ago
Failed to extract signature
7 changed files with
191 additions and
28 deletions
-
apps/dashboard/appinfo/routes.php
-
apps/dashboard/lib/Controller/DashboardApiController.php
-
apps/dashboard/lib/Controller/DashboardController.php
-
apps/dashboard/openapi.json
-
apps/dashboard/src/DashboardApp.vue
-
dist/dashboard-main.js
-
dist/dashboard-main.js.map
|
|
|
@ -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), |
|
|
|
}) |
|
|
|
}, |
|
|
|
|