Skip to content

Commit 03b3215

Browse files
committed
times
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
1 parent 48159f2 commit 03b3215

5 files changed

Lines changed: 113 additions & 96 deletions

File tree

lib/Controller/CardController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
use OCA\Deck\Service\AssignmentService;
2727
use OCA\Deck\Service\CardService;
28-
use OCA\Deck\Service\DashboardService;
2928
use OCP\IRequest;
3029
use OCP\AppFramework\Controller;
3130

@@ -34,11 +33,10 @@ class CardController extends Controller {
3433
private $cardService;
3534
private $assignmentService;
3635

37-
public function __construct($appName, IRequest $request, CardService $cardService, DashboardService $dashboardService, AssignmentService $assignmentService, $userId) {
36+
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
3837
parent::__construct($appName, $request);
3938
$this->userId = $userId;
4039
$this->cardService = $cardService;
41-
$this->dashboardService = $dashboardService;
4240
$this->assignmentService = $assignmentService;
4341
}
4442

src/components/cards/CardMenu.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ export default {
8080
name: 'CardMenu',
8181
components: { Actions, ActionButton, Modal, Multiselect },
8282
props: {
83-
/* id: {
84-
type: Number,
85-
default: null,
86-
}, */
8783
card: {
8884
type: Object,
8985
default: null,
@@ -107,9 +103,6 @@ export default {
107103
currentBoard: state => state.currentBoard,
108104
}),
109105
110-
/* card() {
111-
return this.$store.getters.cardById(this.id)
112-
}, */
113106
isBoardAndStackChoosen() {
114107
if (this.selectedBoard === '' || this.selectedStack === '') {
115108
return false

src/components/dashboards/Dashboards.vue

Lines changed: 103 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -24,83 +24,92 @@
2424
<div>
2525
<Controls :dashboard-name="filter" />
2626

27-
<div v-if="filter=='due'" class="dashboard">
28-
<div class="dashboard-column">
29-
<h2>overdue</h2>
30-
<div v-for="card in withDueDashboardGroup.overdue" :key="card.id">
31-
<CardItem :item="card" />
27+
<div v-if="loading" key="loading" class="emptycontent">
28+
<div class="icon icon-loading" />
29+
<h2>{{ t('deck', 'Loading Dashboard') }}</h2>
30+
<p />
31+
</div>
32+
33+
<div v-else>
34+
35+
<div v-if="filter=='due'" class="dashboard">
36+
<div class="dashboard-column">
37+
<h2>{{ t('deck', 'overdue') }}</h2>
38+
<div v-for="card in dueOverdue" :key="card.id">
39+
<CardItem :item="card" />
40+
</div>
3241
</div>
33-
</div>
3442

35-
<div class="dashboard-column">
36-
<h2>today</h2>
37-
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
38-
<CardItem :item="card" />
43+
<div class="dashboard-column">
44+
<h2>{{ t('deck', 'today') }}</h2>
45+
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
46+
<CardItem :item="card" />
47+
</div>
3948
</div>
40-
</div>
4149

42-
<div class="dashboard-column">
43-
<h2>tomorrow</h2>
44-
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
45-
<CardItem :item="card" />
50+
<div class="dashboard-column">
51+
<h2>{{ t('deck', 'tomorrow') }}</h2>
52+
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
53+
<CardItem :item="card" />
54+
</div>
4655
</div>
47-
</div>
4856

49-
<div class="dashboard-column">
50-
<h2>this week</h2>
51-
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
52-
<CardItem :item="card" />
57+
<div class="dashboard-column">
58+
<h2>{{ t('deck', 'this week') }}</h2>
59+
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
60+
<CardItem :item="card" />
61+
</div>
5362
</div>
54-
</div>
5563

56-
<div class="dashboard-column">
57-
<h2>later</h2>
58-
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
59-
<CardItem :item="card" />
64+
<div class="dashboard-column">
65+
<h2>{{ t('deck', 'later') }}</h2>
66+
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
67+
<CardItem :item="card" />
68+
</div>
6069
</div>
6170
</div>
62-
</div>
6371

64-
<div v-if="filter=='assigned'" class="dashboard">
65-
<div class="dashboard-column">
66-
<h2>no due</h2>
67-
<div v-for="card in withDueDashboardGroup.noDue" :key="card.id">
68-
<CardItem :item="card" />
72+
<div v-if="filter=='assigned'" class="dashboard">
73+
<div class="dashboard-column">
74+
<h2>{{ t('deck', 'no due') }}</h2>
75+
<div v-for="card in assignedCardsDashboardGroup.nodue" :key="card.id">
76+
<CardItem :item="card" />
77+
</div>
6978
</div>
70-
</div>
7179

72-
<div class="dashboard-column">
73-
<h2>overdue</h2>
74-
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
75-
<CardItem :item="card" />
80+
<div class="dashboard-column">
81+
<h2>{{ t('deck', 'overdue') }}</h2>
82+
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
83+
<CardItem :item="card" />
84+
</div>
7685
</div>
77-
</div>
7886

79-
<div class="dashboard-column">
80-
<h2>today</h2>
81-
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
82-
<CardItem :item="card" />
87+
<div class="dashboard-column">
88+
<h2>{{ t('deck', 'today') }}</h2>
89+
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
90+
<CardItem :item="card" />
91+
</div>
8392
</div>
84-
</div>
8593

86-
<div class="dashboard-column">
87-
<h2>tomorrow</h2>
88-
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
89-
<CardItem :item="card" />
94+
<div class="dashboard-column">
95+
<h2>{{ t('deck', 'tomorrow') }}</h2>
96+
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
97+
<CardItem :item="card" />
98+
</div>
9099
</div>
91-
</div>
92100

93-
<div class="dashboard-column">
94-
<h2>this week</h2>
95-
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
96-
<CardItem :item="card" />
101+
<div class="dashboard-column">
102+
<h2>{{ t('deck', 'this week') }}</h2>
103+
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
104+
<CardItem :item="card" />
105+
</div>
97106
</div>
98-
</div>
99107

100-
<div class="dashboard-column">
101-
<h2>this week</h2>
102-
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
103-
<CardItem :item="card" />
108+
<div class="dashboard-column">
109+
<h2>{{ t('deck', 'later') }}</h2>
110+
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
111+
<CardItem :item="card" />
112+
</div>
104113
</div>
105114
</div>
106115
</div>
@@ -126,10 +135,16 @@ export default {
126135
default: '',
127136
},
128137
},
138+
data: function() {
139+
return {
140+
loading: true,
141+
}
142+
},
129143
computed: {
130144
...mapGetters([
131145
'withDueDashboard',
132146
'assignedCardsDashboard',
147+
'dueOverdue'
133148
]),
134149
withDueDashboardGroup() {
135150
return this.groupByDue(this.withDueDashboard)
@@ -139,9 +154,31 @@ export default {
139154
},
140155
},
141156
created() {
142-
this.$store.dispatch('loadDashboards')
157+
this.getData()
158+
},
159+
watch: {
160+
"$route.params.filter"() {
161+
this.getData()
162+
}
143163
},
144164
methods: {
165+
async getData() {
166+
this.loading = true
167+
try {
168+
if (this.filter === 'due') {
169+
await this.$store.dispatch('loadDueDashboard')
170+
}
171+
172+
if (this.filter === 'assigned') {
173+
await this.$store.dispatch('loadAssignDashboard')
174+
}
175+
} catch (e) {
176+
console.error(e)
177+
}
178+
this.loading = false
179+
},
180+
181+
145182
groupByDue(dataset) {
146183
const all = {
147184
nodue: [],
@@ -156,20 +193,23 @@ export default {
156193
if (card.duedate === null) {
157194
all.nodue.push(card)
158195
} else {
159-
const days = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24)
160-
if (days < 0) {
196+
const hours = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 )
197+
let d = new Date()
198+
let currentHour = d.getHours()
199+
console.log(card.title +' '+ hours )
200+
if (hours < 0) {
161201
all.overdue.push(card)
162202
}
163-
if (days === 0) {
203+
if (hours >= 0 && hours < (24 - currentHour)) {
164204
all.today.push(card)
165205
}
166-
if (days === 1) {
206+
if (hours >= (24 - currentHour) && hours < (48 - currentHour)) {
167207
all.tomorrow.push(card)
168208
}
169-
if (days > 1 && days < 8) {
209+
if (hours >= (48 - currentHour) && hours < (24 * 7)) {
170210
all.thisWeek.push(card)
171211
}
172-
if (days > 8) {
212+
if (hours >= (24 * 7)) {
173213
all.later.push(card)
174214
}
175215
}

src/services/CardApi.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,4 @@ export class CardApi {
194194
return Promise.reject(err)
195195
})
196196
}
197-
198-
findAllWithDue(data) {
199-
return axios.get(this.url(`/dashboard/due`))
200-
.then(
201-
(response) => Promise.resolve(response.data),
202-
(err) => Promise.reject(err)
203-
)
204-
.catch((err) => Promise.reject(err)
205-
)
206-
}
207-
208-
findMyAssignedCards(data) {
209-
return axios.get(this.url(`/dashboard/assigned`))
210-
.then(
211-
(response) => Promise.resolve(response.data),
212-
(err) => Promise.reject(err)
213-
)
214-
.catch((err) => Promise.reject(err)
215-
)
216-
}
217-
218197
}

src/store/dashboard.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ export default {
3232
assignedCards: [],
3333
},
3434
getters: {
35+
dueOverdue: state => {
36+
return state.withDue.filter((card) => {
37+
return card
38+
})
39+
40+
},
3541
withDueDashboard: state => {
3642
return state.withDue
3743
},
@@ -49,15 +55,16 @@ export default {
4955

5056
},
5157
actions: {
52-
async loadDashboards({ commit }) {
58+
async loadDueDashboard({ commit }) {
5359
const withDue = await apiClient.findAllWithDue()
5460
const withDueFlat = withDue.flat()
5561
commit('setWithDueDashboard', withDueFlat)
62+
},
5663

64+
async loadAssignDashboard({ commit }) {
5765
const assignedCards = await apiClient.findMyAssignedCards()
5866
const assignedCardsFlat = assignedCards.flat()
5967
commit('setAssignedCards', assignedCardsFlat)
60-
6168
},
6269
},
6370
}

0 commit comments

Comments
 (0)