Skip to content

Commit 2951f5b

Browse files
committed
card dashboard
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
1 parent f94b0b1 commit 2951f5b

8 files changed

Lines changed: 99 additions & 0 deletions

File tree

appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
['name' => 'card#removeLabel', 'url' => '/cards/{cardId}/label/{labelId}', 'verb' => 'DELETE'],
6666
['name' => 'card#assignUser', 'url' => '/cards/{cardId}/assign', 'verb' => 'POST'],
6767
['name' => 'card#unassignUser', 'url' => '/cards/{cardId}/unassign', 'verb' => 'PUT'],
68+
['name' => 'card#findAllWithDue', 'url' => '/cards/findAllWithDue/{userId}', 'verb' => 'GET'],
6869

6970
['name' => 'attachment#getAll', 'url' => '/cards/{cardId}/attachments', 'verb' => 'GET'],
7071
['name' => 'attachment#create', 'url' => '/cards/{cardId}/attachment', 'verb' => 'POST'],

lib/Controller/CardController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,12 @@ public function assignUser($cardId, $userId, $type = 0) {
165165
public function unassignUser($cardId, $userId, $type = 0) {
166166
return $this->assignmentService->unassignUser($cardId, $userId, $type);
167167
}
168+
169+
/**
170+
* @NoAdminRequired
171+
* @return array
172+
*/
173+
public function findAllWithDue() {
174+
return $this->cardService->findAllWithDue();
175+
}
168176
}

lib/Db/CardMapper.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ public function findAllByStack($stackId, $limit = null, $offset = null) {
141141
return $this->findEntities($sql, [$stackId], $limit, $offset);
142142
}
143143

144+
public function findAllWithDue($userId) {
145+
$sql = 'SELECT * FROM `*PREFIX*deck_cards`
146+
inner join `*PREFIX*deck_stacks` on stack_id = `*PREFIX*deck_stacks.id`
147+
inner join `*PREFIX*deck_boards` on board_id = `*PREFIX*deck_boards.id`
148+
left join `*PREFIX*deck_board_acl` on `*PREFIX*deck_boards.id` = `*PREFIX*deck_board_acl.id`
149+
where `*PREFIX*deck_boards.owner` = ? OR participant = ?';
150+
return $this->findEntities($sql, [$userId]);
151+
}
152+
144153
public function findOverdue() {
145154
$sql = 'SELECT id,title,duedate,notified from `*PREFIX*deck_cards` WHERE duedate < NOW() AND NOT archived AND deleted_at = 0';
146155
return $this->findEntities($sql);

lib/Service/CardService.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,4 +564,16 @@ public function removeLabel($cardId, $labelId) {
564564
'\OCA\Deck\Card::onUpdate', new FTSEvent(null, ['id' => $cardId, 'card' => $card])
565565
);
566566
}
567+
568+
/**
569+
*
570+
* @return array
571+
* @throws \OCA\Deck\NoPermissionException
572+
* @throws BadRequestException
573+
*/
574+
public function findAllWithDue($userId) {
575+
$cards = $this->cardMapper->findAllWithDue($userId);
576+
577+
return $cards;
578+
}
567579
}

src/components/navigation/AppNavigation.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
<template>
2424
<div id="app-navigation" :class="{'icon-loading': loading}">
2525
<ul id="deck-navigation">
26+
<AppNavigationBoardCategory
27+
id="deck-navigation-dashboard"
28+
:text="t('deck', 'Card Dashboard')"
29+
:boards="dashboards"
30+
:open-on-add-boards="true"
31+
icon="icon-screen" />
2632
<AppNavigationBoardCategory
2733
id="deck-navigation-all"
2834
:text="t('deck', 'All boards')"
@@ -110,6 +116,7 @@ export default {
110116
'noneArchivedBoards',
111117
'archivedBoards',
112118
'sharedBoards',
119+
'dashboards',
113120
]),
114121
isAdmin() {
115122
// eslint-disable-next-line

src/services/CardApi.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,14 @@ export class CardApi {
195195
})
196196
}
197197

198+
findAllWithDue(data) {
199+
return axios.get(this.url(`/cards/findAllWithDue`))
200+
.then(
201+
(response) => Promise.resolve(response.data),
202+
(err) => Promise.reject(err)
203+
)
204+
.catch((err) => Promise.reject(err)
205+
)
206+
}
207+
198208
}

src/store/dashboard.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* @copyright Copyright (c) 2020 Jakob Röhrl <jakob.roehrl@web.de>
3+
*
4+
* @author Jakob Röhrl <jakob.roehrl@web.de>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import Vue from 'vue'
24+
import Vuex from 'vuex'
25+
import { CardApi } from '../services/CardApi'
26+
Vue.use(Vuex)
27+
28+
const apiClient = new CardApi()
29+
export default new Vuex.Store({
30+
state: {
31+
withDue: [],
32+
},
33+
getters: {
34+
dashboards: state => {
35+
return state.withDue
36+
},
37+
},
38+
mutations: {
39+
setDashboards(state, withDue) {
40+
state.withDue = withDue
41+
},
42+
43+
},
44+
actions: {
45+
async loadDashboards({ commit }) {
46+
const withDue = await apiClient.findAllWithDue()
47+
commit('setDashboards', withDue)
48+
},
49+
},
50+
})

src/store/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import card from './card'
3232
import comment from './comment'
3333
import trashbin from './trashbin'
3434
import attachment from './attachment'
35+
import dashboard from './dashboard'
3536
import debounce from 'lodash/debounce'
3637
Vue.use(Vuex)
3738

@@ -51,6 +52,7 @@ export default new Vuex.Store({
5152
comment,
5253
trashbin,
5354
attachment,
55+
dashboard,
5456
},
5557
strict: debug,
5658
state: {

0 commit comments

Comments
 (0)