You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
import { Subject } from 'rxjs';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
import { MatSnackBar } from '@angular/material';
|
|
|
|
import { DataService } from '../../../shared/services/data.service';
|
|
import { LoggerService } from '../../../shared/services/logger.service';
|
|
|
|
@Component({
|
|
selector: 'rtl-sign',
|
|
templateUrl: './sign.component.html',
|
|
styleUrls: ['./sign.component.scss']
|
|
})
|
|
export class SignComponent implements OnInit, OnDestroy {
|
|
public message = '';
|
|
public signature = '';
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
|
|
|
|
constructor(private dataService: DataService, private snackBar: MatSnackBar, private logger: LoggerService) {}
|
|
|
|
ngOnInit() {}
|
|
|
|
onSign() {
|
|
if (!this.message || this.message === '') { return true; }
|
|
this.dataService.signMessage(this.message).pipe(takeUntil(this.unSubs[0])).subscribe(res => { this.signature = res; });
|
|
}
|
|
|
|
onCopyField(payload: string) {
|
|
this.snackBar.open('Signature copied.');
|
|
this.logger.info('Copied Text: ' + payload);
|
|
}
|
|
|
|
resetData() {
|
|
this.message = '';
|
|
this.signature = '';
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.unSubs.forEach(completeSub => {
|
|
completeSub.next();
|
|
completeSub.complete();
|
|
});
|
|
}
|
|
}
|