2020-04-14 11:28:33 +02:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
2020-05-01 19:10:17 +02:00
|
|
|
import { ClipboardService } from 'ngx-clipboard';
|
2020-04-14 11:28:33 +02:00
|
|
|
import { MessageService } from 'primeng/api';
|
2020-02-04 11:35:09 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-04-22 12:56:18 +02:00
|
|
|
selector: 'app-copy-text',
|
2020-04-21 10:50:26 +02:00
|
|
|
templateUrl: './copy-text.component.html',
|
|
|
|
styleUrls: ['./copy-text.component.scss'],
|
2020-02-04 11:35:09 +01:00
|
|
|
})
|
|
|
|
export class CopyTextComponent implements OnInit {
|
2020-05-01 19:10:17 +02:00
|
|
|
@Input() public textToCopy: string;
|
|
|
|
public displayContentToCopy = false;
|
2020-02-04 11:35:09 +01:00
|
|
|
|
2020-05-01 19:10:17 +02:00
|
|
|
constructor(private _clipboardService: ClipboardService, private messageService: MessageService) {}
|
2020-02-04 11:35:09 +01:00
|
|
|
|
2020-05-01 19:10:17 +02:00
|
|
|
ngOnInit(): void {}
|
2020-02-04 11:35:09 +01:00
|
|
|
|
2020-05-01 19:10:17 +02:00
|
|
|
public copy(): void {
|
|
|
|
this._clipboardService.copyFromContent(this.textToCopy);
|
2020-04-21 10:50:26 +02:00
|
|
|
this.messageService.add({
|
|
|
|
severity: 'success',
|
|
|
|
summary: 'Texte copié',
|
|
|
|
detail: this.textToCopy,
|
|
|
|
});
|
|
|
|
}
|
2020-02-04 11:35:09 +01:00
|
|
|
}
|