Website Summary Files Commits Branches @commit @diff @stats
path: root / src / app / components / post-attachment / post-attachment.component.ts
diff options
context:
space:
mode:
Commitbcd88af53b1a920d728ec98b45daa9ac2e2c0917 (patch)
Author
 transtrike <transtrike@gmail.com>
2021-02-12 19:04:53 +0200
Committer
 transtrike <transtrike@gmail.com>
2021-02-12 19:04:53 +0200
Filesfd27eef086822b0f02f74364cac0b940956d2458 /src/app/components/post-attachment/post-attachment.component.ts
DevHive-Angular-bcd88af53b1a920d728ec98b45daa9ac2e2c0917.tar
DevHive-Angular-bcd88af53b1a920d728ec98b45daa9ac2e2c0917.tar.gz
DevHive-Angular-bcd88af53b1a920d728ec98b45daa9ac2e2c0917.zip
Parent1d1f05e3f74d70a558b4847a9107afa7952131cf (diff)
Moved from DevHive
1 files changed, 27 insertions, 0 deletions
-rw-r--r--src/app/components/post-attachment/post-attachment.component.ts27
diff --git a/src/app/components/post-attachment/post-attachment.component.ts b/src/app/components/post-attachment/post-attachment.component.ts
new file mode 100644
index 0000000..1d00def
--- /dev/null
+++ b/src/app/components/post-attachment/post-attachment.component.ts
@@ -0,0 +1,27 @@
+import { Component, Input, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-post-attachment',
+ templateUrl: './post-attachment.component.html',
+ styleUrls: ['./post-attachment.component.css']
+})
+export class PostAttachmentComponent implements OnInit {
+ @Input() paramURL: string;
+ public isImage = false;
+ public showFull = false;
+ public fileName: string;
+ public fileType: string;
+
+ constructor()
+ { }
+
+ ngOnInit(): void {
+ this.isImage = this.paramURL.includes('image') && !this.paramURL.endsWith('pdf');
+ this.fileType = this.isImage ? 'img' : 'raw';
+ this.fileName = this.paramURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment';
+ }
+
+ toggleShowFull(): void {
+ this.showFull = !this.showFull;
+ }
+}