Merge pull request #2115 from nextcloud/enh/dashboard
This commit is contained in:
@@ -136,7 +136,6 @@ return [
|
|||||||
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
||||||
|
|
||||||
// dashboard
|
// dashboard
|
||||||
['name' => 'overview_api#findAllWithDue', 'url' => '/api/v1.0/overview/due', 'verb' => 'GET'],
|
['name' => 'overview_api#upcomingCards', 'url' => '/api/v1.0/overview/upcoming', 'verb' => 'GET'],
|
||||||
['name' => 'overview_api#findAssignedCards', 'url' => '/api/v1.0/overview/assigned', 'verb' => 'GET'],
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use OCA\Deck\Activity\CommentEventHandler;
|
|||||||
use OCA\Deck\Capabilities;
|
use OCA\Deck\Capabilities;
|
||||||
use OCA\Deck\Collaboration\Resources\ResourceProvider;
|
use OCA\Deck\Collaboration\Resources\ResourceProvider;
|
||||||
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
|
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
|
||||||
|
use OCA\Deck\Dashboard\DeckWidget;
|
||||||
use OCA\Deck\Db\Acl;
|
use OCA\Deck\Db\Acl;
|
||||||
use OCA\Deck\Db\AclMapper;
|
use OCA\Deck\Db\AclMapper;
|
||||||
use OCA\Deck\Db\AssignedUsersMapper;
|
use OCA\Deck\Db\AssignedUsersMapper;
|
||||||
@@ -43,6 +44,7 @@ use OCP\AppFramework\App;
|
|||||||
use OCP\Collaboration\Resources\IManager;
|
use OCP\Collaboration\Resources\IManager;
|
||||||
use OCP\Collaboration\Resources\IProviderManager;
|
use OCP\Collaboration\Resources\IProviderManager;
|
||||||
use OCP\Comments\CommentsEntityEvent;
|
use OCP\Comments\CommentsEntityEvent;
|
||||||
|
use OCP\Dashboard\RegisterWidgetEvent;
|
||||||
use OCP\EventDispatcher\Event;
|
use OCP\EventDispatcher\Event;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\FullTextSearch\IFullTextSearchManager;
|
use OCP\FullTextSearch\IFullTextSearchManager;
|
||||||
@@ -85,6 +87,15 @@ class Application extends App {
|
|||||||
$container->registerService('database4ByteSupport', static function () use ($server) {
|
$container->registerService('database4ByteSupport', static function () use ($server) {
|
||||||
return $server->getDatabaseConnection()->supports4ByteText();
|
return $server->getDatabaseConnection()->supports4ByteText();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$version = OC_Util::getVersion()[0];
|
||||||
|
if ($version >= 20) {
|
||||||
|
/** @var IEventDispatcher $dispatcher */
|
||||||
|
$dispatcher = $container->getServer()->query(IEventDispatcher::class);
|
||||||
|
$dispatcher->addListener(RegisterWidgetEvent::class, function (RegisterWidgetEvent $event) use ($container) {
|
||||||
|
$event->registerWidget(DeckWidget::class);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(): void {
|
public function register(): void {
|
||||||
|
|||||||
@@ -48,14 +48,7 @@ class OverviewApiController extends OCSController {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function findAllWithDue(): DataResponse {
|
public function upcomingCards(): DataResponse {
|
||||||
return new DataResponse($this->dashboardService->findAllWithDue($this->userId));
|
return new DataResponse($this->dashboardService->findUpcomingCards($this->userId));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
*/
|
|
||||||
public function findAssignedCards(): DataResponse {
|
|
||||||
return new DataResponse($this->dashboardService->findAssignedCards($this->userId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
84
lib/Dashboard/DeckWidget.php
Normal file
84
lib/Dashboard/DeckWidget.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @author Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Deck\Dashboard;
|
||||||
|
|
||||||
|
use OCP\Dashboard\IWidget;
|
||||||
|
use OCP\IL10N;
|
||||||
|
|
||||||
|
class DeckWidget implements IWidget {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IL10N
|
||||||
|
*/
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
|
public function __construct(IL10N $l10n) {
|
||||||
|
$this->l10n = $l10n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getId(): string {
|
||||||
|
return 'deck';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string {
|
||||||
|
return $this->l10n->t('Upcoming cards');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getOrder(): int {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getIconClass(): string {
|
||||||
|
return 'icon-deck';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getUrl(): ?string {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function load(): void {
|
||||||
|
\OCP\Util::addScript('deck', 'dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,23 +107,34 @@ class OverviewService {
|
|||||||
return $allDueCards;
|
return $allDueCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAssignedCards(string $userId): array {
|
public function findUpcomingCards(string $userId): array {
|
||||||
$userBoards = $this->findAllBoardsFromUser($userId);
|
$userBoards = $this->findAllBoardsFromUser($userId);
|
||||||
$allAssignedCards = [];
|
$findCards = [];
|
||||||
foreach ($userBoards as $userBoard) {
|
foreach ($userBoards as $userBoard) {
|
||||||
$service = $this;
|
$service = $this;
|
||||||
$allAssignedCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
|
|
||||||
$service->enrich($card, $userId);
|
if (count($userBoard->getAcl()) === 0) {
|
||||||
$cardData = $card->jsonSerialize();
|
// get cards with due date
|
||||||
$cardData['boardId'] = $userBoard->getId();
|
$findCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
|
||||||
return $cardData;
|
$service->enrich($card, $userId);
|
||||||
}, $this->cardMapper->findAssignedCards($userBoard->getId(), $userId));
|
$cardData = $card->jsonSerialize();
|
||||||
|
$cardData['boardId'] = $userBoard->getId();
|
||||||
|
return $cardData;
|
||||||
|
}, $this->cardMapper->findAllWithDue($userBoard->getId()));
|
||||||
|
} else {
|
||||||
|
// get assigned cards
|
||||||
|
$findCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
|
||||||
|
$service->enrich($card, $userId);
|
||||||
|
$cardData = $card->jsonSerialize();
|
||||||
|
$cardData['boardId'] = $userBoard->getId();
|
||||||
|
return $cardData;
|
||||||
|
}, $this->cardMapper->findAssignedCards($userBoard->getId(), $userId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $allAssignedCards;
|
return $findCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This is duplicate code with the board service
|
// FIXME: This is duplicate code with the board service
|
||||||
|
|
||||||
private function findAllBoardsFromUser(string $userId): array {
|
private function findAllBoardsFromUser(string $userId): array {
|
||||||
$userInfo = $this->getBoardPrerequisites($userId);
|
$userInfo = $this->getBoardPrerequisites($userId);
|
||||||
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null);
|
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null);
|
||||||
|
|||||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -3851,6 +3851,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@nextcloud/vue-dashboard": {
|
||||||
|
"version": "0.1.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@nextcloud/vue-dashboard/-/vue-dashboard-0.1.8.tgz",
|
||||||
|
"integrity": "sha512-OGr1oK/WF9+bYHK8dE8Vjwh3IDNamN+9MSti1VO7zuUSm5A9EGCzAghR7zzCG4O43rAJEDcvnQwsYIiA6g4Yrw==",
|
||||||
|
"requires": {
|
||||||
|
"@nextcloud/vue": "^2.3.0",
|
||||||
|
"core-js": "^3.6.4",
|
||||||
|
"vue": "^2.6.11"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"core-js": {
|
||||||
|
"version": "3.6.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz",
|
||||||
|
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"@nextcloud/webpack-vue-config": {
|
"@nextcloud/webpack-vue-config": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@nextcloud/webpack-vue-config/-/webpack-vue-config-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@nextcloud/webpack-vue-config/-/webpack-vue-config-1.1.0.tgz",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"@nextcloud/moment": "^1.1.1",
|
"@nextcloud/moment": "^1.1.1",
|
||||||
"@nextcloud/router": "^1.1.0",
|
"@nextcloud/router": "^1.1.0",
|
||||||
"@nextcloud/vue": "^2.6.0",
|
"@nextcloud/vue": "^2.6.0",
|
||||||
|
"@nextcloud/vue-dashboard": "^0.1.8",
|
||||||
"blueimp-md5": "^2.17.0",
|
"blueimp-md5": "^2.17.0",
|
||||||
"dompurify": "^2.0.12",
|
"dompurify": "^2.0.12",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
|
|||||||
@@ -68,7 +68,13 @@
|
|||||||
import { Modal } from '@nextcloud/vue'
|
import { Modal } from '@nextcloud/vue'
|
||||||
import attachmentUpload from '../mixins/attachmentUpload'
|
import attachmentUpload from '../mixins/attachmentUpload'
|
||||||
import { loadState } from '@nextcloud/initial-state'
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
const maxUploadSizeState = loadState('deck', 'maxUploadSize')
|
|
||||||
|
let maxUploadSizeState
|
||||||
|
try {
|
||||||
|
maxUploadSizeState = loadState('deck', 'maxUploadSize')
|
||||||
|
} catch (e) {
|
||||||
|
maxUploadSizeState = -1
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AttachmentDragAndDrop',
|
name: 'AttachmentDragAndDrop',
|
||||||
|
|||||||
@@ -47,17 +47,11 @@
|
|||||||
<input type="button" class="icon-confirm" @click="finishedEdit(card)">
|
<input type="button" class="icon-confirm" @click="finishedEdit(card)">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div v-if="!editing" class="duedate right">
|
<DueDate v-if="!editing" :card="card" />
|
||||||
<transition name="zoom">
|
|
||||||
<div v-if="card.duedate" :class="dueIcon">
|
|
||||||
<span>{{ relativeDate }}</span>
|
|
||||||
</div>
|
|
||||||
</transition>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CardMenu v-if="!editing && compactMode" :card="card" class="right" />
|
<CardMenu v-if="!editing && compactMode" :card="card" class="right" />
|
||||||
</div>
|
</div>
|
||||||
<transition-group v-if="card.labels.length"
|
<transition-group v-if="card.labels && card.labels.length"
|
||||||
name="zoom"
|
name="zoom"
|
||||||
tag="ul"
|
tag="ul"
|
||||||
class="labels"
|
class="labels"
|
||||||
@@ -76,16 +70,16 @@
|
|||||||
<script>
|
<script>
|
||||||
import ClickOutside from 'vue-click-outside'
|
import ClickOutside from 'vue-click-outside'
|
||||||
import { mapState, mapGetters } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
import moment from 'moment'
|
|
||||||
import CardBadges from './CardBadges'
|
import CardBadges from './CardBadges'
|
||||||
import Color from '../../mixins/color'
|
import Color from '../../mixins/color'
|
||||||
import labelStyle from '../../mixins/labelStyle'
|
import labelStyle from '../../mixins/labelStyle'
|
||||||
import AttachmentDragAndDrop from '../AttachmentDragAndDrop'
|
import AttachmentDragAndDrop from '../AttachmentDragAndDrop'
|
||||||
import CardMenu from './CardMenu'
|
import CardMenu from './CardMenu'
|
||||||
|
import DueDate from './badges/DueDate'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CardItem',
|
name: 'CardItem',
|
||||||
components: { CardBadges, AttachmentDragAndDrop, CardMenu },
|
components: { CardBadges, AttachmentDragAndDrop, CardMenu, DueDate },
|
||||||
directives: {
|
directives: {
|
||||||
ClickOutside,
|
ClickOutside,
|
||||||
},
|
},
|
||||||
@@ -128,29 +122,7 @@ export default {
|
|||||||
currentCard() {
|
currentCard() {
|
||||||
return this.card && this.$route && this.$route.params.cardId === this.card.id
|
return this.card && this.$route && this.$route.params.cardId === this.card.id
|
||||||
},
|
},
|
||||||
relativeDate() {
|
|
||||||
const diff = moment(this.$root.time).diff(this.card.duedate, 'seconds')
|
|
||||||
if (diff >= 0 && diff < 45) {
|
|
||||||
return t('core', 'seconds ago')
|
|
||||||
}
|
|
||||||
return moment(this.card.duedate).fromNow()
|
|
||||||
},
|
|
||||||
dueIcon() {
|
|
||||||
const days = Math.floor(moment(this.card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24)
|
|
||||||
if (days < 0) {
|
|
||||||
return 'icon-calendar due icon overdue'
|
|
||||||
}
|
|
||||||
if (days === 0) {
|
|
||||||
return 'icon-calendar-dark due icon now'
|
|
||||||
}
|
|
||||||
if (days === 1) {
|
|
||||||
return 'icon-calendar-dark due icon next'
|
|
||||||
}
|
|
||||||
return 'icon-calendar-dark due icon'
|
|
||||||
},
|
|
||||||
dueDateTooltip() {
|
|
||||||
return moment(this.card.duedate).format('LLLL')
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openCard() {
|
openCard() {
|
||||||
@@ -178,10 +150,6 @@ export default {
|
|||||||
@import './../../css/animations';
|
@import './../../css/animations';
|
||||||
@import './../../css/variables';
|
@import './../../css/variables';
|
||||||
|
|
||||||
body.dark .card {
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:hover {
|
.card:hover {
|
||||||
box-shadow: 0 0 5px 1px var(--color-box-shadow);
|
box-shadow: 0 0 5px 1px var(--color-box-shadow);
|
||||||
}
|
}
|
||||||
@@ -226,42 +194,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.labels {
|
@import './../../css/labels';
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
min-width: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
margin-left: $card-padding;
|
|
||||||
margin-right: $card-padding;
|
|
||||||
margin-top: -5px;
|
|
||||||
|
|
||||||
li {
|
|
||||||
flex-grow: 0;
|
|
||||||
flex-shrink: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 0px 5px;
|
|
||||||
border-radius: 15px;
|
|
||||||
font-size: 85%;
|
|
||||||
margin-right: 3px;
|
|
||||||
margin-bottom: 3px;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
overflow: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
flex-grow: 0;
|
|
||||||
flex-shrink: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-controls {
|
.card-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -282,49 +215,6 @@ export default {
|
|||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon.due {
|
|
||||||
background-position: 4px center;
|
|
||||||
border-radius: 3px;
|
|
||||||
margin-top: 9px;
|
|
||||||
margin-bottom: 9px;
|
|
||||||
padding: 3px 4px;
|
|
||||||
padding-right: 0;
|
|
||||||
font-size: 90%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
opacity: .5;
|
|
||||||
flex-shrink: 1;
|
|
||||||
z-index: 2;
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
background-size: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.overdue {
|
|
||||||
background-color: var(--color-error);
|
|
||||||
color: var(--color-primary-text);
|
|
||||||
opacity: .7;
|
|
||||||
padding: 3px 4px;
|
|
||||||
}
|
|
||||||
&.now {
|
|
||||||
background-color: var(--color-warning);
|
|
||||||
opacity: .7;
|
|
||||||
padding: 3px 4px;
|
|
||||||
}
|
|
||||||
&.next {
|
|
||||||
background-color: var(--color-background-dark);
|
|
||||||
opacity: .7;
|
|
||||||
padding: 3px 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
margin-left: 20px;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.compact {
|
.compact {
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
|
|
||||||
|
|||||||
115
src/components/cards/badges/DueDate.vue
Normal file
115
src/components/cards/badges/DueDate.vue
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<!--
|
||||||
|
- @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
|
||||||
|
-
|
||||||
|
- @author Julius Härtl <jus@bitgrid.net>
|
||||||
|
-
|
||||||
|
- @license GNU AGPL version 3 or any later version
|
||||||
|
-
|
||||||
|
- This program is free software: you can redistribute it and/or modify
|
||||||
|
- it under the terms of the GNU Affero General Public License as
|
||||||
|
- published by the Free Software Foundation, either version 3 of the
|
||||||
|
- License, or (at your option) any later version.
|
||||||
|
-
|
||||||
|
- This program is distributed in the hope that it will be useful,
|
||||||
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
- GNU Affero General Public License for more details.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the GNU Affero General Public License
|
||||||
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="card" class="duedate">
|
||||||
|
<transition name="zoom">
|
||||||
|
<div v-if="card.duedate" :class="dueIcon">
|
||||||
|
<span>{{ relativeDate }}</span>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from '@nextcloud/moment'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DueDate',
|
||||||
|
props: {
|
||||||
|
card: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
dueIcon() {
|
||||||
|
const days = Math.floor(moment(this.card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24)
|
||||||
|
if (days < 0) {
|
||||||
|
return 'icon-calendar due icon overdue'
|
||||||
|
}
|
||||||
|
if (days === 0) {
|
||||||
|
return 'icon-calendar-dark due icon now'
|
||||||
|
}
|
||||||
|
if (days === 1) {
|
||||||
|
return 'icon-calendar-dark due icon next'
|
||||||
|
}
|
||||||
|
return 'icon-calendar-dark due icon'
|
||||||
|
},
|
||||||
|
relativeDate() {
|
||||||
|
const diff = moment(this.$root.time).diff(this.card.duedate, 'seconds')
|
||||||
|
if (diff >= 0 && diff < 45) {
|
||||||
|
return t('core', 'seconds ago')
|
||||||
|
}
|
||||||
|
return moment(this.card.duedate).fromNow()
|
||||||
|
},
|
||||||
|
dueDateTooltip() {
|
||||||
|
return moment(this.card.duedate).format('LLLL')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" coped>
|
||||||
|
.icon.due {
|
||||||
|
background-position: 4px center;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin-top: 9px;
|
||||||
|
margin-bottom: 9px;
|
||||||
|
padding: 3px 4px;
|
||||||
|
padding-right: 0;
|
||||||
|
font-size: 90%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
opacity: .5;
|
||||||
|
flex-shrink: 1;
|
||||||
|
z-index: 2;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
background-size: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.overdue {
|
||||||
|
background-color: var(--color-error);
|
||||||
|
color: var(--color-primary-text);
|
||||||
|
opacity: .7;
|
||||||
|
padding: 3px 4px;
|
||||||
|
}
|
||||||
|
&.now {
|
||||||
|
background-color: var(--color-warning);
|
||||||
|
opacity: .7;
|
||||||
|
padding: 3px 4px;
|
||||||
|
}
|
||||||
|
&.next {
|
||||||
|
background-color: var(--color-background-dark);
|
||||||
|
opacity: .7;
|
||||||
|
padding: 3px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin-left: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
<AppNavigationVue :class="{'icon-loading': loading}">
|
<AppNavigationVue :class="{'icon-loading': loading}">
|
||||||
<template #list>
|
<template #list>
|
||||||
<AppNavigationItem
|
<AppNavigationItem
|
||||||
:title="t('deck', 'My assigned cards')"
|
:title="t('deck', 'Upcoming cards')"
|
||||||
icon="icon-group"
|
icon="icon-desktop"
|
||||||
to="/overview/assigned" />
|
to="/" />
|
||||||
<AppNavigationBoardCategory
|
<AppNavigationBoardCategory
|
||||||
id="deck-navigation-all"
|
id="deck-navigation-all"
|
||||||
to="/board"
|
to="/board"
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="overview-wrapper">
|
||||||
<Controls :dashboard-name="filterDisplayName" />
|
<Controls :overview-name="filterDisplayName" />
|
||||||
|
|
||||||
<div v-if="loading" key="loading" class="emptycontent">
|
<div v-if="loading" key="loading" class="emptycontent">
|
||||||
<div class="icon icon-loading" />
|
<div class="icon icon-loading" />
|
||||||
@@ -30,48 +30,46 @@
|
|||||||
<p />
|
<p />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else-if="isValidFilter" class="overview">
|
||||||
<div v-if="isValidFilter" class="dashboard">
|
<div v-if="cardsByDueDate.overdue.length > 0" class="dashboard-column">
|
||||||
<div class="dashboard-column">
|
<h3>{{ t('deck', 'Overdue') }}</h3>
|
||||||
<h2>{{ t('deck', 'No due') }}</h2>
|
<div v-for="card in cardsByDueDate.overdue" :key="card.id">
|
||||||
<div v-for="card in cardsByDueDate.nodue" :key="card.id">
|
<CardItem :id="card.id" />
|
||||||
<CardItem :id="card.id" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>{{ t('deck', 'Overdue') }}</h2>
|
<h3>{{ t('deck', 'Today') }}</h3>
|
||||||
<div v-for="card in cardsByDueDate.overdue" :key="card.id">
|
<div v-for="card in cardsByDueDate.today" :key="card.id">
|
||||||
<CardItem :id="card.id" />
|
<CardItem :id="card.id" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>{{ t('deck', 'Today') }}</h2>
|
<h3>{{ t('deck', 'Tomorrow') }}</h3>
|
||||||
<div v-for="card in cardsByDueDate.today" :key="card.id">
|
<div v-for="card in cardsByDueDate.tomorrow" :key="card.id">
|
||||||
<CardItem :id="card.id" />
|
<CardItem :id="card.id" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>{{ t('deck', 'Tomorrow') }}</h2>
|
<h3>{{ t('deck', 'This week') }}</h3>
|
||||||
<div v-for="card in cardsByDueDate.tomorrow" :key="card.id">
|
<div v-for="card in cardsByDueDate.thisWeek" :key="card.id">
|
||||||
<CardItem :id="card.id" />
|
<CardItem :id="card.id" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>{{ t('deck', 'This week') }}</h2>
|
<h3>{{ t('deck', 'Later') }}</h3>
|
||||||
<div v-for="card in cardsByDueDate.thisWeek" :key="card.id">
|
<div v-for="card in cardsByDueDate.later" :key="card.id">
|
||||||
<CardItem :id="card.id" />
|
<CardItem :id="card.id" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>{{ t('deck', 'Later') }}</h2>
|
<h3>{{ t('deck', 'No due') }}</h3>
|
||||||
<div v-for="card in cardsByDueDate.later" :key="card.id">
|
<div v-for="card in cardsByDueDate.nodue" :key="card.id">
|
||||||
<CardItem :id="card.id" />
|
<CardItem :id="card.id" />
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,12 +83,10 @@ import CardItem from '../cards/CardItem'
|
|||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import moment from '@nextcloud/moment'
|
import moment from '@nextcloud/moment'
|
||||||
|
|
||||||
const FILTER_DUE = 'due'
|
const FILTER_UPCOMING = 'upcoming'
|
||||||
const FILTER_ASSIGNED = 'assigned'
|
|
||||||
|
|
||||||
const SUPPORTED_FILTERS = [
|
const SUPPORTED_FILTERS = [
|
||||||
FILTER_ASSIGNED,
|
FILTER_UPCOMING,
|
||||||
FILTER_DUE,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -102,7 +98,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
filter: {
|
filter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: FILTER_UPCOMING,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -116,25 +112,21 @@ export default {
|
|||||||
},
|
},
|
||||||
filterDisplayName() {
|
filterDisplayName() {
|
||||||
switch (this.filter) {
|
switch (this.filter) {
|
||||||
case 'assigned':
|
case FILTER_UPCOMING:
|
||||||
return t('deck', 'My assigned cards')
|
return t('deck', 'Upcoming cards')
|
||||||
default:
|
default:
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'withDueDashboard',
|
|
||||||
'assignedCardsDashboard',
|
'assignedCardsDashboard',
|
||||||
]),
|
]),
|
||||||
cardsByDueDate() {
|
cardsByDueDate() {
|
||||||
switch (this.filter) {
|
switch (this.filter) {
|
||||||
case FILTER_ASSIGNED:
|
case FILTER_UPCOMING:
|
||||||
return this.groupByDue(this.assignedCardsDashboard)
|
return this.groupByDue(this.assignedCardsDashboard)
|
||||||
case FILTER_DUE:
|
|
||||||
return this.groupByDue(this.withDueDashboard)
|
|
||||||
default:
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -149,12 +141,8 @@ export default {
|
|||||||
async getData() {
|
async getData() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
if (this.filter === 'due') {
|
if (this.filter === FILTER_UPCOMING) {
|
||||||
await this.$store.dispatch('loadDueDashboard')
|
await this.$store.dispatch('loadUpcoming')
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filter === 'assigned') {
|
|
||||||
await this.$store.dispatch('loadAssignDashboard')
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
@@ -172,7 +160,6 @@ export default {
|
|||||||
later: [],
|
later: [],
|
||||||
}
|
}
|
||||||
dataset.forEach(card => {
|
dataset.forEach(card => {
|
||||||
|
|
||||||
if (card.duedate === null) {
|
if (card.duedate === null) {
|
||||||
all.nodue.push(card)
|
all.nodue.push(card)
|
||||||
} else {
|
} else {
|
||||||
@@ -195,10 +182,13 @@ export default {
|
|||||||
all.later.push(card)
|
all.later.push(card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
Object.keys(all).forEach((list) => {
|
||||||
|
all[list] = all[list].sort((a, b) => {
|
||||||
|
return (new Date(a.duedate)).getTime() - (new Date(b.duedate)).getTime()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
return all
|
return all
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -208,16 +198,39 @@ export default {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import './../../css/variables';
|
@import './../../css/variables';
|
||||||
|
|
||||||
.dashboard {
|
.overview-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: calc(100vh - 50px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overview {
|
||||||
|
position: relative;
|
||||||
|
height: calc(100% - 44px);
|
||||||
|
overflow-x: scroll;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
margin: $board-spacing;
|
padding-left: $board-spacing;
|
||||||
|
padding-right: $board-spacing;
|
||||||
|
|
||||||
.dashboard-column {
|
.dashboard-column {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: $stack-width;
|
min-width: $stack-width;
|
||||||
margin: $stack-spacing;
|
margin-left: $stack-spacing;
|
||||||
|
margin-right: $stack-spacing;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin: -6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 6px 13px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
|
background-color: var(--color-main-background);
|
||||||
|
border: 1px solid var(--color-main-background);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
src/css/dashboard.scss
Normal file
7
src/css/dashboard.scss
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.icon-deck {
|
||||||
|
background-image: url(./../../img/deck-dark.svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark .icon-deck {
|
||||||
|
background-image: url(./../../img/deck.svg);
|
||||||
|
}
|
||||||
39
src/css/labels.scss
Normal file
39
src/css/labels.scss
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
$card-spacing: 10px;
|
||||||
|
$card-padding: 10px;
|
||||||
|
|
||||||
|
.labels {
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-left: $card-padding;
|
||||||
|
margin-right: $card-padding;
|
||||||
|
margin-top: -5px;
|
||||||
|
|
||||||
|
li {
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0px 5px;
|
||||||
|
border-radius: 15px;
|
||||||
|
font-size: 85%;
|
||||||
|
margin-right: 3px;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
overflow: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
$card-spacing: 10px;
|
$card-spacing: 16px;
|
||||||
$card-padding: 10px;
|
$card-padding: 8px;
|
||||||
$stack-spacing: 10px;
|
$stack-spacing: 12px;
|
||||||
$stack-width: 260px;
|
$stack-width: 260px;
|
||||||
$board-spacing: 15px;
|
$board-spacing: 16px;
|
||||||
|
|||||||
61
src/init-dashboard.js
Normal file
61
src/init-dashboard.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @author Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Vue from 'vue'
|
||||||
|
import Vuex from 'vuex'
|
||||||
|
|
||||||
|
import overview from './store/overview'
|
||||||
|
|
||||||
|
import './css/dashboard.scss'
|
||||||
|
|
||||||
|
import Dashboard from './views/Dashboard.vue'
|
||||||
|
|
||||||
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
const debug = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
|
const store = new Vuex.Store({
|
||||||
|
modules: {
|
||||||
|
overview,
|
||||||
|
},
|
||||||
|
strict: debug,
|
||||||
|
})
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
__webpack_nonce__ = btoa(OC.requestToken);
|
||||||
|
// eslint-disable-next-line
|
||||||
|
__webpack_public_path__ = OC.linkTo('deck', 'js/');
|
||||||
|
|
||||||
|
Vue.prototype.t = t
|
||||||
|
Vue.prototype.n = n
|
||||||
|
Vue.prototype.OC = OC
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
OCA.Dashboard.register('deck', (el) => {
|
||||||
|
const View = Vue.extend(Dashboard)
|
||||||
|
const vm = new View({
|
||||||
|
propsData: {},
|
||||||
|
store,
|
||||||
|
}).$mount(el)
|
||||||
|
return vm
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -40,7 +40,7 @@ export default new Router({
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'main',
|
name: 'main',
|
||||||
component: Boards,
|
component: Overview,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/overview/:filter',
|
path: '/overview/:filter',
|
||||||
|
|||||||
@@ -29,20 +29,8 @@ export class OverviewApi {
|
|||||||
return generateOcsUrl(`apps/deck/api/v1.0`) + url
|
return generateOcsUrl(`apps/deck/api/v1.0`) + url
|
||||||
}
|
}
|
||||||
|
|
||||||
findAllWithDue(data) {
|
get(filter) {
|
||||||
return axios.get(this.url(`overview/due`), {
|
return axios.get(this.url(`overview/${filter}`), {
|
||||||
headers: { 'OCS-APIRequest': 'true' },
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
(response) => Promise.resolve(response.data.ocs.data),
|
|
||||||
(err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
.catch((err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
findMyAssignedCards(data) {
|
|
||||||
return axios.get(this.url(`overview/assigned`), {
|
|
||||||
headers: { 'OCS-APIRequest': 'true' },
|
headers: { 'OCS-APIRequest': 'true' },
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
|
|||||||
@@ -28,39 +28,22 @@ Vue.use(Vuex)
|
|||||||
const apiClient = new OverviewApi()
|
const apiClient = new OverviewApi()
|
||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
withDue: [],
|
|
||||||
assignedCards: [],
|
assignedCards: [],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
withDueDashboard: state => {
|
|
||||||
return state.withDue
|
|
||||||
},
|
|
||||||
assignedCardsDashboard: state => {
|
assignedCardsDashboard: state => {
|
||||||
return state.assignedCards
|
return state.assignedCards
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setWithDueDashboard(state, withDue) {
|
|
||||||
state.withDue = withDue
|
|
||||||
},
|
|
||||||
setAssignedCards(state, assignedCards) {
|
setAssignedCards(state, assignedCards) {
|
||||||
state.assignedCards = assignedCards
|
state.assignedCards = assignedCards
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async loadDueDashboard({ commit }) {
|
async loadUpcoming({ commit }) {
|
||||||
commit('setCurrentBoard', null)
|
commit('setCurrentBoard', null)
|
||||||
const cardsWithDueDate = await apiClient.findAllWithDue()
|
const assignedCards = await apiClient.get('upcoming')
|
||||||
const withDueFlat = cardsWithDueDate.flat()
|
|
||||||
for (const i in withDueFlat) {
|
|
||||||
commit('addCard', withDueFlat[i])
|
|
||||||
}
|
|
||||||
commit('setWithDueDashboard', withDueFlat)
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadAssignDashboard({ commit }) {
|
|
||||||
commit('setCurrentBoard', null)
|
|
||||||
const assignedCards = await apiClient.findMyAssignedCards()
|
|
||||||
const assignedCardsFlat = assignedCards.flat()
|
const assignedCardsFlat = assignedCards.flat()
|
||||||
for (const i in assignedCardsFlat) {
|
for (const i in assignedCardsFlat) {
|
||||||
commit('addCard', assignedCardsFlat[i])
|
commit('addCard', assignedCardsFlat[i])
|
||||||
|
|||||||
150
src/views/Dashboard.vue
Normal file
150
src/views/Dashboard.vue
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
<!--
|
||||||
|
- @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
|
||||||
|
-
|
||||||
|
- @author Julius Härtl <jus@bitgrid.net>
|
||||||
|
-
|
||||||
|
- @license GNU AGPL version 3 or any later version
|
||||||
|
-
|
||||||
|
- This program is free software: you can redistribute it and/or modify
|
||||||
|
- it under the terms of the GNU Affero General Public License as
|
||||||
|
- published by the Free Software Foundation, either version 3 of the
|
||||||
|
- License, or (at your option) any later version.
|
||||||
|
-
|
||||||
|
- This program is distributed in the hope that it will be useful,
|
||||||
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
- GNU Affero General Public License for more details.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the GNU Affero General Public License
|
||||||
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<DashboardWidget :items="cards"
|
||||||
|
:show-more-text="t('deck', 'upcoming cards')"
|
||||||
|
:show-more-url="showMoreUrl"
|
||||||
|
:loading="loading"
|
||||||
|
@hide="() => {}"
|
||||||
|
@markDone="() => {}">
|
||||||
|
<template v-slot:default="{ item }">
|
||||||
|
<a :key="item.id"
|
||||||
|
:href="cardLink(item)"
|
||||||
|
target="_blank"
|
||||||
|
class="card">
|
||||||
|
<div class="card--header">
|
||||||
|
<DueDate class="right" :card="item" />
|
||||||
|
<span class="title">{{ item.title }}</span>
|
||||||
|
</div>
|
||||||
|
<ul v-if="item.labels && item.labels.length"
|
||||||
|
class="labels">
|
||||||
|
<li v-for="label in item.labels" :key="label.id" :style="labelStyle(label)">
|
||||||
|
<span>{{ label.title }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
<template v-slot:empty-content>
|
||||||
|
<EmptyContent
|
||||||
|
id="deck-widget-empty-content"
|
||||||
|
icon="icon-deck">
|
||||||
|
{{ t('deck', 'No upcoming cards') }}
|
||||||
|
</EmptyContent>
|
||||||
|
</template>
|
||||||
|
</DashboardWidget>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { DashboardWidget } from '@nextcloud/vue-dashboard'
|
||||||
|
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
import labelStyle from './../mixins/labelStyle'
|
||||||
|
import DueDate from '../components/cards/badges/DueDate'
|
||||||
|
import { generateUrl } from '@nextcloud/router'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Dashboard',
|
||||||
|
components: {
|
||||||
|
DueDate,
|
||||||
|
EmptyContent,
|
||||||
|
DashboardWidget,
|
||||||
|
},
|
||||||
|
mixins: [ labelStyle ],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters([
|
||||||
|
'assignedCardsDashboard',
|
||||||
|
]),
|
||||||
|
cards() {
|
||||||
|
const list = [
|
||||||
|
...this.assignedCardsDashboard,
|
||||||
|
].filter((card) => {
|
||||||
|
return card.duedate !== null
|
||||||
|
})
|
||||||
|
list.sort((a, b) => {
|
||||||
|
return (new Date(a.duedate)).getTime() - (new Date(b.duedate)).getTime()
|
||||||
|
})
|
||||||
|
return list
|
||||||
|
},
|
||||||
|
cardLink() {
|
||||||
|
return (card) => {
|
||||||
|
return generateUrl('/apps/deck') + `#/board/${card.boardId}/card/${card.id}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showMoreUrl() {
|
||||||
|
return this.cards.length > 7 ? generateUrl('/apps/deck') : null
|
||||||
|
},
|
||||||
|
},
|
||||||
|
beforeMount() {
|
||||||
|
this.loading = true
|
||||||
|
this.$store.dispatch('loadUpcoming').then(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './../css/labels';
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: block;
|
||||||
|
border-radius: var(--border-radius-large);
|
||||||
|
padding: 8px;
|
||||||
|
height: 60px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--color-background-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card--header {
|
||||||
|
overflow: hidden;
|
||||||
|
.title {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.labels {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.duedate::v-deep {
|
||||||
|
.due {
|
||||||
|
margin: 0 0 0 10px;
|
||||||
|
padding: 2px 4px;
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -6,6 +6,7 @@ const config = {
|
|||||||
entry: {
|
entry: {
|
||||||
deck: path.join(__dirname, 'src', 'main.js'),
|
deck: path.join(__dirname, 'src', 'main.js'),
|
||||||
collections: path.join(__dirname, 'src', 'init-collections.js'),
|
collections: path.join(__dirname, 'src', 'init-collections.js'),
|
||||||
|
dashboard: path.join(__dirname, 'src', 'init-dashboard.js'),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
|
|||||||
Reference in New Issue
Block a user