import { Component, Injector, ViewEncapsulation, ViewChild, AfterViewInit, Output, EventEmitter, Input } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { SupportTicketServiceProxy, SupportTicketSettingServiceProxy, SupportTicketStatusServiceProxy, SupportTicketSettingList, SupportTicketTypeServiceProxy, TicketTypeList, TicketStatusList, TenantListDropDown, TicketKPI, TicketStatusCodeDto, SupportCategoryTypesServiceProxy, TicketList, VersionsServiceProxy, OrganizationUnitDto, GetSupportCategoryTypesForViewDto, TicketEffortHoursDto, PriorityCodeDto } 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 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'; import { PrimengTableHelper } from 'shared/helpers/PrimengTableHelper'; import * as _ from 'lodash'; import * as jquery from 'jquery'; import { OnInit } from '@angular/core'; declare var KTWizard: any; declare var $: any; @Component({ templateUrl: './support-ticket.component.html', styleUrls: ['./support-ticket.component.less'], encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()] }) export class SupportTicketsComponent extends AppComponentBase implements OnInit, AfterViewInit { //@ViewChild('createOrEditRouteTypeModal', { static: true }) createOrEditRouteTypeModal: CreateOrEditRouteTypeModalComponent; //@ViewChild('viewRouteTypeModalComponent', { static: true }) viewRouteTypeModal: ViewRouteTypeModalComponent; //@ViewChild('entityTypeHistoryModal', { static: true }) entityTypeHistoryModal: EntityTypeHistoryModalComponent; @ViewChild('dataTableTickets', { static: true }) dataTableTickets: Table; @ViewChild('paginatorTickets', { static: true }) paginatorTickets: 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; @Output() chartData: EventEmitter = new EventEmitter(); _entityTypeFullName = 'SprintTek.Shipping.SupportTickets.SupportTicket'; entityHistoryEnabled = false; @ViewChild(SupportKPIBoxComponent, { static: false }) sKpiBoxComponent: SupportKPIBoxComponent; advancedFiltersAreShown = false; filterText = ''; tester = ''; assignedToFilter = ''; statusFilter = ''; typeFilter = ''; createdBy = ''; priorityFilter: any; tenant: any; update: Array = []; ticketTypes: TicketTypeList[] = []; ticketStatuses: TicketStatusList[] = []; ticketPriorities: PriorityCodeDto[] = []; 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; versionList: 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: GetSupportCategoryTypesForViewDto [] = []; categoryFilter: any typeFilterCode: any statusFilterCode: any; parentStatusTypeIds: any; primengTableHelperTickets = new PrimengTableHelper(); hideIcon: boolean = false; hideDetail: boolean = true; versionId: any; organizationId: any; organizationUnits: OrganizationUnitDto[] = []; gantt: boolean = false; ganttData: any; filteredStatus: any; filteredStatusParent: any; filteredType: any; filteredPriority: any; filteredCategory: any; initialLoad: boolean = true; 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, private _versionService: VersionsServiceProxy, private router: Router, ) { super(injector); if (localStorage.getItem('ticketFilter') == null) { this.searchArray = { 'filterText': this.filterText, 'tester': this.tester, 'assignedToFilter': this.assignedToFilter, 'statusFilter': 'none', 'typeFilter': 'none', // 'priorityFilter': 'none', 'dateFrom': this.dateFrom, 'dateTo': this.dateTo, 'createdBy': this.createdBy, 'tenant': '0', 'tenantCaption': 'Select Tenant', 'startDate': this.startDate, 'dueDate': this.dueDate, 'organizationUnitId': this.organizationId, 'parentStatusTypeId': Number($('#parentStatusId').val()) }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); console.log(localStorage.getItem('ticketFilter')); } else { this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); this.filterText = this.searchArray.filterText; this.assignedToFilter = this.searchArray.assignedToFilter; this.tester = this.searchArray.tester; this.typeFilter = this.searchArray.typeFilter; // this.typeFilterCode = this.searchArray.typeFilterCode; // this.priorityFilter = this.searchArray.priorityFilter; 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.organizationId = this.searchArray.organizationUnitId; } this.showFilters(); } ngOnInit(): void { var that = this; this.setIsEntityHistoryEnabled(); $('.kt-select2').select2(); this.resultGroup = []; this.hideHeader = true; this.tenancy = this._appSessionService.tenant != undefined ? true : false; console.log(this.searchArray); console.log(this.typeFilterCode); // this.getSupportTickets(); } showFilters(){ this.showAllTenant(); this.showAllStatus(); this.showAllPriorities(); this.showAllTypes(); this.showUrl(); this.getParentStatusType(); this.checkSetting(); this.getCategoryTypes(); this.getVersion(); this.getEffortHours(); } hideShow(event, id?): void { if (id === '') { } else { let divId = id; let numb = divId.match(/\d/g); numb = numb.join(""); let showIconIdStatus = 'showIconStatus-' + numb; let showDetailIdStatus = 'showDetailStatus-' + numb; let showIconIdType = 'showIconType-' + numb; let showDetailIdType = 'showDetailType-' + numb; let showIconIdCategory = 'showIconCategory-' + numb; let showDetailIdCategory = 'showDetailCategory-' + numb; if (event.type == 'mouseover') { if (id.includes('Status') == true) { $('#' + showIconIdStatus).hide(); $('#' + showDetailIdStatus).show(); } else if (id.includes('Type') == true) { $('#' + showIconIdType).hide(); $('#' + showDetailIdType).show(); } else if (id.includes('Category') == true) { $('#' + showIconIdCategory).hide(); $('#' + showDetailIdCategory).show(); } } else if (event.type == 'mouseout') { if (id.includes('Status') == true) { $('#' + showIconIdStatus).show(); $('#' + showDetailIdStatus).hide(); } else if (id.includes('Type') == true) { $('#' + showIconIdType).show(); $('#' + showDetailIdType).hide(); } else if (id.includes('Category') == true) { $('#' + showIconIdCategory).show(); $('#' + showDetailIdCategory).hide(); } } } } ngAfterViewInit(): void { this.primengTableHelperTickets.adjustScroll(this.dataTableTickets); this.initialLoad = true; this.getSupportTickets(); } checkSetting(): void { this._settingServiceProxy.checkSupportSetting().subscribe((result) => { this.checkSettings = result; }); } showUrl(): void { this._settingServiceProxy.getSettingsForDisplay().subscribe((result) => { if (result != null) { this.supportTicketSettingList = result[0]; } }); } getDate(event): void { let from = new Date(event[0]).toLocaleDateString() let to = new Date(event[1]).toLocaleDateString() this.dateFrom = from; this.dateTo = to; } getKpi(): void { this._supportTicketsServiceProxy.getTicketForKPI( ).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( ).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; }); } getSupportTicketsKPIFilter(status: any, type: any) { console.log(type); this.searchArray = { 'filterText': this.filterText, 'tester': this.tester, 'assignedToFilter': this.assignedToFilter, 'statusFilter': status, 'typeFilter': type, // 'priorityFilter': this.priorityFilter, '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()), 'organizationUnitId': this.organizationId }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); console.log(localStorage.getItem('ticketFilter')); } getSupportTicketsFilter() { this.searchArray = { 'filterText': this.filterText, 'tester': this.tester, '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()), 'organizationUnitId': this.organizationId, }; localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); this.getSupportTickets(); } getSupportTickets(event?: LazyLoadEvent) { this.ganttData = []; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); console.log(this.searchArray); console.log(this.initialLoad); this.statusFilter = this.searchArray.statusFilter; this.typeFilter = this.searchArray.typeFilter; this.statusFilterCode = this.searchArray.statusFilterCode; this.typeFilterCode = this.searchArray.typeFilterCode; this.priorityFilter = this.searchArray.priorityFilter; this.categoryFilter = this.searchArray.categoryFilter; this.tenant = this.searchArray.tenant; this.parentStatusTypeId = 0; this.priorityFilter = this.initialLoad ? this.priorityFilter : $("#priority").val() == "" ? undefined : $("#priority").val() this.effortHour = $("#effortHours").val() == "" ? 0 : $("#effortHours").val(); this.statusFilter = (this.statusFilter == 'none') ? '' : this.statusFilter; this.tenant = $("#tenant").val() == 0 ? undefined : $("#tenant").val(); this.categoryFilter = this.initialLoad ? this.categoryFilter : $("#categoryFilter").val() == 0 ? undefined :$("#categoryFilter").val() this.organizationId = $("#unit2").val() == 0 ? undefined : $("#unit2").val() this.statusFilterCode = this.initialLoad ? this.statusFilterCode : $("#status").val() == 0 ? undefined : $("#status").val() this.typeFilterCode = this.initialLoad ? this.typeFilterCode : $("#ticketType2").val() == 0 ? undefined : $("#ticketType2").val(); this.parentStatusTypeIds = $("#parentStatusId").val() == 0 ? undefined : $("#parentStatusId").val(); this.versionId = $("#version").val() == 0 ? undefined : $("#version").val() this.spinnerService.show(); this._supportTicketsServiceProxy.getTicket( this.filterText, this.assignedToFilter, this.tester, 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.organizationId, this.todayFilter, this.myTickerFilter, this.openTicketFilter, this.startDate, this.dueDate, this.effortHour, this.versionId, this.primengTableHelperTickets.getSorting(this.dataTableTickets), this.primengTableHelperTickets.getSkipCount(this.paginatorTickets, event), this.primengTableHelperTickets.getMaxResultCount(this.paginatorTickets, 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, 'tester': this.tester, 'statusFilter': this.statusFilter, 'statusFilterCode': this.statusFilterCode, 'typeFilter': this.typeFilter, 'typeFilterCode': this.typeFilterCode, 'priorityFilter': this.priorityFilter, 'categoryFilter': this.categoryFilter, '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()), 'organizationUnitId': this.organizationId }; console.log(this.searchArray); localStorage.setItem('ticketFilter', JSON.stringify(this.searchArray)); this.initialLoad = false; this.sKpiBoxComponent.getKpi(); 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.primengTableHelperTickets.totalRecordsCount = result.totalCount; this.primengTableHelperTickets.records = result.items; this.primengTableHelperTickets.records = this.resultGroup; this.spinnerService.hide(); localStorage.setItem('sorting', this.primengTableHelperTickets.getSorting(this.dataTableTickets)); localStorage.setItem('skipCount', this.primengTableHelperTickets.getSkipCount(this.paginatorTickets, event).toString()); localStorage.setItem('maxResultCount', this.primengTableHelperTickets.getMaxResultCount(this.paginatorTickets, event).toString()); }); } expandDetails(obj: string, tenantId: any) { obj = obj.replace(' ', '-'); if ($('.tr-' + obj).css('display') == 'none') { // $('.span-' + obj).html(obj + ' Routes'); $('.tr-' + obj).css('display', 'table-row'); $('.td-' + obj).html('Collapse '); if (tenantId == 0) { tenantId = ""; } this.tenantIds.push(tenantId); } else { $('.tr-' + obj).css('display', 'none'); $('.td-' + obj).html('Expand '); } 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}`; } 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._supportTicketTypeServiceProxy.getTicketTypeList().subscribe((result) => { this.ticketTypes = result.items; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); let key, key2, arrAny = {}, arrHolder = []; for (key in this.ticketTypes) { arrAny = { 'code': this.ticketTypes[key].code, 'desc': this.ticketTypes[key].description, 'selected': false }; if (this.searchArray != undefined) { if (this.searchArray.typeFilterCode != null) { for (key2 in this.searchArray.typeFilterCode) { if (this.searchArray.typeFilterCode[key2] == this.ticketTypes[key].code) { arrAny = { 'code': this.ticketTypes[key].code, 'desc': this.ticketTypes[key].description, 'selected': true }; } } } } arrHolder.push(arrAny); } this.filteredType = arrHolder; console.log(this.filteredType); }); } showAllPriorities(): void { this._supportTicketStatusServiceProxy.getPriority().subscribe((result) => { this.ticketPriorities = result; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); let key, key2, arrAny = {}, arrHolder = []; for (key in this.ticketPriorities) { arrAny = { 'code': this.ticketPriorities[key].code, 'id': this.ticketPriorities[key].id, 'selected': false }; if (this.searchArray != undefined) { if (this.searchArray.priorityFilter != null) { for (key2 in this.searchArray.priorityFilter) { if (this.searchArray.priorityFilter[key2] == this.ticketPriorities[key].id) { arrAny = { 'code': this.ticketPriorities[key].code, 'id': this.ticketPriorities[key].id, 'selected': true }; } } } } arrHolder.push(arrAny); } this.filteredPriority = arrHolder; console.log(this.filteredPriority); }); } showAllStatus(): void { //this.active = true; this._supportTicketStatusServiceProxy.getTicketStatusList().subscribe((result) => { this.ticketStatuses = result.items; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); let key, key2, arrAny = {}, arrHolder = []; for (key in this.ticketStatuses) { arrAny = { 'desc': this.ticketStatuses[key].description, 'code': this.ticketStatuses[key].code, 'selected': false }; if (this.searchArray != undefined) { if (this.searchArray.statusFilterCode != null) { for (key2 in this.searchArray.statusFilterCode) { if (this.searchArray.statusFilterCode[key2] == this.ticketStatuses[key].code) { arrAny = { 'desc': this.ticketStatuses[key].description, 'code': this.ticketStatuses[key].code, 'selected': true }; } } } } arrHolder.push(arrAny); } this.filteredStatus = arrHolder; }); } getCategoryTypes() { this._supportCategoryTypeServiceProxy.getAll(undefined, undefined, undefined, undefined, undefined, 0, undefined, undefined, 1000) .subscribe(result => { this.categoryTypes = result.items; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); let key, key2, arrAny = {}, arrHolder = []; for (key in this.categoryTypes) { arrAny = { 'desc': this.categoryTypes[key].supportCategoryTypes.description, 'id': this.categoryTypes[key].supportCategoryTypes.id, 'selected': false }; if (this.searchArray != undefined) { if (this.searchArray.categoryFilter != null) { for (key2 in this.searchArray.categoryFilter) { if (this.searchArray.categoryFilter[key2] == this.categoryTypes[key].supportCategoryTypes.id) { arrAny = { 'desc': this.categoryTypes[key].supportCategoryTypes.description, 'id': this.categoryTypes[key].supportCategoryTypes.id, 'selected': true }; } } } } arrHolder.push(arrAny); } this.filteredCategory = arrHolder; }); } 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); } } } }); } getParentStatusType() { this._supportTicketStatusServiceProxy.getParentTicketStatusType().subscribe(result => { this.parentStatusType = result; this.searchArray = JSON.parse(localStorage.getItem('ticketFilter')); let key, key2, arrAny = {}, arrHolder = []; for (key in this.parentStatusType) { arrAny = { 'code': this.parentStatusType[key].code, 'id': this.parentStatusType[key].id, 'selected': false }; if (this.searchArray != undefined) { if (this.searchArray.statusFilterCode != null) { for (key2 in this.searchArray.statusFilterCode) { if (this.searchArray.statusFilterCode[key2] == this.parentStatusType[key].code) { arrAny = { 'code': this.parentStatusType[key].code, 'id': this.parentStatusType[key].id, 'selected': true }; } } } } arrHolder.push(arrAny); } this.filteredStatusParent = arrHolder; //console.log(this.filteredStatus); }); } 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."); } ); } 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); } 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 = $("#ticketType2").val() == 0 ? undefined : $("#ticketType2").val() this.statusFilterCode = $("#status").val() == 0 ? undefined : $("#status").val() this.parentStatusTypeIds = $("#parentStatusId").val() == 0 ? undefined : $("#parentStatusId").val() this.spinnerService.show(); this.versionId = $("#version").val() == 0 ? undefined : $("#version").val() this.spinnerService.show(); this._supportTicketsServiceProxy.getTicketToExcel( this.filterText, this.assignedToFilter, this.tester, 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.organizationId, this.todayFilter, this.myTickerFilter, this.openTicketFilter, this.startDate, this.dueDate, this.effortHour, this.versionId, undefined, undefined, undefined, ).subscribe(result => { if (result != undefined) { if (result.fileUrl != undefined) { this.router.navigate([]).then(result1 => { window.open(result.fileUrl, '_blank'); }); this.spinnerService.hide(); } else { this.spinnerService.hide(); } } else { this.message.warn('', "No data to export"); this.spinnerService.hide(); } }); } getEffortHours() { this._supportTicketStatusServiceProxy.getEffortHours().subscribe(result => { this.effortHours = result; }); } getVersion() { this._versionService.getAll(undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1000).subscribe(result => { this.versionList = result.items; }) } showGanttChart() { if (this.gantt) { this.gantt = false; $('#tickets-container').show(); $('#kt_aside_toggler').trigger('click'); $('.refresh').show(); $('.newTicket').show(); $('.export').show(); $('#header').text("Tickets"); $('#desc').text("Manage Tickets"); } else { this.gantt = true; $('#tickets-container').hide(); $('.refresh').hide(); $('.newTicket').hide(); $('.export').hide(); $('#header').text("Gantt Chart"); } } }