import { Component, Injector, ViewChild, OnInit, ElementRef } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { RoleListDto, RoleServiceProxy, SubAppServiceProxy, SubAppDto, DictionariesServiceProxy } from '@shared/service-proxies/service-proxies'; import { Table } from 'primeng/components/table/table'; import { EntityTypeHistoryModalComponent } from '@app/shared/common/entityHistory/entity-type-history-modal.component'; import * as _ from 'lodash'; import { finalize } from 'rxjs/operators'; import { LazyLoadEvent } from 'primeng/api'; import { Paginator } from 'primeng/primeng'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { CreateOrEditDictionaryModalComponent } from './create-or-edit-dictionary-modal.component'; @Component({ templateUrl: './dictionary.component.html', animations: [appModuleAnimation()] }) export class DictionaryComponent extends AppComponentBase implements OnInit { @ViewChild('createOrEditDictionaryModal') createOrEditDictionaryModal: CreateOrEditDictionaryModalComponent; @ViewChild('entityTypeHistoryModal') entityTypeHistoryModal: EntityTypeHistoryModalComponent; @ViewChild('dataTable') dataTable: Table; @ViewChild('paginator') paginator: Paginator; advancedFiltersAreShown = false; //Filters selectedPermission = ''; filterText = ''; filterCode = ''; filterName = ''; filterValue = ''; filterDesc = ''; dictionaryTypeList; selectDicType; constructor( injector: Injector, private _dictionaryService: DictionariesServiceProxy, private _fileDownloadService: FileDownloadService ) { super(injector); } ngOnInit(): void { } getSubApps(event?: LazyLoadEvent): void { if (this.primengTableHelper.shouldResetPaging(event)) { this.paginator.changePage(0); return; } this._dictionaryService.getDictionaryType().subscribe(result => { this.dictionaryTypeList = result; console.log(result); }); this.primengTableHelper.showLoadingIndicator(); this._dictionaryService.getAll( this.filterText, this.selectDicType, this.filterCode, this.filterName, this.filterValue, this.filterDesc, this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getSkipCount(this.paginator, event), this.primengTableHelper.getMaxResultCount(this.paginator, event) ).pipe(finalize(() => this.primengTableHelper.hideLoadingIndicator())).subscribe(result => { this.primengTableHelper.totalRecordsCount = result.totalCount; this.primengTableHelper.records = result.items; this.primengTableHelper.hideLoadingIndicator(); }); } exportToExcel(): void { this._dictionaryService.getDictionariesToExcel( this.filterText, this.selectDicType, this.filterCode, this.filterName, this.filterValue, this.filterDesc) .subscribe(result => { this._fileDownloadService.downloadTempFile(result); }); } createSubApp(): void { this.createOrEditDictionaryModal.show(); } deleteSubApp(subapp: SubAppDto): void { let self = this; self.message.confirm('', isConfirmed => { if (isConfirmed) { this._dictionaryService.delete(subapp.id).subscribe(() => { this.getSubApps(); abp.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } }