|
- import {Component, ElementRef, Input, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
- import {ActivatedRoute, Router} from '@angular/router';
- import {UploadAttachService} from '../service/upload.attach.service';
- import {UploadAnalysisModel} from '../models/upload.analysis.model';
- import {UploadModel} from '../models/upload.model';
- import {FloatingActionButtonComponent} from '@progress/kendo-angular-buttons';
- import {DrawerSelectEvent} from '@progress/kendo-angular-layout';
-
-
-
- @Component({
- selector: 'app-upload-detail',
- templateUrl: './upload-detail.component.html',
- styleUrls: ['./upload-detail.component.scss']
- })
- export class UploadDetailComponent implements OnInit {
- @Input() uploadId: number;
- @Input() ua: UploadAnalysisModel = new UploadAnalysisModel({});
- @ViewChild('fab', {static: true}) fab: FloatingActionButtonComponent;
- @ViewChild('pdf', {static: false}) pdf: ElementRef;
- // 'http://africau.edu/images/default/sample.pdf';
- public uploadAsPicUrl = 'https://svr2021.lawipac.com:8080/api/v1/upload-as-pdf/default';
- public uploadAsPdfUrl = '';
- public initAnimation = false;
- public iframeLoaded = false;
- public scanning = false;
- public scandone = false;
- constructor(private us: UploadAttachService, private actRoute: ActivatedRoute, private router: Router) { }
-
- ngOnInit(): void {
- const id = this.actRoute.snapshot.params.id;
- if ( id !== undefined && id > 0 ) {
- this.uploadId = id;
- }
-
- this.ua.Id = this.uploadId;
- if ( this.uploadId > 0 ) {
- this.uploadAsPicUrl = this.us.getUploadAsJpgUrl(this.ua.Id);
- this.uploadAsPdfUrl = this.us.getUploadAsPdfUrl(this.ua.Id);
- }
-
- this.loadUploadMeta();
- // this.loadUploadAnalysis();
- // this.fabOffset = { y : '-1px' };
- this.fabSlideIn();
- }
-
- private loadUploadAnalysis(): void {
- this.us.getUploadAnalysis(this.uploadId).subscribe(
- resp => {
- this.scandone = true;
- this.scanning = false;
- this.ua = new UploadAnalysisModel(resp);
- this.uploadId = this.ua.Id;
- }
- );
- }
- private loadUploadMeta(): void {
- this.us.getUploadMeta(this.uploadId).subscribe(
- resp => {
- this.ua.Input = new UploadModel(resp);
- }
- );
- }
-
- private fabSlideIn(): void {
- setTimeout(() => {this.initAnimation = true; }, 1000);
- }
-
- public onClickFloatActionButton(e: any): void{
- this.router.navigate(['/lender-uploads']);
- }
-
- public finishedLoading(status: string ): void{
- if ( this.pdf === undefined ) {
- return;
- }
- const el = this.pdf.nativeElement;
- if ( el !== undefined && el.src === this.uploadAsPdfUrl) {
- console.log('yes true',this);
- this.iframeLoaded = true;
- }
- }
- public onTabSelect( select: DrawerSelectEvent): void {
- if ( select.index === 2 && ! this.iframeLoaded ) {
- select.preventDefault();
- return;
- }
- if ( ! this.scandone ) {
- this.scanning = true;
- this.loadUploadAnalysis();
- }
-
- }
- }
|