import { Component, Injector, ViewEncapsulation, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { ReportServiceProxy, ReportList, UserServiceProxy, UserListDto } 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 { 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 { 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'; @Component({ templateUrl: './report.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()] }) export class ReportComponent extends AppComponentBase { @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; advancedFiltersAreShown = false; filterText = ''; filterName = ''; modifiedByFilter: any; createdByFilter: any; createdFrom: any; createdTo: any; modifiedFrom: any; modifiedTo: any; update: Array = []; users: Array<{ id: number, name: string, surname: string }> = new Array(); creatorId: any; public modifiedDateRange: moment.Moment[] = null; public createdDateRange: moment.Moment[] = null; constructor( injector: Injector, private _reportServiceProxy: ReportServiceProxy, private _notifyService: NotifyService, private _tokenAuth: TokenAuthServiceProxy, private _activatedRoute: ActivatedRoute, private _router: Router ) { super(injector); } ngOnInit(): void { //this.entityHistoryEnabled = this.setIsEntityHistoryEnabled(); $('.kt-select2').select2(); this.showAllUsers(); } getReport(event?: LazyLoadEvent) { //if (this.primengTableHelper.shouldResetPaging(event)) { //this.paginator.changePage(0); //return; //} //this.primengTableHelper.showLoadingIndicator(); this.createdByFilter = Number((document.getElementById('createdByFilter')).value) != 0 ? Number((document.getElementById('createdByFilter')).value) : undefined; this.modifiedByFilter = Number((document.getElementById('modifiedByFilter')).value) != 0 ? Number((document.getElementById('modifiedByFilter')).value) : undefined; this.spinnerService.show(); this._reportServiceProxy.getReports( this.filterText, this.filterName, this.createdDateRange == null ? undefined : this.createdDateRange[0], this.createdDateRange == null ? undefined : this.createdDateRange[1].endOf('day'), this.modifiedDateRange == null ? undefined : this.modifiedDateRange[0], this.modifiedDateRange == null ? undefined : this.modifiedDateRange[1].endOf('day'), this.createdByFilter, this.modifiedByFilter, this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getSkipCount(this.paginator, event), this.primengTableHelper.getMaxResultCount(this.paginator, event) ).subscribe(result => { this.primengTableHelper.totalRecordsCount = result.totalCount; this.primengTableHelper.records = result.items; console.log(result); //this.primengTableHelper.hideLoadingIndicator(); this.spinnerService.hide(); }); } reloadPage(): void { //this.paginator.changePage(this.paginator.getPage()); this.getReport(); } createOrEditReport(url: any, name?: string){ if(name != null){ var myurl = `${url}/${name}`; }else{ var myurl = `${url}`; } console.log(myurl); this._router.navigateByUrl(myurl); } redirectUrl(url: any, name?: string){ if(name != null){ var myurl = `${url}/${name}`; }else{ var myurl = `${url}`; } console.log(myurl); this._router.navigateByUrl(myurl); } delete(id): void { this.message.confirm( '', '', (isConfirmed) => { if (isConfirmed) { this._reportServiceProxy.delete(id) .subscribe(() => { this.reloadPage(); this.notify.success(this.l('SuccessfullyDeleted')); }); } } ); } showAllUsers() : void { //this.active = true; this._reportServiceProxy.getUsersForDropDownReport().subscribe((result) => { result.forEach(element => { this.users.push(element); }); }); } }