mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Cleanup frontend comment service & other code
[ci skip]
This commit is contained in:
		| @@ -4,11 +4,10 @@ | |||||||
|             <p class="card-text">{{comment.comment}}</p> |             <p class="card-text">{{comment.comment}}</p> | ||||||
|         </div> |         </div> | ||||||
|         <div class="d-flex card-footer small bg-light text-primary justify-content-between align-items-center"> |         <div class="d-flex card-footer small bg-light text-primary justify-content-between align-items-center"> | ||||||
|             <span>{{displayName(comment)}} - {{ comment?.created | customDate}}</span> |             <span>{{displayName(comment)}} - {{ comment.created | customDate}}</span> | ||||||
|             <btn class="btn btn-link btn-sm p-0 fade" (click)="deleteComment(comment.id)"> |             <btn class="btn btn-link btn-sm p-0 fade" (click)="deleteComment(comment.id)"> | ||||||
|                 <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"> |                 <svg width="13" height="13" fill="currentColor"> | ||||||
|                     <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/> |                     <use xlink:href="assets/bootstrap-icons.svg#trash" /> | ||||||
|                     <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/> |  | ||||||
|                 </svg> |                 </svg> | ||||||
|             </btn> |             </btn> | ||||||
|         </div> |         </div> | ||||||
|   | |||||||
| @@ -174,7 +174,6 @@ | |||||||
|                     <ng-template ngbNavContent> |                     <ng-template ngbNavContent> | ||||||
|                         <app-document-comments [documentId]="documentId"></app-document-comments> |                         <app-document-comments [documentId]="documentId"></app-document-comments> | ||||||
|                     </ng-template> |                     </ng-template> | ||||||
|  |  | ||||||
|                 </li> |                 </li> | ||||||
|             </ul> |             </ul> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -274,7 +274,6 @@ export class DocumentDetailComponent | |||||||
|           this.suggestions = null |           this.suggestions = null | ||||||
|         }, |         }, | ||||||
|       }) |       }) | ||||||
|  |  | ||||||
|     this.title = this.documentTitlePipe.transform(doc.title) |     this.title = this.documentTitlePipe.transform(doc.title) | ||||||
|     this.documentForm.patchValue(doc) |     this.documentForm.patchValue(doc) | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| import { ObjectWithId } from './object-with-id' | import { ObjectWithId } from './object-with-id' | ||||||
| import { CommentUser } from './user-type' | import { User } from './user' | ||||||
|  |  | ||||||
| export interface PaperlessDocumentComment extends ObjectWithId { | export interface PaperlessDocumentComment extends ObjectWithId { | ||||||
|   created?: Date |   created?: Date | ||||||
|   comment?: string |   comment?: string | ||||||
|     user?: CommentUser |   user?: User | ||||||
| } | } | ||||||
| @@ -1,7 +0,0 @@ | |||||||
| import { ObjectWithId } from './object-with-id' |  | ||||||
|  |  | ||||||
| export interface CommentUser extends ObjectWithId { |  | ||||||
|     username: string |  | ||||||
|     firstname: string |  | ||||||
|     lastname: string |  | ||||||
| }  |  | ||||||
							
								
								
									
										7
									
								
								src-ui/src/app/data/user.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src-ui/src/app/data/user.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | import { ObjectWithId } from './object-with-id' | ||||||
|  |  | ||||||
|  | export interface User extends ObjectWithId { | ||||||
|  |   username: string | ||||||
|  |   firstname: string | ||||||
|  |   lastname: string | ||||||
|  | } | ||||||
| @@ -21,7 +21,7 @@ export class DocumentCommentsService extends AbstractPaperlessService<PaperlessD | |||||||
|   addComment(id: number, comment): Observable<PaperlessDocumentComment[]> { |   addComment(id: number, comment): Observable<PaperlessDocumentComment[]> { | ||||||
|     return this.http.post<PaperlessDocumentComment[]>( |     return this.http.post<PaperlessDocumentComment[]>( | ||||||
|       this.getResourceUrl(id, 'comments'), |       this.getResourceUrl(id, 'comments'), | ||||||
|       { payload: comment } |       { comment: comment } | ||||||
|     ) |     ) | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -29,11 +29,9 @@ export class DocumentCommentsService extends AbstractPaperlessService<PaperlessD | |||||||
|     documentId: number, |     documentId: number, | ||||||
|     commentId: number |     commentId: number | ||||||
|   ): Observable<PaperlessDocumentComment[]> { |   ): Observable<PaperlessDocumentComment[]> { | ||||||
|     let httpParams = new HttpParams() |  | ||||||
|     httpParams = httpParams.set('commentId', commentId.toString()) |  | ||||||
|     return this.http.delete<PaperlessDocumentComment[]>( |     return this.http.delete<PaperlessDocumentComment[]>( | ||||||
|       this.getResourceUrl(documentId, 'comments'), |       this.getResourceUrl(documentId, 'comments'), | ||||||
|       { params: httpParams } |       { params: new HttpParams({ fromString: `id=${commentId}` }) } | ||||||
|     ) |     ) | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -414,7 +414,7 @@ class DocumentViewSet( | |||||||
|             try: |             try: | ||||||
|                 c = Comment.objects.create( |                 c = Comment.objects.create( | ||||||
|                     document=doc, |                     document=doc, | ||||||
|                     comment=request.data["payload"], |                     comment=request.data["comment"], | ||||||
|                     user=currentUser, |                     user=currentUser, | ||||||
|                 ) |                 ) | ||||||
|                 c.save() |                 c.save() | ||||||
| @@ -427,7 +427,7 @@ class DocumentViewSet( | |||||||
|                     }, |                     }, | ||||||
|                 ) |                 ) | ||||||
|         elif request.method == "DELETE": |         elif request.method == "DELETE": | ||||||
|             comment = Comment.objects.get(id=int(request.GET.get("commentId"))) |             comment = Comment.objects.get(id=int(request.GET.get("id"))) | ||||||
|             comment.delete() |             comment.delete() | ||||||
|             return Response(self.getComments(doc)) |             return Response(self.getComments(doc)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -566,6 +566,7 @@ CONVERT_MEMORY_LIMIT = os.getenv("PAPERLESS_CONVERT_MEMORY_LIMIT") | |||||||
|  |  | ||||||
| GS_BINARY = os.getenv("PAPERLESS_GS_BINARY", "gs") | GS_BINARY = os.getenv("PAPERLESS_GS_BINARY", "gs") | ||||||
|  |  | ||||||
|  |  | ||||||
| # Pre-2.x versions of Paperless stored your documents locally with GPG | # Pre-2.x versions of Paperless stored your documents locally with GPG | ||||||
| # encryption, but that is no longer the default.  This behaviour is still | # encryption, but that is no longer the default.  This behaviour is still | ||||||
| # available, but it must be explicitly enabled by setting | # available, but it must be explicitly enabled by setting | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon