import { Component, Injector, ViewEncapsulation, ViewChild, AfterViewInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { SupportTicketServiceProxy, SupportTicketSettingServiceProxy, SupportTicketStatusServiceProxy, SupportTicketSettingList, SupportTicketTypeServiceProxy, TicketTypeList, TicketStatusList, TenantListDropDown, TicketKPI, TicketStatusCodeDto, SupportCategoryTypesServiceProxy, TicketList, TicketEffortHoursDto} from '@shared/service-proxies/service-proxies'; import { NotifyService } from '@abp/notify/notify.service'; import { AppComponentBase } from '@shared/common/app-component-base'; import { TokenAuthServiceProxy } from '@shared/service-proxies/service-proxies'; //import { CreateOrEditRouteTypeModalComponent } from './create-or-edit-routeType-modal.component'; //import { ViewRouteTypeModalComponent } from './view-routeType-modal.component'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { Table } from 'primeng/components/table/table'; import { Paginator } from 'primeng/components/paginator/paginator'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { HttpClient, HttpEventType, } from '@angular/common/http'; import { Router } from '@angular/router'; //import { EntityTypeHistoryModalComponent } from '@app/shared/common/entityHistory/entity-type-history-modal.component'; import * as _ from 'lodash'; import * as moment from 'moment'; import { AppSessionService } from '@shared/common/session/app-session.service'; import { HttpHeaders } from '@angular/common/http'; import { map } from "rxjs/operators"; import { saveAs } from 'file-saver'; import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; import { AppConsts } from '@shared/AppConsts'; import { TicketNotesModalComponent } from './ticket-notes-modal.component'; import { AssignModalComponent } from './assign-modal.component'; import { AssignTenantComponent } from './assign-tenant.component'; import { SupportKPIBoxComponent } from '@app/sprintship/supportTicket/support-kpi-box/support-kpi-box.component'; import { EntityTypeHistoryModalComponent } from '@app/shared/common/entityHistory/entity-type-history-modal.component'; declare var $ : any @Component({ templateUrl: './support-ticket.component.html', styleUrls: ['./support-ticket.component.less'], encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()] }) export class SupportTicketsComponent extends AppComponentBase { //@ViewChild('createOrEditRouteTypeModal', { static: true }) createOrEditRouteTypeModal: CreateOrEditRouteTypeModalComponent; //@ViewChild('viewRouteTypeModalComponent', { static: true }) viewRouteTypeModal: ViewRouteTypeModalComponent; //@ViewChild('entityTypeHistoryModal', { static: true }) entityTypeHistoryModal: EntityTypeHistoryModalComponent; @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; @ViewChild('ticketNotesModal', {static: false}) ticketNotesModal: TicketNotesModalComponent; @ViewChild('assignModal', {static: false}) assignModal: AssignModalComponent; @ViewChild('assignTenant', {static: false}) assignTenant: AssignTenantComponent; @ViewChild('entityTypeHistoryModal', { static: true }) entityTypeHistoryModal: EntityTypeHistoryModalComponent; _entityTypeFullName = 'SprintTek.Shipping.SupportTickets.SupportTicket'; entityHistoryEnabled = false; @ViewChild(SupportKPIBoxComponent, { static: false }) sKpiBoxComponent: SupportKPIBoxComponent; advancedFiltersAreShown = false; filterText = ''; assignedToFilter = ''; statusFilter = ''; typeFilter = ''; createdBy = ''; priorityFilter: any; tenant: any; update: Array = []; ticketTypes: TicketTypeList[] = []; ticketStatuses: TicketStatusList[] = []; tenantList: TenantListDropDown[] = []; supportTicketSettingList: any; tenancy: boolean = false; hostList: any; totalTicket: any totalNewTicket: any; totalAssignedTicket: any; totalClosedTicket: any; totalTodayClosedTicket: any; totalFeatureChangeTicket: any; totalBugTicket: any; totalNewFeatureTicket: any; totalMyTicket: any; totalMyCreateTicket: any; totalUnAssignedTicket: any; todayFilter:any; myTickerFilter:any; openTicketFilter:any; dateFrom: any; dateTo: any; resultGroup: any; hideHeader: boolean; effortHours : TicketEffortHoursDto[]; dueDate: any; startDate: any; effortHour: number; //public dateRange: moment.Moment[] = [moment().startOf('day'), moment().endOf('day')]; checkSettings = false; tenantIds: Array = []; searchArray: any; parentStatusType : TicketStatusCodeDto[]; parentStatusTypeId: number; categoryTypes: any categoryFilter: any typeFilterCode: any statusFilterCode: any; parentStatusTypeIds: any; constructor( injector: Injector, private _supportTicketsServiceProxy: SupportTicketServiceProxy, private _notifyService: NotifyService, private _tokenAuth: TokenAuthServiceProxy, private _activatedRoute: ActivatedRoute, private _fileDownloadService: FileDownloadService, private _settingServiceProxy: SupportTicketSettingServiceProxy, private _supportTicketStatusServiceProxy: SupportTicketStatusServiceProxy, private _supportTicketTypeServiceProxy: SupportTicketTypeServiceProxy, private _supportCategoryTypeServiceProxy : SupportCategoryTypesServiceProxy, private _httpClient: HttpClient, private _router: Router, private _appSessionService: AppSessionService, ) { super(injector); } ngOnInit(): void { var that = this; this.setIsEntityHistoryEnabled(); $('.kt-select2').select2(); this.showAllTypes(); this.showAllStatus(); this.showAllTenant(); this.showUrl(); this.getParentStatusType(); this.checkSetting(); this.getCategoryTypes(); this.getEffortHours(); this.resultGroup = []; this.hideHeader = true; if(localStorage.getItem('ticketFilter') == null) { this.searchArray = { 'filterText': this.filterText, 'assignedToFilter': this.assignedToFilter, 'statusFilter': 'none', 'typeFilter': 'none', 'dateFrom': this.dateFrom, 'dateTo': this.dateTo, 'createdBy': this.createdBy, 'tenant': '0', 'tenantCaption': 'Select Tenant', 'startDate': this.startDate, 'dueDate': this.dueDate, 'parentStatusTypeId': Number($('#parentStatusId').val()) }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); } else { this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); this.filterText = this.searchArray.filterText; this.assignedToFilter = this.searchArray.assignedToFilter; this.typeFilter = this.searchArray.typeFilter; this.dateFrom = this.searchArray.dateFrom; this.dateTo = this.searchArray.dateTo; this.createdBy = this.searchArray.createdBy; this.tenant = this.searchArray.tenant; this.parentStatusTypeId = this.searchArray.parentStatusTypeId; this.startDate = this.searchArray.startDate; this.dueDate = this.searchArray.dueDate; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); if(this.searchArray.statusFilter == 'none') { $('#status').select2({'placeholder': 'Select Status'}); (document.getElementById('status')).value = 'none'; } else { $('#status').select2({'placeholder': this.searchArray.statusFilter}); (document.getElementById('status')).value = this.statusFilter; } if(this.searchArray.typeFilter == 'none') { $('#type').select2({'placeholder': 'Select Type'}); (document.getElementById('type')).value = 'none'; } else { $('#type').select2({'placeholder': this.searchArray.typeFilter}); (document.getElementById('type')).value = this.searchArray.typeFilter; $('#select2-type-container').html( this.searchArray.typeFilter); } if(this.searchArray.tenant == '0') { } else { } // $('.kt-select2').trigger('change'); } /*$('#status').on('select2:select', function (e) { that.getSupportTickets(); }); $('#type').on('select2:select', function (e) { that.getSupportTickets(); }); $('#tenant').on('select2:select', function (e) { that.getSupportTickets(); });*/ if(this._appSessionService.tenant != undefined) { this.tenancy = true; } } ngAfterViewInit(): void { this.primengTableHelper.adjustScroll(this.dataTable); } checkSetting(): void { this._settingServiceProxy.checkSupportSetting().subscribe((result) => { this.checkSettings = result; }); } showUrl(): void { this._settingServiceProxy.getSettingsForDisplay().subscribe((result) => { if(result!=null){ this.supportTicketSettingList = result.items[0]; } // console.log(this.supportTicketSettingList); }); } getDate(event) : void { let from = new Date(event[0]).toLocaleDateString() let to = new Date(event[1]).toLocaleDateString() console.log(from); this.dateFrom = from; this.dateTo = to; //this.getSupportTickets(); } getKpi() : void { this._supportTicketsServiceProxy.getTicketForKPI(undefined ).subscribe(result => { this.totalTicket = result.totalAllTicket; this.totalNewTicket = result.totalNewTicket; this.totalAssignedTicket = result.totalAssignedTicket; this.totalClosedTicket = result.totalCloseTicket; this.totalTodayClosedTicket = result.totalCloseTicketToday; this.totalFeatureChangeTicket = result.totalFeatureChangeTicket; this.totalBugTicket = result.totalIssueOrBugTicket; this.totalNewFeatureTicket = result.totalNewFeatureTicket; this.totalMyTicket = result.totalMyTicket; this.totalMyCreateTicket = result.totalMyCreateTicket; this.totalUnAssignedTicket = result.totalUnAssignedTicket ; }); } getKpiFilter(input: any) : void { this._supportTicketsServiceProxy.getTicketForKPI(input ).subscribe(result => { this.totalTicket = result.totalAllTicket; this.totalNewTicket = result.totalNewTicket; this.totalAssignedTicket = result.totalAssignedTicket; this.totalClosedTicket = result.totalCloseTicket; this.totalTodayClosedTicket = result.totalCloseTicketToday; this.totalFeatureChangeTicket = result.totalFeatureChangeTicket; this.totalBugTicket = result.totalIssueOrBugTicket; this.totalNewFeatureTicket = result.totalNewFeatureTicket; this.totalMyTicket = result.totalMyTicket; this.totalMyCreateTicket = result.totalMyCreateTicket; this.totalUnAssignedTicket = result.totalUnAssignedTicket; }); } filterBox(input: string) { (document.getElementById('status')).value = input; this.getSupportTickets(); } getSupportTicketsKPIFilter(status: any, type: any) { this.searchArray = { 'filterText': this.filterText, 'assignedToFilter': this.assignedToFilter, 'statusFilter': status, 'typeFilter': type, 'dateFrom': this.dateFrom, 'dateTo': this.dateTo, 'createdBy': this.createdBy, 'todayFilter':this.todayFilter, 'myTicketFilter':this.myTickerFilter, 'opentTicketFilter':this.openTicketFilter, 'tenant': (document.getElementById('tenant')).value, 'tenantCaption': $('.select2-tenant-container').text(), 'parentStatusTypeId': Number($('#parentStatusId').val()) }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); this.getSupportTickets(); } getSupportTicketsFilter() { this.searchArray = { 'filterText': this.filterText, 'assignedToFilter': this.assignedToFilter, // removed having issue with kpi and normal search if not disabled // 'statusFilter': (document.getElementById('status')).value, // 'typeFilter': (document.getElementById('type')).value, 'dateFrom': this.dateFrom, 'dateTo': this.dateTo, 'createdBy': this.createdBy, 'todayFilter':this.todayFilter, 'myTicketFilter':this.myTickerFilter, 'opentTicketFilter':this.openTicketFilter, 'tenant': (document.getElementById('tenant')).value, 'tenantCaption': $('.select2-tenant-container').text(), 'parentStatusTypeId': Number($('#parentStatusId').val()) }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); this.getSupportTickets(); } getSupportTickets(event?: LazyLoadEvent) { //if (this.primengTableHelper.shouldResetPaging(event)) { //this.paginator.changePage(0); //return; //} // this.getKpi(); //this.sKpiBoxComponent.getKpi(); //this.primengTableHelper.showLoadingIndicator(); this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); // this.statusFilter = (document.getElementById('status')).value; this.statusFilter = this.searchArray.statusFilter; this.typeFilter = this.searchArray.typeFilter; this.tenant = this.searchArray.tenant; // this.parentStatusTypeId = this.searchArray.parentStatusTypeId; this.parentStatusTypeId = 0; // this.typeFilter = (document.getElementById('type')).value; // this.tenant = (document.getElementById('tenant')).value; this.priorityFilter = $("#priority").val() == "" ? undefined : $("#priority").val() // (document.getElementById('priority')).value; this.effortHour = $("#effortHours").val() == "" ? 0 : $("#effortHours").val() this.statusFilter = (this.statusFilter == 'none') ? '' : this.statusFilter ; this.typeFilter = (this.typeFilter == 'none') ? '' : this.typeFilter ; this.tenant = $("#tenant").val() == 0 ? undefined : $("#tenant").val() // (this.tenant == '0') ? '' : this.tenant ; this.categoryFilter = $("#categoryFilter").val() == 0 ? undefined : $("#categoryFilter").val() // Number((document.getElementById('categoryFilter')).value) == 0 ? // undefined : // Number((document.getElementById('categoryFilter')).value) // console.log($("#type").val()) this.typeFilterCode = $("#type").val() == 0 ? undefined : $("#type").val() this.statusFilterCode = $("#status").val() == 0 ? undefined : $("#status").val() this.parentStatusTypeIds = $("#parentStatusId").val() == 0 ? undefined : $("#parentStatusId").val() this.spinnerService.show(); this._supportTicketsServiceProxy.getTicket( this.filterText, this.assignedToFilter, this.statusFilter, this.statusFilterCode, this.typeFilter, this.typeFilterCode, this.dateFrom, this.dateTo, this.createdBy, this.priorityFilter, this.tenant, this.parentStatusTypeId, this.parentStatusTypeIds, this.categoryFilter, this.todayFilter, this.myTickerFilter, this.openTicketFilter, this.startDate, this.dueDate, this.effortHour, this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getSkipCount(this.paginator, event), this.primengTableHelper.getMaxResultCount(this.paginator, event) ).subscribe(result => { this.statusFilter = (this.statusFilter == '') ? 'none' : this.statusFilter ; this.typeFilter = (this.typeFilter == '') ? 'none' : this.typeFilter ; this.tenant = (this.tenant == '') ? '0' : this.tenant ; this.searchArray = { 'filterText': this.filterText, 'assignedToFilter': this.assignedToFilter, 'statusFilter': this.statusFilter, 'typeFilter': this.typeFilter, 'dateFrom': this.dateFrom, 'dateTo': this.dateTo, 'createdBy': this.createdBy, 'todayFilter':this.todayFilter, 'myTicketFilter':this.myTickerFilter, 'opentTicketFilter':this.openTicketFilter, 'tenant': this.tenant, 'startDate': this.startDate, 'dueDate': this.dueDate, 'tenantCaption': $('.select2-tenant-container').text(), 'parentStatusTypeId': Number($('#parentStatusId').val()) }; this.sKpiBoxComponent.getKpi(); localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); let key, object, index; let arrTmp = []; this.resultGroup = []; if( result.items.length > 0) { if(result.items[0].mainTenant !== null) { this.hideHeader = false; } } for(key in result.items) { let obj = this.resultGroup.find(o=> o.tenant === result.items[key].tenant); let index = this.resultGroup.findIndex(o=> o.tenant === result.items[key].tenant); if(obj === undefined) { arrTmp = []; arrTmp.push( result.items[key]); if(result.items[key].tenant == null) { index = this.resultGroup.findIndex(o=> o.tenant === 'Host'); if(index < 0) { this.resultGroup.push({'tenant': 'Host', 'tenantId': 0, 'tenantDetails': []}); this.tenantIds.push(''); index = this.resultGroup.findIndex(o=> o.tenant === 'Host'); } else { index = this.resultGroup.findIndex(o=> o.tenant === 'Host'); } } else { this.resultGroup.push({'tenant': result.items[key].tenant, 'tenantId': result.items[key].tenantId, 'tenantDetails': []}); this.tenantIds.push(result.items[key].tenantId); index = this.resultGroup.findIndex(o=> o.tenant === result.items[key].tenant); } this.resultGroup[index].tenantDetails.push(result.items[key]); } else { this.resultGroup[index].tenantDetails.push(result.items[key]); } } if(localStorage.getItem('collapseTenants') == null) { localStorage.setItem('collapseTenants', this.tenantIds.toString()); } this.primengTableHelper.totalRecordsCount = result.totalCount; this.primengTableHelper.records = result.items; this.primengTableHelper.records = this.resultGroup; console.log(this.resultGroup); //this.primengTableHelper.hideLoadingIndicator(); this.spinnerService.hide(); }); } expandDetails(obj: string, tenantId: any) { console.log('TENANT IDS: '); console.log(this.tenantIds); if($('.tr-' + obj).css('display') == 'none') { // $('.span-' + obj).html(obj + ' Routes'); $('.tr-' + obj).css('display', 'table-row'); $('.td-' + obj).html(''); if(tenantId == 0) { tenantId = ""; } this.tenantIds.push(tenantId); } else { // $('.span-' + obj).html(obj + ' Routes'); $('.tr-' + obj).css('display', 'none'); $('.td-' + obj).html(''); let index = this.tenantIds.findIndex(o=> o == tenantId); this.tenantIds.splice(index,1); } this.getKpiFilter(this.tenantIds); console.log(this.tenantIds) localStorage.setItem('collapseTenants', this.tenantIds.toString()); } reloadPage(): void { //this.paginator.changePage(this.paginator.getPage()); this.getSupportTickets(); } filterKpiBox(filter: any) { if(filter == 'TOTALOPEN') { this.typeFilter = ''; this.openTicketFilter = 'OPEN'; this.statusFilter = ''; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); } else if(filter == 'NEW') { this.typeFilter = ''; this.statusFilter = 'NEW'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'ASSIGNED') { this.typeFilter = ''; this.statusFilter = 'ASSIGNED'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'UNASSIGNED') { this.typeFilter = ''; this.statusFilter = 'UNASSIGNED'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'CLOSED') { this.typeFilter = ''; this.statusFilter = 'RESOLVE'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'TODAY') { this.typeFilter = ''; this.todayFilter = 'TODAY'; this.myTickerFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; this.statusFilter = ''; } else if(filter == 'REQUEST') { this.typeFilter = 'REQUEST'; this.statusFilter = ''; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'ALL') { this.typeFilter = ''; this.statusFilter = ''; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'URGENT') { this.statusFilter = ''; this.priorityFilter = 0; $("#priority").val(0); this.myTickerFilter = ''; this.todayFilter = ''; this.typeFilter = ''; this.openTicketFilter = ''; } else if(filter == 'MODIFICATION') { this.statusFilter = ''; this.typeFilter = 'FEATURECHANGE'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'ISSUEORBUG') { this.statusFilter = ''; this.typeFilter = 'ISSUEORBUG'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'NEWFEATURE') { this.statusFilter = ''; this.typeFilter = 'NEWFEATURE'; this.myTickerFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } else if(filter == 'MYTICKET') { this.myTickerFilter = 'MYTICKET'; this.typeFilter = ''; this.statusFilter = ''; this.todayFilter = ''; this.priorityFilter = ''; $("#priority").val(''); this.openTicketFilter = ''; } this.getSupportTicketsKPIFilter(this.statusFilter, this.typeFilter); } refresh(): void { this.dateFrom = undefined; this.dateTo = undefined; this.getSupportTickets(); } /* createRouteType(): void { this.createOrEditRouteTypeModal.show(); }*/ delete(id): void { this.message.confirm( '', '', (isConfirmed) => { if (isConfirmed) { this._supportTicketsServiceProxy.delete(id) .subscribe(() => { this.reloadPage(); this.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } createOrEdit(url: any, id?: number, open?: boolean){ if(id != null && !open){ var myurl = `${url}/${id}`; }else if(id != null && open){ var myurl = `${url}/${id}/${open}`; }else{ var myurl = `${url}`; } // console.log(myurl); this._router.navigateByUrl(myurl); } documentation() { var url = this.supportTicketSettingList.documentationUrl; var win = window.open(url, '_blank'); win.focus(); } onBoarding() { var url = this.supportTicketSettingList.onBoardingGuideUrl; var win = window.open(url, '_blank'); win.focus(); } gettingStarted() { var url = this.supportTicketSettingList.trainingVideoUrl; var win = window.open(url, '_blank'); win.focus(); } showAllTypes() : void { //this.active = true; this._supportTicketTypeServiceProxy.getTicketTypeList().subscribe((result) => { this.ticketTypes = result.items; }); } showAllStatus() : void { //this.active = true; this._supportTicketStatusServiceProxy.getTicketStatusList().subscribe((result) => { this.ticketStatuses = result.items; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); //removed for placeholder issue // if(this.searchArray.statusFilter == 'none') // { // $('#status').select2({'placeholder': 'Select Status'}); // (document.getElementById('status')).value = 'none'; // } // else // { // $('#status').select2({'placeholder': this.searchArray.statusFilter}); // (document.getElementById('status')).value = this.statusFilter; // } }); } showAllTenant() : void { //this.active = true; this._supportTicketsServiceProxy.getTenantForDropDown().subscribe((result) => { this.tenantList = result.items; this.hostList = JSON.parse(JSON.stringify(result.items)); this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); if(this.searchArray.tenant == '') { $('#tenant').select2({'placeholder': 'Select Tenant'}); (document.getElementById('tenant')).value = ''; } else { let key; for(key in this.hostList) { if(this.hostList[key].id == this.searchArray.tenant) { $('#tenant').select2({'placeholder': this.hostList[key].name}); (document.getElementById('tenant')).value = this.hostList[key].id; $('#select2-tenant-container').html(this.hostList[key].name); } } } }); } downloadFile(id: number, fileName: string) { let checkFileType = fileName.split('.').pop(); var fileType; if (checkFileType == ".txt") { fileType = "text/plain"; } if (checkFileType == ".pdf") { fileType = "application/pdf"; } if (checkFileType == ".doc") { fileType = "application/vnd.ms-word"; } if (checkFileType == ".docx") { fileType = "application/vnd.ms-word"; } if (checkFileType == ".xls") { fileType = "application/vnd.ms-excel"; } if (checkFileType == ".png") { fileType = "image/png"; } if (checkFileType == ".jpg") { fileType = "image/jpeg"; } if (checkFileType == ".jpeg") { fileType = "image/jpeg"; } if (checkFileType == ".gif") { fileType = "image/gif"; } if (checkFileType == ".csv") { fileType = "text/csv"; } this.download(fileName, fileType, id) .subscribe( success => { saveAs(success, fileName); }, err => { alert("Server error while downloading file."); } ); //console.log(this.downloadUrl); //return this._httpClient.get(`${AppConsts.remoteServiceBaseUrl}/api/services/app/SupportTicket/DownloadFile?id= ${id}`, { observe: 'response', responseType: 'blob' as 'json' }); //location.href = this.downloadUrl; //this.notify.success(`Downloaded successfully.`); //window.location = this.downloadUrl; } download(filePath: string, fileType: string, id: number): Observable { let fileExtension = fileType; let input = filePath; return this._httpClient.get(AppConsts.remoteServiceBaseUrl + '/api/services/app/SupportTicket/DownloadFile?id=' + id, { responseType: 'blob', observe: 'response' }).pipe( map((res: any) => { return new Blob([res.body], { type: fileExtension }); }) ); } ticketNotes(id, statusId): void { this.ticketNotesModal.show(id, true, this.ticketStatuses, statusId); } assign(id, assignId?): void { this.assignModal.show(id, assignId); } assignTenantModal(id, assignId, data): void { this.assignTenant.show(id, assignId, data); } getParentStatusType(){ this._supportTicketStatusServiceProxy.getParentTicketStatusType().subscribe(result =>{ this.parentStatusType = result; }); } getCategoryTypes(){ this._supportCategoryTypeServiceProxy.getAll(undefined, undefined, undefined, undefined, undefined, 0, undefined, undefined, 1000) .subscribe(result => { this.categoryTypes = result.items }) } private setIsEntityHistoryEnabled(): void { let customSettings = (abp as any).custom; this.entityHistoryEnabled = customSettings.EntityHistory && customSettings.EntityHistory.isEnabled && _.filter(customSettings.EntityHistory.enabledEntities, entityType => entityType === this._entityTypeFullName).length === 1; } showHistory(role: TicketList): void { this.entityTypeHistoryModal.show({ entityId: role.id.toString(), entityTypeFullName: this._entityTypeFullName, entityTypeDescription: "Ticket - " +role.shortDescription }); } exportToExcel() { this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); this.statusFilter = this.searchArray.statusFilter; this.typeFilter = this.searchArray.typeFilter; this.tenant = this.searchArray.tenant; // this.parentStatusTypeId = this.searchArray.parentStatusTypeId; this.parentStatusTypeId = 0; this.priorityFilter = $("#priority").val() == "" ? undefined : $("#priority").val() this.effortHour = $("#effortHours").val() == "" ? 0 : $("#effortHours").val() this.statusFilter = (this.statusFilter == 'none') ? '' : this.statusFilter ; this.typeFilter = (this.typeFilter == 'none') ? '' : this.typeFilter ; this.tenant = $("#tenant").val() == 0 ? undefined : $("#tenant").val() this.categoryFilter = $("#categoryFilter").val() == 0 ? undefined : $("#categoryFilter").val() this.typeFilterCode = $("#type").val() == 0 ? undefined : $("#type").val() this.statusFilterCode = $("#status").val() == 0 ? undefined : $("#status").val() this.parentStatusTypeIds = $("#parentStatusId").val() == 0 ? undefined : $("#parentStatusId").val() this.spinnerService.show(); this._supportTicketsServiceProxy.getTicketToExcel( this.filterText, this.assignedToFilter, this.statusFilter, this.statusFilterCode, this.typeFilter, this.typeFilterCode, this.dateFrom, this.dateTo, this.createdBy, this.priorityFilter, this.tenant, this.parentStatusTypeId, this.parentStatusTypeIds, this.categoryFilter, this.todayFilter, this.myTickerFilter, this.openTicketFilter, this.startDate, this.dueDate, this.effortHour, undefined, undefined, undefined, ).subscribe(result => { this._fileDownloadService.downloadTempFile(result); this.spinnerService.hide(); }); } getEffortHours(){ this._supportTicketStatusServiceProxy.getEffortHours().subscribe(result =>{ this.effortHours = result; }); } }