diff --git a/appinfo/routes.php b/appinfo/routes.php index 96774f444..506cebd7b 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -66,10 +66,6 @@ return [ ['name' => 'card#assignUser', 'url' => '/cards/{cardId}/assign', 'verb' => 'POST'], ['name' => 'card#unassignUser', 'url' => '/cards/{cardId}/unassign', 'verb' => 'PUT'], - // dashboard - ['name' => 'card#findAllWithDue', 'url' => '/dashboard/due', 'verb' => 'GET'], - ['name' => 'card#findMyAssignedCards', 'url' => '/dashboard/assigned', 'verb' => 'GET'], - // attachments ['name' => 'attachment#getAll', 'url' => '/cards/{cardId}/attachments', 'verb' => 'GET'], ['name' => 'attachment#create', 'url' => '/cards/{cardId}/attachment', 'verb' => 'POST'], @@ -138,5 +134,9 @@ return [ ['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'], ['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'], ['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'], + + // dashboard + ['name' => 'dashboard_api#findAllWithDue', 'url' => '/api/v1.0/dashboard/dashboard/due', 'verb' => 'GET'], + ['name' => 'dashboard_api#findAssignedCards', 'url' => '/api/v1.0/dashboard/assigned', 'verb' => 'GET'], ] -]; +]; \ No newline at end of file diff --git a/lib/Controller/CardController.php b/lib/Controller/CardController.php index db6bc08bd..ce36b81a6 100644 --- a/lib/Controller/CardController.php +++ b/lib/Controller/CardController.php @@ -167,20 +167,4 @@ class CardController extends Controller { public function unassignUser($cardId, $userId, $type = 0) { return $this->assignmentService->unassignUser($cardId, $userId, $type); } - - /** - * @NoAdminRequired - * @return array - */ - public function findAllWithDue($userId) { - return $this->dashboardService->findAllWithDue($userId); - } - - /** - * @NoAdminRequired - * @return array - */ - public function findMyAssignedCards($userId) { - return $this->dashboardService->findMyAssignedCards($userId); - } } diff --git a/lib/Controller/DashboardApiController.php b/lib/Controller/DashboardApiController.php new file mode 100644 index 000000000..df989b8c8 --- /dev/null +++ b/lib/Controller/DashboardApiController.php @@ -0,0 +1,56 @@ + + * + * @author Jakob Röhrl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Deck\Controller; + + +use OCA\Deck\Service\DashboardService; +use OCP\IRequest; +use OCP\AppFramework\Controller; + +class DashboardApiController extends OCSController { + private $userId; + private $cardService; + + public function __construct($appName, IRequest $request, DashboardService $dashboardService, $userId) { + parent::__construct($appName, $request); + $this->userId = $userId; + $this->dashboardService = $dashboardService; + } + + /** + * @NoAdminRequired + * @return array + */ + public function findAllWithDue($userId) { + return $this->dashboardService->findAllWithDue($userId); + } + + /** + * @NoAdminRequired + * @return array + */ + public function findAssignedCards($userId) { + return $this->dashboardService->findAssignedCards($userId); + } +} diff --git a/lib/Db/CardMapper.php b/lib/Db/CardMapper.php index 1a77dac0d..bbbcdb560 100644 --- a/lib/Db/CardMapper.php +++ b/lib/Db/CardMapper.php @@ -149,7 +149,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper { return $this->findEntities($sql, [$boardId]); } - public function findMyAssignedCards($boardId, $username) { + public function findAssignedCards($boardId, $username) { $sql = 'SELECT c.* FROM `*PREFIX*deck_cards` c INNER JOIN `*PREFIX*deck_stacks` s ON s.id = c.stack_id INNER JOIN `*PREFIX*deck_boards` b ON b.id = s.board_id diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 4b969709a..9d4867705 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -583,8 +583,8 @@ class CardService { * @throws \OCA\Deck\NoPermissionException * @throws BadRequestException */ - public function findMyAssignedCards($userId) { - $cards = $this->cardMapper->findMyAssignedCards($userId); + public function findAssignedCards($userId) { + $cards = $this->cardMapper->findAssignedCards($userId); return $cards; } diff --git a/lib/Service/DashboardService.php b/lib/Service/DashboardService.php index 000c2bc8c..316c6df60 100644 --- a/lib/Service/DashboardService.php +++ b/lib/Service/DashboardService.php @@ -144,7 +144,7 @@ class DashboardService { /** * @return array */ - public function findMyAssignedCards($userId) { + public function findAssignedCards($userId) { $userInfo = $this->getBoardPrerequisites(); $userBoards = $this->findAllBoardsFromUser($userInfo); $allAssignedCards = []; @@ -155,7 +155,7 @@ class DashboardService { $cardData = $card->jsonSerialize(); $cardData['boardId'] = $userBoard->getId(); return $cardData; - }, $this->cardMapper->findMyAssignedCards($userBoard->getId(), $this->userId)); + }, $this->cardMapper->findAssignedCards($userBoard->getId(), $this->userId)); } return $allAssignedCards; } diff --git a/src/App.vue b/src/App.vue index ee190cd62..c5237165f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -85,7 +85,6 @@ export default { created() { this.$store.dispatch('loadBoards') this.$store.dispatch('loadSharees') - this.$store.dispatch('loadDashboards') }, } diff --git a/src/components/cards/CardBadges.vue b/src/components/cards/CardBadges.vue index cdef86f03..59b124615 100644 --- a/src/components/cards/CardBadges.vue +++ b/src/components/cards/CardBadges.vue @@ -21,7 +21,7 @@ --> diff --git a/src/components/cards/CardItem.vue b/src/components/cards/CardItem.vue index ddae4f234..291202afe 100644 --- a/src/components/cards/CardItem.vue +++ b/src/components/cards/CardItem.vue @@ -25,7 +25,7 @@ --> @@ -81,6 +91,7 @@ import Controls from '../Controls' import CardItem from '../cards/CardItem' import { mapGetters } from 'vuex' +import moment from '@nextcloud/moment' export default { name: 'Dashboards', @@ -106,6 +117,9 @@ export default { return this.groupByDue(this.assignedCardsDashboard) }, }, + created() { + this.$store.dispatch('loadDashboards') + }, methods: { groupByDue(dataset) { const all = { diff --git a/src/services/DashboardApi.js b/src/services/DashboardApi.js new file mode 100644 index 000000000..7b67980f0 --- /dev/null +++ b/src/services/DashboardApi.js @@ -0,0 +1,53 @@ +/* + * @copyright Copyright (c) 2020 Jakob Röhrl + * + * @author Jakob Röhrl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import axios from '@nextcloud/axios' +import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router' + +export class DashboardApi { + + url(url) { + url = `/apps/deck${url}` + return generateOcsUrl(url) + } + + findAllWithDue(data) { + return axios.get(this.url(`/api/v1.0/dashboard/dashboard/due`)) + .then( + (response) => Promise.resolve(response.data), + (err) => Promise.reject(err) + ) + .catch((err) => Promise.reject(err) + ) + } + + findMyAssignedCards(data) { + return axios.get(this.url(`/ocs/v2.php/apps/deck/api/v1.0/dashboard/assigned`)) + .then( + (response) => Promise.resolve(response.data), + (err) => Promise.reject(err) + ) + .catch((err) => Promise.reject(err) + ) + } + +} diff --git a/src/store/dashboard.js b/src/store/dashboard.js index d5d2d030c..d02ddd8d0 100644 --- a/src/store/dashboard.js +++ b/src/store/dashboard.js @@ -22,10 +22,10 @@ import Vue from 'vue' import Vuex from 'vuex' -import { CardApi } from '../services/CardApi' +import { DashboardApi } from '../services/DashboardApi' Vue.use(Vuex) -const apiClient = new CardApi() +const apiClient = new DashboardApi() export default { state: { withDue: [], @@ -57,7 +57,7 @@ export default { const assignedCards = await apiClient.findMyAssignedCards() const assignedCardsFlat = assignedCards.flat() commit('setAssignedCards', assignedCardsFlat) - + }, }, }