import { Component, ViewChild, Injector, Output, EventEmitter, ViewEncapsulation} from '@angular/core'; import { ModalDirective } from 'ngx-bootstrap'; import { finalize } from 'rxjs/operators'; import { OrderTypesServiceProxy, CreateOrEditOrderTypeDto, SupportTicketServiceProxy, GetTicketForEdit } from '@shared/service-proxies/service-proxies'; import { AppComponentBase } from '@shared/common/app-component-base'; import * as moment from 'moment'; import { CreateOrEditOrderTypeModalComponent } from '@app/sprintship/order-management/order-types/create-or-edit-orderType-modal.component'; import { IFormattedUserNotification, UserNotificationHelper } from './UserNotificationHelper'; @Component({ encapsulation: ViewEncapsulation.None, templateUrl: './emegency-notifications.component.html', selector: 'emergencyNotifModalComponent', styleUrls: [ './emegency-notifications.component.less' ] }) export class EmergencyNotifModalComponent extends AppComponentBase { @ViewChild('createOrEditModal', { static: true }) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); active = false; saving = false; isPending: boolean; ticketId: number; ticket: GetTicketForEdit; notification: IFormattedUserNotification; constructor( injector: Injector, private _supportTicketService: SupportTicketServiceProxy, private _userNotificationHelper: UserNotificationHelper ) { super(injector); } // show(isPending: boolean,ticketId: number): void { // this.spinnerService.show(); // this.active = true; // this._supportTicketService.getTicketForEdit(ticketId).subscribe(result => { // this.spinnerService.hide(); // this.modal.show(); // }); // } save(): void { // this.saving = true; // this._orderTypesServiceProxy.createOrEdit(this.orderType) // .pipe(finalize(() => { this.saving = false;})) // .subscribe(() => { // this.notify.info(this.l('SavedSuccessfully')); // this.close(); // this.modalSave.emit(null); // }); } close(): void { this.active = false; this.modal.hide(); } show(isPending: boolean,ticketId: number, notif: IFormattedUserNotification) { this.isPending = isPending; this.ticketId = ticketId; this.notification = notif; console.log("show emergency") this.getEmergencyProtocol(() => { this.active = true; this.modal.show(); }); } private getEmergencyProtocol(callback: () => void) { this.spinnerService.show(); this._supportTicketService.getTicketForEdit(this.ticketId).subscribe((result: GetTicketForEdit) => { this.ticket = result; callback(); this.spinnerService.hide(); }); } setNotificationAsRead(userNotification: IFormattedUserNotification): void { this._userNotificationHelper.setAsRead(userNotification.userNotificationId); } }