aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/post-attachment/post-attachment.component.ts
blob: 1d00def63f88564fd22b3da964c02fd2bc340f94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
  }
}