import { Component, Injector, ViewChild, OnInit } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { SubAppServiceProxy, RackIdServiceProxy } from '@shared/service-proxies/service-proxies'; import { Table } from 'primeng/components/table/table'; import * as _ from 'lodash'; import { LazyLoadEvent } from 'primeng/api'; import { Paginator } from 'primeng/primeng'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { SelfHttp } from '@app/shared/common/utils/selfHttp.service'; import { CreateOrEditRackIdModalComponent } from './create-or-edit-rackid-modal.component'; import { RackTypeLookupTableModalComponent } from '@app/shared/lookup/rackTypeLookup/rackType-lookup-table-modal.component'; import { RackAreaLookupTableModalComponent } from '@app/shared/lookup/rackAreaLookup/rackArea-lookup-table-modal.component'; import { RackIdLookupTableModalComponent } from '@app/shared/lookup/rackIdLookup/rackId-lookup-table-modal.component'; @Component({ templateUrl: './rackid.component.html', animations: [appModuleAnimation()] }) export class RackIdComponent extends AppComponentBase implements OnInit { @ViewChild('dataTable') dataTable: Table; @ViewChild('paginator') paginator: Paginator; @ViewChild('createOrEditRackIdModal') createOrEditRackIdModal: CreateOrEditRackIdModalComponent; @ViewChild('rackTypeLookupTableModal') rackTypeLookupTableModal: RackTypeLookupTableModalComponent; @ViewChild('rackAreaLookupTableModal') rackAreaLookupTableModal: RackAreaLookupTableModalComponent; @ViewChild('rackIdLookupTableModal') rackIdLookupTableModal: RackIdLookupTableModalComponent; advancedFiltersAreShown = false; //Filters selectedPermission = ''; filterText = ''; filterRackType = ''; filterRackArea = ''; filterRackId = ''; rackType = ''; rackArea = ''; rackId = '' ; Sort = ''; constructor( injector: Injector, private _rackIdService: RackIdServiceProxy, private _fileDownloadService: FileDownloadService, private selfHttp: SelfHttp ) { super(injector); } ngOnInit(): void { } getAll(event?: LazyLoadEvent): void { if (this.primengTableHelper.shouldResetPaging(event)) { this.paginator.changePage(0); return; } let data = { Filter: this.filterText, RackType: this.rackType, RackArea: this.rackArea, RackId: this.rackId, Sort: this.primengTableHelper.getSorting(this.dataTable) ? this.primengTableHelper.getSorting(this.dataTable) : '', PageSize: this.primengTableHelper.getMaxResultCount(this.paginator, event), PageIndex: this.primengTableHelper.getSkipCount(this.paginator, event) }; this.selfHttp.get('api/RackIdManage/RackIdGetAll', data, res => { //20221026 Modify let result = JSON.parse(res); if (result.result.length > 0) { this.primengTableHelper.totalRecordsCount = result.total; } else { this.primengTableHelper.totalRecordsCount = 0; } this.primengTableHelper.records = result.result; //if (res.result.length > 0) { //this.primengTableHelper.totalRecordsCount = res.total; //} else { // this.primengTableHelper.totalRecordsCount = 0; //} //this.primengTableHelper.records = res.result; }); } exportToExcel(): void { this._rackIdService.getRackIdToExcel( this.filterText, this.primengTableHelper.getSorting(this.dataTable), this.filterRackType, this.filterRackArea, this.filterRackId) .subscribe(result => { this._fileDownloadService.downloadTempFile(result); }); } createSubApp(): void { this.createOrEditRackIdModal.show(); } deleteRackArea(data: any): void { let self = this; self.message.confirm('', isConfirmed => { if (isConfirmed) { this.selfHttp.delete('api/RackIdManage/DeleteRackId', { RackType: data.RACKTYPE, RackArea: data.RACKAREA, RackId: data.RACKID }, () => { this.getAll(); abp.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } openSelectRackTypeModal() { this.rackTypeLookupTableModal.rackType = this.rackType; this.rackTypeLookupTableModal.show(); } openSelectRackAreaModal() { this.rackAreaLookupTableModal.filterRackType = this.rackType; this.rackAreaLookupTableModal.rackArea = this.rackArea; this.rackAreaLookupTableModal.show(); } openSelectRackIdModal() { this.rackIdLookupTableModal.filterRackType = this.rackType; this.rackIdLookupTableModal.filterRackArea = this.rackArea; this.rackIdLookupTableModal.rackId = this.rackId; this.rackIdLookupTableModal.show(); } setRackTypeNull() { this.rackType = ''; } setRackAreaNull() { this.rackArea = ''; } setRackIdNull() { this.rackId = ''; } getNewRackType() { this.rackType = this.rackTypeLookupTableModal.rackType; } getNewRackArea() { this.rackArea = this.rackAreaLookupTableModal.rackArea; } getNewRackId() { this.rackId = this.rackIdLookupTableModal.rackId; } }