From a109c9d0a51b37b5165a0acae82cff714d17419e Mon Sep 17 00:00:00 2001 From: Matthew Ross Date: Mon, 11 May 2020 19:10:36 -0400 Subject: [PATCH] Attachments fully working --- src/app/app.routes.ts | 1 + src/app/board/board.service.ts | 19 ++- src/app/board/column/column.component.html | 15 ++- src/app/board/column/column.component.ts | 131 +++++++++++++-------- src/app/files/file-viewer.component.html | 18 ++- src/app/files/file-viewer.component.ts | 62 ++++++++-- src/app/files/file-viewer.module.ts | 4 + src/app/files/file-viewer.service.ts | 22 ++++ 8 files changed, 203 insertions(+), 69 deletions(-) create mode 100644 src/app/files/file-viewer.service.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index d5313aa..2571004 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -35,6 +35,7 @@ export const ROUTES: Routes = [ { path: 'files/:hash', component: FileViewerComponent, + canActivate: [ AuthGuard ] } ]; diff --git a/src/app/board/board.service.ts b/src/app/board/board.service.ts index e4cdf1c..efea658 100644 --- a/src/app/board/board.service.ts +++ b/src/app/board/board.service.ts @@ -123,6 +123,14 @@ export class BoardService { ); } + addComment(comment: Comment): Observable { + return this.http.post('api/comments', comment) + .pipe( + map((response: ApiResponse) => response), + catchError((err) => of(err.error as ApiResponse)) + ); + } + updateComment(comment: Comment): Observable { return this.http.post('api/comments/' + comment.id, comment) .pipe( @@ -139,8 +147,7 @@ export class BoardService { ); } - /* istanbul ignore next */ - uploadAttachment(attachment: Attachment): Observable { + addAttachment(attachment: Attachment): Observable { return this.http.post('api/attachments', attachment) .pipe( map((response: ApiResponse) => response), @@ -148,6 +155,14 @@ export class BoardService { ); } + uploadAttachment(data: FormData, hash: string): Observable { + return this.http.post('api/upload/' + hash, data) + .pipe( + map((response: ApiResponse) => response), + catchError((err) => of(err.error as ApiResponse)) + ); + } + removeAttachment(id: number): Observable { return this.http.delete('api/attachments/' + id) .pipe( diff --git a/src/app/board/column/column.component.html b/src/app/board/column/column.component.html index 32bb287..ea00dbe 100644 --- a/src/app/board/column/column.component.html +++ b/src/app/board/column/column.component.html @@ -178,8 +178,11 @@ - + + + -
+

{{ strings['boards_taskAddAttachment'] }}

- + -