import { Component, Injector, ViewChild, ViewEncapsulation, OnInit, DoCheck, Input } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { OrderStatusAttachmentServiceProxy } from '@shared/service-proxies/service-proxies'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { finalize } from 'rxjs/operators'; import { ModalDirective } from 'ngx-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import * as moment from 'moment'; import { DomSanitizer } from '@angular/platform-browser'; @Component({ templateUrl: './order-attachments.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()], styleUrls: ['./order-detail.component.less'], selector: 'orderAttachment' }) export class OrderAttachment extends AppComponentBase implements OnInit { orderStatusPhotoId:number; active = false; saving= false; orderId:number; image:string; caption:string; @ViewChild('orderAttachmentModal', {static: false}) modal: ModalDirective; constructor( injector: Injector, private id:ActivatedRoute, private _attachmentService:OrderStatusAttachmentServiceProxy, public sanitizer:DomSanitizer ) { super(injector); } timeId: any; ngOnInit() { this.id.paramMap.subscribe(params => { this.orderId = Number(params.get('id')); }); // this.timeId = localStorage.getItem('timeZoneId'); // moment.tz.setDefault(this.timeId); } show(image:string,caption:string,id:number):void { this.image = image; this.caption = caption; this.orderStatusPhotoId = id; this.active = true; this.modal.show(); } deletePhoto() : void { this.message.confirm( this.l("AreYouSure"), '', (isConfirmed) => { if (isConfirmed) { this.spinnerService.show(); this.saving = true; this._attachmentService.deleteOrderStatusPhoto(this.orderStatusPhotoId) .pipe(finalize(() => { this.saving = false; })) .subscribe(() => { document.getElementById("attachment-photo-id-" + this.orderStatusPhotoId).remove(); this.close(); this.spinnerService.hide(); }); } } ); } onShown(): void { } close(): void { this.active = false; this.modal.hide(); } }