import { Component, Injector, OnInit, Output, EventEmitter, AfterViewInit, ViewChild } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { CachedRequestSettingServiceProxy, GetCachedRequestSettingListItemDto } from '@shared/service-proxies/service-proxies'; import { AddMobileAppRequestSettingModalComponent } from './add-mobile-app-request-setting-modal.component'; @Component({ selector: 'mobile-app-request-settings', templateUrl: './mobile-app-request-settings.component.html', animations: [appModuleAnimation()], providers: [CachedRequestSettingServiceProxy] }) export class MobileAppRequestSettingsComponent extends AppComponentBase implements OnInit, AfterViewInit { displayItems: Array = []; @Output() showLoaderEvent = new EventEmitter(); @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; @ViewChild('addMobileAppRequestSettingModalComponent', { static: true }) addMobileAppRequestSettingModalComponent: AddMobileAppRequestSettingModalComponent; constructor( injector: Injector, private _cachedRequestSettingServiceProxy: CachedRequestSettingServiceProxy ) { super(injector); } ngOnInit(): void { } ngAfterViewInit(): void { } showCreateDialog(record?: GetCachedRequestSettingListItemDto): void { this.addMobileAppRequestSettingModalComponent.show(record); } deleteRecord(record?: GetCachedRequestSettingListItemDto): void { if (record) { this.showLoaderEvent.emit(true); this._cachedRequestSettingServiceProxy.deleteCachedRequestSetting(record.apiRequestCode) .subscribe(result => { this.showLoaderEvent.emit(false); this.getSettingsFromApi(null); }); } } getSettingsFromApi(event?: LazyLoadEvent): void { this.showLoaderEvent.emit(true); this._cachedRequestSettingServiceProxy.getCachedRequestSettings( this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getMaxResultCount(this.paginator, event), this.primengTableHelper.getSkipCount(this.paginator, event) ) .subscribe(result => { this.primengTableHelper.totalRecordsCount = result.totalCount; this.displayItems = []; if (result.items) { this.displayItems = result.items; } this.showLoaderEvent.emit(false); }); } }