From ab63ab8d0099bae3b454886abc4ef4150d84d4e9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 2 Feb 2021 20:14:57 +0200 Subject: Proper file names are now shown in posts and post edit page --- .../src/app/components/post-attachment/post-attachment.component.html | 2 +- .../src/app/components/post-attachment/post-attachment.component.ts | 2 ++ .../src/app/components/post-page/post-page.component.ts | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html index e7889f0..a8ebce7 100644 --- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html +++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html @@ -1,7 +1,7 @@
- Attachment + {{ fileName }}
{{ fileType }} diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts index d2aa636..6c468b0 100644 --- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts +++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts @@ -8,6 +8,7 @@ import { Component, Input, OnInit } from '@angular/core'; export class PostAttachmentComponent implements OnInit { @Input() paramURL: string; public showFull = false; + public fileName: string; public fileType: string; constructor() @@ -15,6 +16,7 @@ export class PostAttachmentComponent implements OnInit { ngOnInit(): void { this.fileType = this.paramURL.includes('image') ? 'img' : 'raw'; + this.fileName = this.paramURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment'; } toggleShowFull(): void { diff --git a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts index 21a5e50..39365d7 100644 --- a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts +++ b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts @@ -66,6 +66,10 @@ export class PostPageComponent implements OnInit { this._cloudinaryService.getFileRequest(fileURL).subscribe( (result: object) => { const file = result as File; + const tmp = { + name: fileURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment' + }; + Object.assign(file, tmp); this.files.push(file); } ); -- cgit v1.2.3