Broker System for Supercredit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 satır
2.9KB

  1. import {Component, ElementRef, Input, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
  2. import {ActivatedRoute, Router} from '@angular/router';
  3. import {UploadAttachService} from '../service/upload.attach.service';
  4. import {UploadAnalysisModel} from '../models/upload.analysis.model';
  5. import {UploadModel} from '../models/upload.model';
  6. import {FloatingActionButtonComponent} from '@progress/kendo-angular-buttons';
  7. import {DrawerSelectEvent} from '@progress/kendo-angular-layout';
  8. @Component({
  9. selector: 'app-upload-detail',
  10. templateUrl: './upload-detail.component.html',
  11. styleUrls: ['./upload-detail.component.scss']
  12. })
  13. export class UploadDetailComponent implements OnInit {
  14. @Input() uploadId: number;
  15. @Input() ua: UploadAnalysisModel = new UploadAnalysisModel({});
  16. @ViewChild('fab', {static: true}) fab: FloatingActionButtonComponent;
  17. @ViewChild('pdf', {static: false}) pdf: ElementRef;
  18. // 'http://africau.edu/images/default/sample.pdf';
  19. public uploadAsPicUrl = 'https://svr2021.lawipac.com:8080/api/v1/upload-as-pdf/default';
  20. public uploadAsPdfUrl = '';
  21. public initAnimation = false;
  22. public iframeLoaded = false;
  23. public scanning = false;
  24. public scandone = false;
  25. constructor(private us: UploadAttachService, private actRoute: ActivatedRoute, private router: Router) { }
  26. ngOnInit(): void {
  27. const id = this.actRoute.snapshot.params.id;
  28. if ( id !== undefined && id > 0 ) {
  29. this.uploadId = id;
  30. }
  31. this.ua.Id = this.uploadId;
  32. if ( this.uploadId > 0 ) {
  33. this.uploadAsPicUrl = this.us.getUploadAsJpgUrl(this.ua.Id);
  34. this.uploadAsPdfUrl = this.us.getUploadAsPdfUrl(this.ua.Id);
  35. }
  36. this.loadUploadMeta();
  37. // this.loadUploadAnalysis();
  38. // this.fabOffset = { y : '-1px' };
  39. this.fabSlideIn();
  40. }
  41. private loadUploadAnalysis(): void {
  42. this.us.getUploadAnalysis(this.uploadId).subscribe(
  43. resp => {
  44. this.scandone = true;
  45. this.scanning = false;
  46. this.ua = new UploadAnalysisModel(resp);
  47. this.uploadId = this.ua.Id;
  48. }
  49. );
  50. }
  51. private loadUploadMeta(): void {
  52. this.us.getUploadMeta(this.uploadId).subscribe(
  53. resp => {
  54. this.ua.Input = new UploadModel(resp);
  55. }
  56. );
  57. }
  58. private fabSlideIn(): void {
  59. setTimeout(() => {this.initAnimation = true; }, 1000);
  60. }
  61. public onClickFloatActionButton(e: any): void{
  62. this.router.navigate(['/lender-uploads']);
  63. }
  64. public finishedLoading(status: string ): void{
  65. if ( this.pdf === undefined ) {
  66. return;
  67. }
  68. const el = this.pdf.nativeElement;
  69. if ( el !== undefined && el.src === this.uploadAsPdfUrl) {
  70. console.log('yes true',this);
  71. this.iframeLoaded = true;
  72. }
  73. }
  74. public onTabSelect( select: DrawerSelectEvent): void {
  75. if ( select.index === 2 && ! this.iframeLoaded ) {
  76. select.preventDefault();
  77. return;
  78. }
  79. if ( ! this.scandone ) {
  80. this.scanning = true;
  81. this.loadUploadAnalysis();
  82. }
  83. }
  84. }