From 66f6a3e1935d2127530d17aa34cda8a2f904a676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20R=C3=B6hrl?= Date: Mon, 13 Jul 2020 11:23:44 +0200 Subject: [PATCH] times MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakob Röhrl --- lib/Controller/CardController.php | 4 +- src/components/cards/CardMenu.vue | 7 - src/components/dashboards/Dashboards.vue | 182 ++++++++++++++--------- src/services/CardApi.js | 21 --- src/store/dashboard.js | 11 +- 5 files changed, 121 insertions(+), 104 deletions(-) diff --git a/lib/Controller/CardController.php b/lib/Controller/CardController.php index ce36b81a6..dcb3e6046 100644 --- a/lib/Controller/CardController.php +++ b/lib/Controller/CardController.php @@ -25,7 +25,6 @@ namespace OCA\Deck\Controller; use OCA\Deck\Service\AssignmentService; use OCA\Deck\Service\CardService; -use OCA\Deck\Service\DashboardService; use OCP\IRequest; use OCP\AppFramework\Controller; @@ -34,11 +33,10 @@ class CardController extends Controller { private $cardService; private $assignmentService; - public function __construct($appName, IRequest $request, CardService $cardService, DashboardService $dashboardService, AssignmentService $assignmentService, $userId) { + public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) { parent::__construct($appName, $request); $this->userId = $userId; $this->cardService = $cardService; - $this->dashboardService = $dashboardService; $this->assignmentService = $assignmentService; } diff --git a/src/components/cards/CardMenu.vue b/src/components/cards/CardMenu.vue index 06cf4be25..436518a09 100644 --- a/src/components/cards/CardMenu.vue +++ b/src/components/cards/CardMenu.vue @@ -80,10 +80,6 @@ export default { name: 'CardMenu', components: { Actions, ActionButton, Modal, Multiselect }, props: { - /* id: { - type: Number, - default: null, - }, */ card: { type: Object, default: null, @@ -107,9 +103,6 @@ export default { currentBoard: state => state.currentBoard, }), - /* card() { - return this.$store.getters.cardById(this.id) - }, */ isBoardAndStackChoosen() { if (this.selectedBoard === '' || this.selectedStack === '') { return false diff --git a/src/components/dashboards/Dashboards.vue b/src/components/dashboards/Dashboards.vue index 17df4fe05..1881dbdf5 100644 --- a/src/components/dashboards/Dashboards.vue +++ b/src/components/dashboards/Dashboards.vue @@ -24,83 +24,92 @@
-
-
-

overdue

-
- -
-
- -
-

today

-
- -
-
- -
-

tomorrow

-
- -
-
- -
-

this week

-
- -
-
- -
-

later

-
- -
-
+
+
+

{{ t('deck', 'Loading Dashboard') }}

+

-
-
-

no due

-
- +
+ +
+
+

{{ t('deck', 'overdue') }}

+
+ +
+
+ +
+

{{ t('deck', 'today') }}

+
+ +
+
+ +
+

{{ t('deck', 'tomorrow') }}

+
+ +
+
+ +
+

{{ t('deck', 'this week') }}

+
+ +
+
+ +
+

{{ t('deck', 'later') }}

+
+ +
-
-

overdue

-
- +
+
+

{{ t('deck', 'no due') }}

+
+ +
-
-
-

today

-
- +
+

{{ t('deck', 'overdue') }}

+
+ +
-
-
-

tomorrow

-
- +
+

{{ t('deck', 'today') }}

+
+ +
-
-
-

this week

-
- +
+

{{ t('deck', 'tomorrow') }}

+
+ +
-
-
-

this week

-
- +
+

{{ t('deck', 'this week') }}

+
+ +
+
+ +
+

{{ t('deck', 'later') }}

+
+ +
@@ -126,10 +135,16 @@ export default { default: '', }, }, + data: function() { + return { + loading: true, + } + }, computed: { ...mapGetters([ 'withDueDashboard', 'assignedCardsDashboard', + 'dueOverdue' ]), withDueDashboardGroup() { return this.groupByDue(this.withDueDashboard) @@ -139,9 +154,31 @@ export default { }, }, created() { - this.$store.dispatch('loadDashboards') + this.getData() + }, + watch: { + "$route.params.filter"() { + this.getData() + } }, methods: { + async getData() { + this.loading = true + try { + if (this.filter === 'due') { + await this.$store.dispatch('loadDueDashboard') + } + + if (this.filter === 'assigned') { + await this.$store.dispatch('loadAssignDashboard') + } + } catch (e) { + console.error(e) + } + this.loading = false + }, + + groupByDue(dataset) { const all = { nodue: [], @@ -156,20 +193,23 @@ export default { if (card.duedate === null) { all.nodue.push(card) } else { - const days = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24) - if (days < 0) { + const hours = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 ) + let d = new Date() + let currentHour = d.getHours() + console.log(card.title +' '+ hours ) + if (hours < 0) { all.overdue.push(card) } - if (days === 0) { + if (hours >= 0 && hours < (24 - currentHour)) { all.today.push(card) } - if (days === 1) { + if (hours >= (24 - currentHour) && hours < (48 - currentHour)) { all.tomorrow.push(card) } - if (days > 1 && days < 8) { + if (hours >= (48 - currentHour) && hours < (24 * 7)) { all.thisWeek.push(card) } - if (days > 8) { + if (hours >= (24 * 7)) { all.later.push(card) } } diff --git a/src/services/CardApi.js b/src/services/CardApi.js index d52623dc2..abc3f7114 100644 --- a/src/services/CardApi.js +++ b/src/services/CardApi.js @@ -194,25 +194,4 @@ export class CardApi { return Promise.reject(err) }) } - - findAllWithDue(data) { - return axios.get(this.url(`/dashboard/due`)) - .then( - (response) => Promise.resolve(response.data), - (err) => Promise.reject(err) - ) - .catch((err) => Promise.reject(err) - ) - } - - findMyAssignedCards(data) { - return axios.get(this.url(`/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 d02ddd8d0..34ef40e3b 100644 --- a/src/store/dashboard.js +++ b/src/store/dashboard.js @@ -32,6 +32,12 @@ export default { assignedCards: [], }, getters: { + dueOverdue: state => { + return state.withDue.filter((card) => { + return card + }) + + }, withDueDashboard: state => { return state.withDue }, @@ -49,15 +55,16 @@ export default { }, actions: { - async loadDashboards({ commit }) { + async loadDueDashboard({ commit }) { const withDue = await apiClient.findAllWithDue() const withDueFlat = withDue.flat() commit('setWithDueDashboard', withDueFlat) + }, + async loadAssignDashboard({ commit }) { const assignedCards = await apiClient.findMyAssignedCards() const assignedCardsFlat = assignedCards.flat() commit('setAssignedCards', assignedCardsFlat) - }, }, }