Skip to content
Prev Previous commit
Next Next commit
times
Signed-off-by: Jakob Röhrl <[email protected]>
  • Loading branch information
jakobroehrl authored and juliusknorr committed Aug 20, 2020
commit 66f6a3e1935d2127530d17aa34cda8a2f904a676
4 changes: 1 addition & 3 deletions lib/Controller/CardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use OCA\Deck\Service\AssignmentService;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\DashboardService;
use OCP\IRequest;
use OCP\AppFramework\Controller;

Expand All @@ -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;
}

Expand Down
7 changes: 0 additions & 7 deletions src/components/cards/CardMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ export default {
name: 'CardMenu',
components: { Actions, ActionButton, Modal, Multiselect },
props: {
/* id: {
type: Number,
default: null,
}, */
card: {
type: Object,
default: null,
Expand All @@ -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
Expand Down
166 changes: 103 additions & 63 deletions src/components/dashboards/Dashboards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,83 +24,92 @@
<div>
<Controls :dashboard-name="filter" />

<div v-if="filter=='due'" class="dashboard">
<div class="dashboard-column">
<h2>overdue</h2>
<div v-for="card in withDueDashboardGroup.overdue" :key="card.id">
<CardItem :item="card" />
<div v-if="loading" key="loading" class="emptycontent">
<div class="icon icon-loading" />
<h2>{{ t('deck', 'Loading Dashboard') }}</h2>
<p />
</div>

<div v-else>

<div v-if="filter=='due'" class="dashboard">
<div class="dashboard-column">
<h2>{{ t('deck', 'overdue') }}</h2>
<div v-for="card in dueOverdue" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>today</h2>
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'today') }}</h2>
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>tomorrow</h2>
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'tomorrow') }}</h2>
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>this week</h2>
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'this week') }}</h2>
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>later</h2>
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'later') }}</h2>
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>
</div>

<div v-if="filter=='assigned'" class="dashboard">
<div class="dashboard-column">
<h2>no due</h2>
<div v-for="card in withDueDashboardGroup.noDue" :key="card.id">
<CardItem :item="card" />
<div v-if="filter=='assigned'" class="dashboard">
<div class="dashboard-column">
<h2>{{ t('deck', 'no due') }}</h2>
<div v-for="card in assignedCardsDashboardGroup.nodue" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>overdue</h2>
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'overdue') }}</h2>
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>today</h2>
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'today') }}</h2>
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>tomorrow</h2>
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'tomorrow') }}</h2>
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>this week</h2>
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'this week') }}</h2>
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>

<div class="dashboard-column">
<h2>this week</h2>
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
<CardItem :item="card" />
<div class="dashboard-column">
<h2>{{ t('deck', 'later') }}</h2>
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
<CardItem :item="card" />
</div>
</div>
</div>
</div>
Expand All @@ -126,10 +135,16 @@ export default {
default: '',
},
},
data: function() {
return {
loading: true,
}
},
computed: {
...mapGetters([
'withDueDashboard',
'assignedCardsDashboard',
'dueOverdue'
]),
withDueDashboardGroup() {
return this.groupByDue(this.withDueDashboard)
Expand All @@ -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: [],
Expand All @@ -156,20 +193,23 @@ export default {
if (card.duedate === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in getters in the dashboard store

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)
}
}
Expand Down
21 changes: 0 additions & 21 deletions src/services/CardApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}

}
11 changes: 9 additions & 2 deletions src/store/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export default {
assignedCards: [],
},
getters: {
dueOverdue: state => {
return state.withDue.filter((card) => {
return card
})

},
withDueDashboard: state => {
return state.withDue
},
Expand All @@ -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)

},
},
}