import { Component, Injector, ViewEncapsulation, ViewChild, OnInit, Injectable } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { NotifyService } from '@abp/notify/notify.service'; import { AppComponentBase } from '@shared/common/app-component-base'; import { TokenAuthServiceProxy, SupportCategoryTypesServiceProxy, VersionsServiceProxy, OrganizationUnitDto, TicketList, GetAllVersionsInput, GetTicketStatusInput, PagedResultDtoOfNameValueDto, NameValueDto, GetSupportTicketUsersInput, IPagedResultDtoOfNameValueDto, Page } from '@shared/service-proxies/service-proxies'; import { UserServiceProxy, UserListDto, SupportTicketServiceProxy, SupportTicketStatusServiceProxy, SupportTicketTypeServiceProxy, TicketTypeList, TicketStatusList, CreateTicketDto, CreateAttachments, CreateNotes, AttachmentList, NoteList, GetTicketForEdit, UpdateTicketDto } from '@shared/service-proxies/service-proxies'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { TicketNotesModalComponent } from './ticket-notes-modal.component'; import { AppSessionService } from '@shared/common/session/app-session.service'; 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 { EntityTypeHistoryModalComponent } from '@app/shared/common/entityHistory/entity-type-history-modal.component'; import * as _ from 'lodash'; import * as moment from 'moment'; import { Router } from '@angular/router'; import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker'; import { HttpEventType, HttpClient } from '@angular/common/http'; import { FormControl } from '@angular/forms'; import {Location} from '@angular/common'; import { AppConsts } from '@shared/AppConsts'; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import { HttpHeaders } from '@angular/common/http'; import { map } from "rxjs/operators"; import { NgxDropzoneModule } from 'ngx-dropzone'; import { saveAs } from 'file-saver'; import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; import { CommonLookupModalComponent } from '@app/shared/common/lookup/common-lookup-modal.component'; import { CommonLookupCheckboxModalComponent } from '@app/shared/common/lookup/common-lookup-checkbox-modal.component'; import { Observer } from 'rxjs'; //import { networkInterfaces } from 'node:os'; declare var $ : any; @Component({ templateUrl: './edit-support-ticket.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()], styleUrls: ['./support-ticket.component.less'], }) @Injectable() export class EditSupportTicketComponent extends AppComponentBase implements OnInit { @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; @ViewChild('ticketNotesModal', {static: false}) ticketNotesModal: TicketNotesModalComponent; @ViewChild('ticketTypesList', {static: true}) ticketTypesList: CommonLookupModalComponent; @ViewChild('ticketStatusList', {static: true}) ticketStatusList: CommonLookupModalComponent; @ViewChild('environmentList', {static: true}) environmentList: CommonLookupModalComponent; @ViewChild('priorityList', {static: true}) priorityList: CommonLookupModalComponent; @ViewChild('userList', {static: true}) userList: CommonLookupModalComponent; @ViewChild('ticketList', {static: true}) ticketList: CommonLookupModalComponent; @ViewChild('effortHourList', {static: true}) effortHourList: CommonLookupModalComponent; @ViewChild('versionList', {static: true}) versionList: CommonLookupModalComponent; @ViewChild('unitList', {static: true}) unitList: CommonLookupModalComponent; @ViewChild('publicStatusList', {static: true}) publicStatusList: CommonLookupModalComponent; @ViewChild('categoryTypesList', {static: true}) categoryTypesList: CommonLookupCheckboxModalComponent; bsConfig: Partial; id: any; defaultDate = new Date(); dueDate = new Date(); startDate = new Date(); effortHour? : number; //effortHours : TicketEffortHoursDto[]; //users: UserListDto = new UserListDto(); //contacts: ContactListDto= new ContactListDto(); incidentDate: any; incidentType: any; typesId: number; content: string; notes: any[] = []; users: UserListDto[] = []; ticketTypes: TicketTypeList[] = []; ticketStatuses: TicketStatusList[] = []; filesDropDown: AttachmentList[] = []; noteList: NoteList[] = []; organizationUnits: OrganizationUnitDto[] = []; tickets: TicketList[] = []; ticketForEdit: any; today: any; uploadUrl: string; url: string; downloadUrl: string; uploadedFiles: any[] = []; data: any[] = []; noteCreator: string; tenancy: boolean = false; hideNew: boolean = false; showAlert: boolean = false; assignedToId: any; assignedTo: any; ticketTypeId: any; ticketStatusId: any; shortDescription: any; description: any; rootCause: string; solution: string; environment: any; parentId: any; ticketStatus: any; selectedType: any; selectedTypeCode: string; selectedAssignedId: number; selectedAssigned: any; selectedTesterUserId: number; selectedStatusId: any; selectedManagerId: any; selectedDeveloperId: any; selectedSupportId: any; selectedParentTicketId: any; selectedUnitId: any; selectedManager: any; selectedDeveloper: any; selectedSupport: any; selectedUnit: any; issueOrBugCode = "ISSUEORBUG" typeTrigger: any hasDownloads: boolean = false; files: File[] = []; notesCreate: Array = []; assignedStatusId: any; attachMents: Array = []; priority: any; open: any; doneStatusId : number; countPublicStatus: number = 0; publicNone: boolean = false; public: boolean = true; publicTrigger: boolean; publicStatus: Array = []; publicSelected: boolean; noteInput: CreateNotes = new CreateNotes(); creator: any; statusClicked: boolean = false; userClicked: boolean = false; createdTime: string; creatorName : string; testerId: any; tester: any; managerId: any; manager: any; developerId: any; developer: any; supportId: any; support: any; parentTicketId: any; unitId: any; unit: any; searchTicketType: boolean; tickeTypeId: any; txtTicketTypeFilter: any; showSearchOnStartTicketType: any; selectedTicketType: any; searchTicketStatus: boolean; txtTicketStatusFilter: any; showSearchOnStartTicketStatus: any; selectedTicketStatus: any; environmentId: string; txtEnvironmentFilter: any; showSearchOnStartEnvironment: any; priorityId: any; txtPriorityFilter: any; showSearchOnStartPriority: any; txtTicketFilter: any; showSearchOnStartTicket: any; txtEffortFilter: any; showSearchOnStartEffort: any; txtVersionFilter: any; showSearchOnStartVersion: any; versionId: any; txtUnitFilter: any; showSearchOnStartUnit: any; txtPublicStatusFilter: any; txtAssignedToFilter: any; txtTesterFilter: any; txtManagerFilter: any; txtDeveloperFilter: any; txtTechnicalSupportFilter: any; showSearchOnStartUser: any; searchField: any; categoryType = []; categoryTypeArray = []; constructor( injector: Injector, private _notifyService: NotifyService, private _userServiceProxy: UserServiceProxy, private _supportTicketServiceProxy: SupportTicketServiceProxy, private _supportTicketStatusServiceProxy: SupportTicketStatusServiceProxy, private _supportTicketTypeServiceProxy: SupportTicketTypeServiceProxy, private _supportCategoryTypeServiceProxy: SupportCategoryTypesServiceProxy, private _tokenAuth: TokenAuthServiceProxy, private _activatedRoute: ActivatedRoute, private _httpClient: HttpClient, private _router: Router, private _location:Location, private route: ActivatedRoute, private _fileDownloadService: FileDownloadService, //private _orderAppService: OrderServiceProxy, //private _incidentTypesService: IncidentTypesServiceProxy, //private _orderIncidentsService : OrderIncidentsServiceProxy, private _appSessionService: AppSessionService, private _versionService : VersionsServiceProxy ) { super(injector); this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/DemoUiComponents/UploadFiles'; this.url = AppConsts.appBaseUrl; } ngOnInit(): void { let maxcount = 1000; var that = this; var re = "sandbox"; var str = this.url; this.route.paramMap.subscribe(params => { this.id = params.get("id") this.open = params.get("open") }); this.creator = this._appSessionService.user.name + ' ' + this._appSessionService.user.surname; this.spinnerService.show() this._supportTicketServiceProxy.getTicketForEdit(this.id).subscribe((result) => { //this.ticketForEdit = result; this.description = result.description; this.rootCause = result.rootCause; this.solution = result.solution; this.parentId = result.parentId; this.shortDescription = result.shortDescription; this.environment = result.environment; this.ticketStatus = result.ticketStatus; this.publicSelected = result.ticketStatusPublic this.ticketTypeId = result.ticketTypeId; this.startDate = moment(result.startDate).toDate(); this.dueDate = moment(result.dueDate).toDate(); this.effortHour = result.effortHour != 0 ? result.effortHour : null; // console.log(this.selectedTypeCode) // this.selectedStatusId = result.ticketStatusId; this.assignedToId = result.assignedToId != 0 ? result.assignedToId : null; this.txtAssignedToFilter = result.assigned; this.ticketStatusId = result.ticketStatusId; this.txtTicketStatusFilter = result.ticketStatus this.testerId = result.testerUserId != 0 ? result.testerUserId : null; this.txtTesterFilter = result.tester; this.managerId = result.managerId; this.txtManagerFilter = result.manager; this.developerId = result.developerId; this.txtDeveloperFilter = result.developer; this.supportId = result.technicalSupportId; this.txtTechnicalSupportFilter = result.technicalSupport; this.parentTicketId = result.parentTicketId; this.unitId = result.organizationalUnitId; this.txtUnitFilter = result.organizationalUnit; this.priorityId = result.priority; this.createdTime = result.createdDateTimeString; this.creatorName = result.creatorName; this.versionId = result.versionId != 0 ? result.versionId : null; this.categoryTypeArray = result.categoryId this.environmentId = this.txtEnvironmentFilter = result.environment; if(result.ticketTypeCode=="EMERGENCYPROTOCOL"){ (document.getElementById('ticketTypesFilter')).style.color="#FF3300"; (document.getElementById('ticketTypesFilter')).style.border="1px solid #FF3300"; }else{ (document.getElementById('ticketTypesFilter')).style.color="#646c9a"; (document.getElementById('ticketTypesFilter')).style.border="1px solid #646c9a"; } // console.log(this.selectedAssignedId) //this.showAllUsers(); //this.showAllTypes(); //this.showAllStatus(); this.getPublicStatusInit(); this.showAllFiles(this.id); this.showAllNotes(this.id); this.getTicketTypesInit(); this.getTicketStatusInit(); this.getEnvironmentInit(); this.getPriorityInit(); this.getCategoryTypesInit(); this.getUserInit(); this.getTicketsInit(); this.getEffortHoursInit(); this.getVersionsInit(); this.getUnitInit(); //this.showOrganizationalUnits(); //this.showAllTickets(); //this.getCategoryTypes(); //this.getEffortHours(); //this.getVersion(); //$('.kt-select2').select2(); this.spinnerService.hide() }); // $('.kt-select2').select2(); //this.getTicketForEdit(this.id); this.today = new Date(); this.noteCreator = this._appSessionService.user.name + ' ' + this._appSessionService.user.surname; if(this._appSessionService.tenant != undefined) { this.tenancy = true; this.hideNew = true; } // $('#assignedInput').change(function() { // //that.selectedStatusId = that.assignedStatusId; // $('#statusInput').val(that.assignedStatusId); // $('#statusInput').trigger('change'); // }); $('#assignedInput').on('change', function() { if($('#assignedInput :selected').val() != "" && that.statusClicked == false){ $('#statusInput').val(that.assignedStatusId); that.userClicked = true $('#statusInput').trigger('change'); } }); $('#statusInput').on('change', function() { if($('#statusInput :selected').val() == that.assignedStatusId && that.userClicked == false){ //that.selectedStatusId = that.assignedStatusId; let sample = $("#assignedInput"); sample.find('option:eq(1)').prop('selected', true) that.statusClicked = true $("#assignedInput").val(sample.val()).change(); // console.log("trigerred") // console.log(sample.val()) // $('#assigned').trigger('change'); } }); $('#typeInput').change(function() { that.typeTrigger = $("#typeInput :selected").val(); // console.log(that.typeTrigger) //that.selectedStatusId = that.assignedStatusId; // $('#statusInput').val(that.assignedStatusId); // $('#statusInput').trigger('change'); }); $('#public').on('change', function() { that.publicTrigger = true; }); this._supportTicketServiceProxy.getStatusIdByCode("ASSIGNED").subscribe(result => { this.doneStatusId = result }) } onSelect(event) { // console.log(event); if(event.rejectedFiles.length != 0) { this.showAlert = true; } this.files.push(...event.addedFiles); let f = event.addedFiles; for (const file of f) { this.getData(file); } } closeAlert() { this.showAlert = false; } onRemove(event) { // console.log(event.name); this.files.splice(this.files.indexOf(event), 1); //this.data.splice(this.data.indexOf(event), 1); _.remove(this.data, function (el) { return el.fileName === event.name; }); } goBack(){ window.location.href='/app/sprintship/support-ticket'; } showAllUsers() : void { //this.active = true; this._supportTicketServiceProxy.getUsersForDropDown().subscribe((result) => { this.users = result.items; }); } 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.DownloadFile(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; } DownloadFile(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 }); }) ); } showAllFiles(id) : void { this._supportTicketServiceProxy.getFiles(id).subscribe((result) => { this.filesDropDown = result.items; if(this.filesDropDown.length != 0) { this.hasDownloads = true; } }); } showAllNotes(id) : void { this._supportTicketServiceProxy.getNotes(id).subscribe((result) => { this.noteList = result.items; }); } showAllTypes() : void { //this.active = true; this._supportTicketTypeServiceProxy.getTicketTypeList().subscribe((result) => { this.ticketTypes = result.items; }); } // showOrganizationalUnits() : void { // this._supportTicketServiceProxy.getOrganizationalUnitsForDropdown().subscribe(result => { // this.organizationUnits = result.items; // }); // } // showAllTickets(): void { // this._supportTicketServiceProxy.getTicketsForDropdown(this.id).subscribe(result => { // this.tickets = result.items; // }) // } showAllStatus() : void { //this.active = true; this._supportTicketStatusServiceProxy.getTicketStatusList().subscribe((result) => { this.ticketStatuses = result.items; for (var i = 0, len = result.items.length; i < len; i++) { if(result.items[i].code == 'ASSIGNED') { this.assignedStatusId = result.items[i].id; } if(result.items[i].isPublic == true) { this.countPublicStatus = ++this.countPublicStatus; this.publicStatus.push(result.items[i]); } } if(this.countPublicStatus > 0) { this.public = false; this.publicNone = true; } }); } save(): void { //console.log(this.createOrderIncident); //alert('yow'); let that = this; this.spinnerService.show() //that.typesId = Number($('#selectedIncidentTypeId').val()); // this.assignedToId = Number($('#assignedInput').val())==0 ? null : Number($('#assignedInput').val()); // this.assignedTo = $('#assignedInput option:selected').text(); // if(this.publicTrigger == true) { // this.ticketStatusId = Number($('#public').val()); // } // else { // this.ticketStatusId = Number($('#statusInput').val()); // } // this.ticketTypeId = Number($('#typeInput').val()); // this.environment = $('#environmentEditInput').val(); // this.priority = Number($('#priorityEditInput').val()); // let checkEffort = $('#effortHours').val(); // if(checkEffort == null || checkEffort == ''){ // let getEffortHour = this.effortHour; // this.effortHour = getEffortHour; // } // else{ // this.effortHour = checkEffort; // } // var testerId = Number($('#tester').val()); // if(isNaN(testerId) || testerId == 0){ // let getTester = this.tester; // let getTesterId = this.testerId; // if(getTesterId == 0){ // this.testerId = null; // this.tester = null; // } // else{ // this.testerId = getTesterId; // this.tester = getTester; // } // } // else{ // this.testerId = testerId; // this.tester = $('#tester option:selected').text(); // } // if (this._appSessionService.tenant == undefined) { // this.manager = Number((document.getElementById('manager')).value) == 0 ? '' : $('#manager option:selected').text(); // this.managerId = Number((document.getElementById('manager')).value) == 0 ? null : Number((document.getElementById('manager')).value); // this.developer = Number((document.getElementById('developer')).value) == 0 ? '' : $('#developer option:selected').text(); // this.developerId = Number((document.getElementById('developer')).value) == 0 ? null : Number((document.getElementById('developer')).value); // this.support = Number((document.getElementById('support')).value) == 0 ? '' : $('#support option:selected').text(); // this.supportId = Number((document.getElementById('support')).value) == 0 ? null : Number((document.getElementById('support')).value); // this.unit = Number((document.getElementById('unit')).value) == 0 ? '' : $('#unit option:selected').text(); // this.unitId = Number((document.getElementById('unit')).value) == 0 ? null : Number((document.getElementById('unit')).value); // this.parentTicketId = Number((document.getElementById('ticket')).value) == 0 ? null : Number((document.getElementById('ticket')).value); // } else { // this.managerId = this.selectedManagerId; // this.manager = this.selectedManager; // this.developerId = this.selectedDeveloperId; // this.developer = this.selectedDeveloper; // this.supportId = this.selectedSupportId; // this.support = this.selectedSupport; // this.parentTicketId = this.selectedParentTicketId; // this.unitId = this.selectedUnitId; // this.unit = this.selectedUnit; // this.assignedTo = this.selectedAssigned; // this.assignedToId = this.selectedAssignedId; // } // var versionId = Number($('#version').val()); // if(isNaN(versionId) || versionId == 0){ // let getVersionId = this.versionId; // if(getVersionId == 0){ // this.versionId = null; // } // else{ // this.versionId = getVersionId; // } // } // else{ // this.versionId = versionId; // } for (let item of this.data) { let a = new CreateAttachments({ fileName: item.fileName, base64EncodedData: item.base64EncodedData, ticketId: null, }); this.attachMents.push(a); } let input = new UpdateTicketDto({ id: this.id, assignedToId: this.assignedToId, ticketTypeId: this.ticketTypeId, ticketStatusId: this.open == null ? this.ticketStatusId : this.doneStatusId, shortDescription: this.shortDescription, assigned: this.assignedToId != null ? this.txtAssignedToFilter : '', description: this.description, rootCause: this.rootCause, solution: this.solution, environment: this.environment, priority: this.priority, startDate: moment(this.startDate), dueDate: moment(this.dueDate), effortHour: this.effortHour == null ? 0 : this.effortHour, createAttachments: this.attachMents, categoryTypeId : this.categoryTypeArray, versionId: this.versionId, testerUserId : this.testerId, tester : this.testerId != null ? this.txtTesterFilter : '', managerId : this.managerId, manager : this.managerId != null ? this.txtManagerFilter : '', developerId : this.developerId, developer : this.developerId != null ? this.txtDeveloperFilter : '', technicalSupportId : this.supportId, technicalSupport : this.supportId != null ? this.txtTechnicalSupportFilter : '', parentTicketId : this.parentTicketId, organizationalUnitId : this.unitId, organizationalUnit : this.unitId != null ? this.txtUnitFilter : '' }); if (moment(this.startDate).format('YYYY-MM-DD') <= moment(this.dueDate).format('YYYY-MM-DD')) { this._supportTicketServiceProxy.updateTicket( input ).pipe().subscribe(result => { if(this.open != null) { this.noteInput.ticketId = this.id; this.noteInput.notes = "Ticket Reopened"; this.noteInput.creator = this.creator; this.noteInput.creationTime = this.today; this._supportTicketServiceProxy.createNote( this.noteInput ).pipe().subscribe(result => { this.attachMents = []; this.files = []; this.data = []; this.notify.info(this.l('SavedSuccessfully')); this.spinnerService.hide(); this.goBack(); }); }else{ this.attachMents = []; this.files = []; this.data = []; this.notify.info(this.l('SavedSuccessfully')); this.spinnerService.hide(); this.goBack(); } // this.files = []; // this.data = []; // this.notify.info(this.l('SavedSuccessfully')); // this.spinnerService.hide(); // this.goBack(); }); } else { this.spinnerService.hide(); this.message.info("Invalid Start and Due Date"); } } updateMyDate(newDate) { this.defaultDate = newDate; } ticketNotes(id): void { this.ticketNotesModal.show(id, false); } onBeforeSend(event): void { event.xhr.setRequestHeader('Authorization', 'Bearer ' + abp.auth.getToken()); } /*getFile(event): void { for (const file of event.files) { this.getData(file); } }*/ /* remove(event): void { //this.data = this.data.filter(item => item = event.file.name); _.remove(this.data, function (el) { return el.fileName === event.file.name; }); console.log(this.data); }*/ getData(file) { var reader:any; let me = this; reader = new FileReader(); reader.readAsDataURL(file); //reader.onload = function () { //me.modelvalue = reader.result; //console.log(reader.result.toString().split(',')[1]); //}; reader.onload = function() { //me.modelvalue = reader.result.toString().split(',')[1]; //me.image.fileName = file.name; //me.image.base64EncodedData = me.modelvalue; me.data.push( { fileName: file.name, base64EncodedData: reader.result.toString().split(',')[1] }); }; reader.onerror = function (error) { // console.log('Error: ', error); }; } reloadPage(): void { //this.paginator.changePage(this.paginator.getPage()); this.ngOnInit(); } deleteRow(id){ //this.notes.splice(index,1); this.message.confirm( '', '', (isConfirmed) => { if (isConfirmed) { this._supportTicketServiceProxy.deleteNote(id) .subscribe(() => { this.reloadPage(); this.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } deleteFile(id) { this.message.confirm( '', '', (isConfirmed) => { if (isConfirmed) { this._supportTicketServiceProxy.deleteAttachment(id) .subscribe(() => { this.reloadPage(); this.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } // getCategoryTypes(){ // this._supportCategoryTypeServiceProxy.getAll(undefined, // undefined, // undefined, // undefined, // undefined, // 0, // undefined, // undefined, // 1000) // .subscribe(result => { // let key, key2, arrAny = {}, arrHolder = []; // for (key in result.items) { // arrAny = { // 'description': result.items[key].supportCategoryTypes.description, // 'id': result.items[key].supportCategoryTypes.id, // 'selected': false // }; // for (key2 in this.defaultCategoryType) { // if (this.defaultCategoryType[key2] == result.items[key].supportCategoryTypes.id) { // arrAny = { // 'description': result.items[key].supportCategoryTypes.description, // 'id': result.items[key].supportCategoryTypes.id, // 'selected': true // }; // // console.log(arrAny) // } // } // arrHolder.push(arrAny); // } // this.categoryTypes = arrHolder // // console.log(this.categoryTypes) // }) // } getEffortHours(){ // this._supportTicketStatusServiceProxy.getEffortHours().subscribe(result =>{ // this.effortHours = result; // }); } // getVersion(){ // this._versionService.getAll(undefined, undefined, undefined, undefined, undefined, undefined, 1000).subscribe(result => { // this.versionList = result.items; // }) // } getTicketTypesInit() { if (this.ticketTypeId != null) { var ticketTypes = this._supportTicketTypeServiceProxy.getTicketTypePagedList(undefined, undefined, undefined, undefined); ticketTypes.subscribe(result => { var types = result.items; var selectedType = types.find(c => c.value == this.ticketTypeId); this.selectTicketType(selectedType); }); } this.ticketTypesList.configure({ title: this.l('Select Ticket Type'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { alert('TEST'); return this._supportTicketTypeServiceProxy.getTicketTypePagedList(filter, undefined, skipCount, maxResultCount); } }); } getTicketTypeList(filter : any) { this.searchTicketType = false; this.ticketTypesList.show(); this.ticketTypesList.filterText = filter; } clearTicketTypeList(){ this.txtTicketTypeFilter = ''; this.ticketTypeId = null; this.showSearchOnStartTicketType = true; } selectTicketType(item) { this.ticketTypeId = item.value; this.txtTicketTypeFilter = item.name; this.showSearchOnStartTicketType = false; if(this.txtTicketTypeFilter=="Emergency Protocol"){ (document.getElementById('ticketTypesFilter')).style.color="#FF3300"; (document.getElementById('ticketTypesFilter')).style.border="1px solid #FF3300"; }else{ (document.getElementById('ticketTypesFilter')).style.color="#646c9a"; (document.getElementById('ticketTypesFilter')).style.border="1px solid #646c9a"; } } getTicketStatusInit() { if (this.ticketStatusId != null) { let input = new GetTicketStatusInput(); input.id = this.ticketStatusId; var ticketStatus = this._supportTicketStatusServiceProxy.ticketStatusPagedList(input); ticketStatus.subscribe(result => { var selectedStatus = result.items[0]; this.selectTicketStatus(selectedStatus); }); } this.ticketStatusList.configure({ title: this.l('Select Ticket Status'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetTicketStatusInput(); input.filter = this.tenancy ? 'New' : filter; input.skipCount = skipCount; input.maxResultCount = maxResultCount; return this._supportTicketStatusServiceProxy.ticketStatusPagedList(input); } }); } getTicketStatusList(filter : any) { this.searchTicketType = false; this.ticketStatusList.show(); this.ticketStatusList.filterText = filter; } clearTicketStatusList(){ this.txtTicketStatusFilter = ''; this.ticketStatusId = null; this.showSearchOnStartTicketStatus = true; } selectTicketStatus(item) { this.ticketStatusId = item.value; this.txtTicketStatusFilter = item.name; this.showSearchOnStartTicketStatus = false; } getPublicStatusInit() { if (this.ticketStatusId != null) { let input = new GetTicketStatusInput(); input.id = this.ticketStatusId; var ticketStatus = this._supportTicketStatusServiceProxy.ticketStatusPagedList(input); ticketStatus.subscribe(result => { var selectedPublicStatus = result.items[0]; this.selectPublicStatus(selectedPublicStatus); }); } this.publicStatusList.configure({ title: this.l('Select Ticket Status'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetTicketStatusInput(); input.isPublicFilter = true; return this._supportTicketStatusServiceProxy.ticketStatusPagedList(input); } }); } getPublicStatusList(filter : any) { this.publicStatusList.show(); this.publicStatusList.filterText = filter; } clearPublicStatusList(){ this.txtPublicStatusFilter = ''; this.ticketStatusId = null; } selectPublicStatus(item) { this.ticketStatusId = item.value; this.txtPublicStatusFilter = item.name; } getEnvironmentInit() { this.environmentList.configure({ title: this.l('Select Environment'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { return this._supportTicketServiceProxy.getEnvironmentTypeList(filter, undefined, skipCount, maxResultCount); } }); } getEnvironmentList(filter : any) { this.environmentList.show(); this.environmentList.filterText = filter; } clearEnvironmentList(){ this.txtEnvironmentFilter = ''; this.environmentId = null; this.showSearchOnStartEnvironment = true; } selectEnvironment(item) { this.environmentId = item.value; this.txtEnvironmentFilter = item.name; this.showSearchOnStartEnvironment = false; } getPriorityInit() { if (this.priorityId != null) { var priority = this._supportTicketServiceProxy.getPriorityTypeList(undefined, undefined, undefined, undefined); priority.subscribe(result => { var prio = result.items; var selectedPriority = prio.find(c => c.value == this.priorityId); this.selectPriority(selectedPriority); }); } this.priorityList.configure({ title: this.l('Select Priority'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { return this._supportTicketServiceProxy.getPriorityTypeList(filter, undefined, skipCount, maxResultCount); } }); } getPriorityList(filter : any) { this.priorityList.show(); this.priorityList.filterText = filter; } clearPriorityList(){ this.txtPriorityFilter = ''; this.priorityId = null; this.showSearchOnStartPriority = true; } selectPriority(item) { this.priorityId = item.value; this.txtPriorityFilter = item.name; this.showSearchOnStartPriority = false; } getCategoryTypesInit() { console.log(this.categoryTypeArray); if (this.categoryTypeArray.length > 0) { var category = this._supportCategoryTypeServiceProxy.getCategoryTypesPagedList(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1000); category.subscribe(result => { var items = result.items; let selectedCategory = []; for (var key in this.categoryTypeArray) { selectedCategory.push(items.find(x => x.value === this.categoryTypeArray[key].toString())); } //var selectedCategory = items.filter(r => this.categoryTypeArray.toString().indexOf(r.value) !== -1); console.log(selectedCategory) this.addCategory(selectedCategory); }); } this.categoryTypesList.configure({ title: this.l('Select Category'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { return this._supportCategoryTypeServiceProxy.getCategoryTypesPagedList(filter, undefined, undefined, undefined, undefined, undefined, undefined, skipCount, maxResultCount); } }); } addCategory(categories: any){ categories.map(c => { this.categoryType.push(c) }) this.categoryTypeArray = this.categoryType.map(c => c.value); } removeCategory(item){ this.categoryType = this.categoryType.filter(c => c.routeCode != item.value); this.categoryTypeArray = this.categoryType.map(c => c.value); } addNewCategory() { this.categoryTypesList.show(this.categoryTypeArray); } getUserInit() { this.userList.configure({ title: this.l('Select User'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetSupportTicketUsersInput(); input.filter = filter; input.maxResultCount = maxResultCount; input.skipCount = skipCount; return this._supportTicketServiceProxy.usersList(input); } }); } getUserList(field : any) { this.searchField = field; let filterText = ''; switch(field) { case 'Assigned': filterText = this.txtAssignedToFilter; break; case 'Tester': filterText = this.txtTesterFilter; break; case 'Manager': filterText = this.txtManagerFilter; break; case 'Developer': filterText = this.txtDeveloperFilter; break; case 'Support': filterText = this.txtTechnicalSupportFilter; break; } this.userList.show(); this.userList.filterText = filterText; } clearUserList(field: string) { switch(field) { case 'Assigned': this.assignedToId = null; this.assignedTo = null; this.txtAssignedToFilter = ''; break; case 'Tester': this.testerId = null; this.tester = null; this.txtTesterFilter = ''; break; case 'Manager': this.managerId = null; this.manager = null; this.txtManagerFilter = ''; break; case 'Developer': this.developerId = null; this.developer = null; this.txtDeveloperFilter = ''; break; case 'Support': this.supportId = null; this.support = null; this.txtTechnicalSupportFilter = ''; break; } this.showSearchOnStartUser = false; } selectUser(item: any) { var resultId = item.value; var name = item.name switch(this.searchField) { case 'Assigned': this.assignedToId = resultId; this.assignedTo = name; this.txtAssignedToFilter = name; break; case 'Tester': this.testerId = resultId; this.tester = name; this.txtTesterFilter = name; break; case 'Manager': this.managerId = resultId; this.manager = name; this.txtManagerFilter = name; break; case 'Developer': this.developerId = resultId; this.developer = name; this.txtDeveloperFilter = name; break; case 'Support': this.supportId = resultId; this.support = name; this.txtTechnicalSupportFilter = name; break; } } getUnitInit() { this.unitList.configure({ title: this.l('Select Unit'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetSupportTicketUsersInput(); input.filter = filter; input.skipCount = skipCount; input.maxResultCount = maxResultCount; return this._supportTicketServiceProxy.organizationalUnitsList(input); } }); } getUnitList(filter : any) { this.unitList.show(); this.unitList.filterText = filter; } clearUnitList(){ this.txtUnitFilter = ''; this.unitId = null; } selectUnit(item) { this.unitId = item.value; this.txtUnitFilter = this.unit = item.name; } getTicketsInit() { if (this.parentTicketId != null) { let input = new GetSupportTicketUsersInput(); input.id = this.parentTicketId; var tickets = this._supportTicketServiceProxy.ticketsList(input); tickets.subscribe(result => { var selectedTicket = result.items[0]; this.selectTicket(selectedTicket); }); } this.ticketList.configure({ title: this.l('Select Ticket'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetSupportTicketUsersInput(); input.filter = filter; input.skipCount = skipCount; input.maxResultCount = maxResultCount; return this._supportTicketServiceProxy.ticketsList(input); } }); } getTicketList(filter : any) { this.ticketList.show(); this.ticketList.filterText = filter; } clearTicketList(){ this.txtTicketFilter = ''; this.parentTicketId = null; this.showSearchOnStartTicket = true; } selectTicket(item) { this.parentTicketId = item.value; this.txtTicketFilter = item.name; this.showSearchOnStartTicket = false; } getEffortHoursInit() { if (this.effortHour != null) { let input = new GetTicketStatusInput(); input.id = this.effortHour; var effortHour = this._supportTicketStatusServiceProxy.effortHoursList(input); effortHour.subscribe(result => { var selectedEffortHour = result.items[0]; this.selectEffortHours(selectedEffortHour); }); } this.effortHourList.configure({ title: this.l('Select Effort'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetTicketStatusInput(); input.filter = filter; input.skipCount = skipCount; input.maxResultCount = maxResultCount; return this._supportTicketStatusServiceProxy.effortHoursList(input); } }); } getEffortHoursList(filter : any) { this.effortHourList.show(); this.effortHourList.filterText = filter; } clearEffortHoursList(){ this.txtEffortFilter = ''; this.effortHour = null; this.showSearchOnStartEffort = true; } selectEffortHours(item) { this.effortHour = item.value; this.txtEffortFilter = item.name; this.showSearchOnStartEffort = false; } getVersionsInit() { if (this.versionId != null) { let input = new GetAllVersionsInput(); input.id = this.versionId; var versions = this._versionService.versionPagedList(input); versions.subscribe(result => { var selectedVersion = result.items[0]; this.selectVersion(selectedVersion); }); } this.versionList.configure({ title: this.l('Select Version'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?: number) => { let input = new GetAllVersionsInput(); input.filter = filter; input.skipCount = skipCount; input.maxResultCount = maxResultCount; return this._versionService.versionPagedList(input); } }); } getVersionList(filter : any) { this.versionList.show(); this.versionList.filterText = filter; } clearVersionList(){ this.txtVersionFilter = ''; this.versionId = null; this.showSearchOnStartVersion = true; } selectVersion(item) { this.versionId = item.value; this.txtVersionFilter = item.name; this.showSearchOnStartVersion = false; } }