diff --git a/CHANGELOG.md b/CHANGELOG.md
index f4e6927..038c0f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 1.0.2 – 2022-05-25
+Adding multiple comments if a comment exceeds Deck 1000char limit.
+Notify user that the request is being worked on.
+Better error handling.
+Attachments added in card description rather than as a comment.
+Using Toast for progress messages.
+
## 1.0.1 – 2022-05-24
Fixed issues where title was longer than 255chars
Upgraded version support to NC23 and NC24
\ No newline at end of file
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 1f14deb..0f2d930 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,7 +5,7 @@
Deck Import From Trello
nextcloud app that allows Deck import from Trello export to JSON file
- 1.0.1
+ 1.0.2
agpl
newroco
DeckImportFromTrello
diff --git a/js/deckimportfromtrello.js b/js/deckimportfromtrello.js
index 5107101..b8504f5 100644
--- a/js/deckimportfromtrello.js
+++ b/js/deckimportfromtrello.js
@@ -20,18 +20,25 @@
function importFile($file) {
var data = {
- id: $file.attr('data-id'),
+ fileId: $file.attr('data-id'),
};
+ OCP.Toast.info('Board import started.');
$.ajax({
url: url,
type: "post",
data: data,
success: function (data) {
- //
+ if(data.boardUrl){
+ OCP.Toast.info('Board was imported successfully',{'isHTML':true});
+ }
},
error: function (jqXHR, textStatus, errorThrown) {
- alert('Something went wrong');
+ let message = '';
+ if(jqXHR.responseJSON && jqXHR.responseJSON.message){
+ message = jqXHR.responseJSON.message;
+ }
+ OCP.Toast.error('Something went wrong: ' + message);
},
});
}
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index 6abb541..94c77cc 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -5,7 +5,7 @@
use Httpful\Request;
use OCA\Deck\Service\BoardService;
use OCA\DeckImportFromTrello\Activity\FileImportEvent;
-use OCA\DeckImportFromTrello\Db\File;
+use OCA\DeckImportFromTrello\Activity\EventHandler;
use OCA\DeckImportFromTrello\Services\DeckImportFromTrelloService;
use OCA\DeckImportFromTrello\Services\UserService;
use OCP\AppFramework\Http\JSONResponse;
@@ -14,10 +14,12 @@
use OCP\IServerContainer;
use OCP\AppFramework\Controller;
use OCP\AppFramework\App;
+use OCP\Files\File;
class PageController extends Controller
{
private $userId;
+ private $eventHandler;
protected $storage;
protected $server;
/**
@@ -30,8 +32,10 @@ public function __construct(
$AppName,
IRequest $request,
IServerContainer $server,
- DeckImportFromTrelloService $deckImportFromTrelloService,
IRootFolder $storage,
+ EventHandler $eventHandler,
+ DeckImportFromTrelloService $deckImportFromTrelloService,
+
$UserId
) {
parent::__construct($AppName, $request);
@@ -39,6 +43,7 @@ public function __construct(
$this->server = $server;
$this->userId = $UserId;
$this->storage = $storage;
+ $this->eventHandler = $eventHandler;
$this->deckImportFromTrelloService = $deckImportFromTrelloService;
}
@@ -47,9 +52,9 @@ public function __construct(
* @param $id
* @return JSONResponse
*/
- public function store($id)
+ public function store($fileId)
{
- if (!$id) {
+ if (!$fileId) {
return new JSONResponse([
'message' => 'File required.',
], 403);
@@ -59,10 +64,10 @@ public function store($id)
try {
// Read file contents
- $files = $userFolder->getById((int)$id);
+ $files = $userFolder->getById((int)$fileId);
$file = $files[0];
- if ( ! $file instanceof \OCP\Files\File) {
+ if ( ! $file instanceof File) {
throw new StorageException('Can not read from folder');
}
@@ -71,11 +76,6 @@ public function store($id)
$contents = $file->getContent();
$board = $this->deckImportFromTrelloService->parseJsonAndImport($contents);
-
-// $boardUrl = ($this->server->getURLGenerator())->linkToRouteAbsolute('deck.board.read', [
-// 'boardId' => $board->getId()
-// ]);
-
$boardUrl = ($this->server->getURLGenerator())->linkToRouteAbsolute('deck.board.index');
$boardUrl = str_replace('/boards', '/#/board/' . $board->getId(), $boardUrl);
@@ -86,11 +86,11 @@ public function store($id)
UserService::getUser()
);
- $eventHandler = (new App('deckimportfromtrello'))->getContainer()->query('OCA\DeckImportFromTrello\Activity\EventHandler');
- $eventHandler->handle($fileImportedEvent);
+ $this->eventHandler->handle($fileImportedEvent);
return new JSONResponse([
'content' => 'Success',
+ 'boardUrl' => $boardUrl
]);
} catch (\Exception $exception) {
return new JSONResponse([
diff --git a/lib/Services/DeckImportFromTrelloService.php b/lib/Services/DeckImportFromTrelloService.php
index 3853826..43d439d 100644
--- a/lib/Services/DeckImportFromTrelloService.php
+++ b/lib/Services/DeckImportFromTrelloService.php
@@ -208,7 +208,7 @@ private function parseCards($cards, $checklists)
$dueDate = $card['due'];
if (count($card['idMembers'])) {
- $description .= "\n Card was assigned to ";
+ $description .= "\n\n Card was assigned to ";
foreach ($card['idMembers'] as $key => $member) {
$card['idMembers'][$key] = $this->members[$member];
@@ -216,7 +216,7 @@ private function parseCards($cards, $checklists)
$description .= implode(',',$card['idMembers']);
- $description .= "\n";
+ $description .= "\n\n";
}
if (count($card['idChecklists'])) {
@@ -233,6 +233,18 @@ private function parseCards($cards, $checklists)
}
}
+ if (count($card['attachments'])) {
+
+ $description .= "\n\nTrello Attachments: \n";
+
+ foreach ($card['attachments'] as $attachment) {
+ if (!$attachment['isUpload']) {
+ continue;
+ }
+ $description .= " - " . $attachment['name'] . " (" . $attachment['url'] . ")\n";
+ }
+ }
+
$order = $card['idShort'];
$cardId = $this->createCard($title, $newStackID, $order, $description, $dueDate);
@@ -240,7 +252,6 @@ private function parseCards($cards, $checklists)
$this->cards[$id] = $cardId;
// $this->createAttachments($card, $cardId);
- $this->addAttachmentsAsComments($card, $cardId);
}
}
@@ -373,7 +384,14 @@ private function createCard($title, $stackID, $order, $description, $duedate = n
*/
private function createComment(int $cardId, string $message, int $parentId)
{
- return $this->commentService->create($cardId, $message, $parentId);
+ while(mb_strlen($message) > 1000){
+ $subComment = mb_substr($message,0,1000);
+ $this->commentService->create($cardId, $subComment, $parentId);
+ $message = mb_substr($message,1000);
+ }
+ if(mb_strlen($message) > 0){
+ $this->commentService->create($cardId, $message, $parentId);
+ }
}
protected function addAttachmentsAsComments(array $card, int $cardId)