Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],

// dashboard
['name' => 'overview_api#findAllWithDue', 'url' => '/api/v1.0/overview/due', 'verb' => 'GET'],
['name' => 'overview_api#findAssignedCards', 'url' => '/api/v1.0/overview/assigned', 'verb' => 'GET'],
['name' => 'overview_api#upcomingCards', 'url' => '/api/v1.0/overview/upcoming', 'verb' => 'GET'],
]
];
11 changes: 11 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Deck\Capabilities;
use OCA\Deck\Collaboration\Resources\ResourceProvider;
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
use OCA\Deck\Dashboard\DeckWidget;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\AclMapper;
use OCA\Deck\Db\AssignedUsersMapper;
Expand All @@ -43,6 +44,7 @@
use OCP\Collaboration\Resources\IManager;
use OCP\Collaboration\Resources\IProviderManager;
use OCP\Comments\CommentsEntityEvent;
use OCP\Dashboard\RegisterWidgetEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\FullTextSearch\IFullTextSearchManager;
Expand Down Expand Up @@ -85,6 +87,15 @@ public function __construct(array $urlParams = []) {
$container->registerService('database4ByteSupport', static function () use ($server) {
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 {
Expand Down
11 changes: 2 additions & 9 deletions lib/Controller/OverviewApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@ public function __construct($appName, IRequest $request, OverviewService $dashbo
/**
* @NoAdminRequired
*/
public function findAllWithDue(): DataResponse {
return new DataResponse($this->dashboardService->findAllWithDue($this->userId));
}

/**
* @NoAdminRequired
*/
public function findAssignedCards(): DataResponse {
return new DataResponse($this->dashboardService->findAssignedCards($this->userId));
public function upcomingCards(): DataResponse {
return new DataResponse($this->dashboardService->findUpcomingCards($this->userId));
}
}
84 changes: 84 additions & 0 deletions lib/Dashboard/DeckWidget.php
Original file line number Diff line number Diff line change
@@ -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');
}
}
31 changes: 21 additions & 10 deletions lib/Service/OverviewService.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,34 @@ public function findAllWithDue(string $userId): array {
return $allDueCards;
}

public function findAssignedCards(string $userId): array {
public function findUpcomingCards(string $userId): array {
$userBoards = $this->findAllBoardsFromUser($userId);
$allAssignedCards = [];
$findCards = [];
foreach ($userBoards as $userBoard) {
$service = $this;
$allAssignedCards[] = 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));

if (count($userBoard->getAcl()) === 0) {
// get cards with due date
$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->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

private function findAllBoardsFromUser(string $userId): array {
$userInfo = $this->getBoardPrerequisites($userId);
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null);
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@nextcloud/moment": "^1.1.1",
"@nextcloud/router": "^1.1.0",
"@nextcloud/vue": "^2.6.0",
"@nextcloud/vue-dashboard": "^0.1.8",
"blueimp-md5": "^2.17.0",
"dompurify": "^2.0.12",
"lodash": "^4.17.20",
Expand Down
8 changes: 7 additions & 1 deletion src/components/AttachmentDragAndDrop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@
import { Modal } from '@nextcloud/vue'
import attachmentUpload from '../mixins/attachmentUpload'
import { loadState } from '@nextcloud/initial-state'
const maxUploadSizeState = loadState('deck', 'maxUploadSize')

let maxUploadSizeState
try {
maxUploadSizeState = loadState('deck', 'maxUploadSize')
} catch (e) {
maxUploadSizeState = -1
}

export default {
name: 'AttachmentDragAndDrop',
Expand Down
Loading