Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-07-13 11:23:44 +02:00
committed by Julius Härtl
parent 818ffa2d57
commit 66f6a3e193
5 changed files with 121 additions and 104 deletions

View File

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

View File

@@ -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

View File

@@ -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>
</div>
<div class="dashboard-column">
<h2>today</h2>
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
</div>
</div>
<div class="dashboard-column">
<h2>tomorrow</h2>
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
<CardItem :item="card" />
</div>
</div>
<div class="dashboard-column">
<h2>this week</h2>
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
<CardItem :item="card" />
</div>
</div>
<div class="dashboard-column">
<h2>later</h2>
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
<CardItem :item="card" />
</div>
</div>
<div v-if="loading" key="loading" class="emptycontent">
<div class="icon icon-loading" />
<h2>{{ t('deck', 'Loading Dashboard') }}</h2>
<p />
</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-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 class="dashboard-column">
<h2>{{ t('deck', 'today') }}</h2>
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
<CardItem :item="card" />
</div>
</div>
<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 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 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 class="dashboard-column">
<h2>overdue</h2>
<div v-for="card in assignedCardsDashboardGroup.overdue" :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>today</h2>
<div v-for="card in assignedCardsDashboardGroup.today" :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>tomorrow</h2>
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :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>this week</h2>
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :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 withDueDashboardGroup.later" :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 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>
@@ -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)
}
}

View File

@@ -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)
)
}
}

View File

@@ -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)
},
},
}