import { Component, Injector, ViewEncapsulation, ViewChild, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { RouteGenerationSettingsServiceProxy, CreateOrEditRouteGenerationSettingDto } 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 { appModuleAnimation } from '@shared/animations/routerTransition'; import { Table } from 'primeng/components/table/table'; import { Paginator } from 'primeng/components/paginator/paginator'; import { FileDownloadService } from '@shared/utils/file-download.service'; import * as _ from 'lodash'; declare var KTWizard: any; declare let swal: any; @Component({ templateUrl: './routeGenerationSettings.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()] }) export class RouteGenerationSettingsComponent extends AppComponentBase implements OnInit { @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; advancedFiltersAreShown = false; noOfDays: number; isFutureFilter: boolean = false; saving: boolean; settings: CreateOrEditRouteGenerationSettingDto = new CreateOrEditRouteGenerationSettingDto(); constructor( injector: Injector, private _routeGenerationSettingsServiceProxy: RouteGenerationSettingsServiceProxy, private _notifyService: NotifyService, private _tokenAuth: TokenAuthServiceProxy, private _activatedRoute: ActivatedRoute, private _fileDownloadService: FileDownloadService ) { super(injector); } ngOnInit() { this.getRouteGenSettings(); } getRouteGenSettings() { this._routeGenerationSettingsServiceProxy.getRouteGenerationSettingForEdit().subscribe((result) => { if (result.routeGenerationSetting != null) { this.isFutureFilter = result.routeGenerationSetting.isFuture; this.noOfDays = result.routeGenerationSetting.noOfDays; } }); } reloadPage(): void { this.paginator.changePage(this.paginator.getPage()); } save() { if (this.isFutureFilter && this.noOfDays == null) { this.message.error('No Of Days is empty'); return; } if (this.isFutureFilter && this.noOfDays <= 0) { this.message.error('No Of Days must be greater than 0'); return; } this.saving = true; this.spinnerService.show(); this.settings.isFuture = this.isFutureFilter; this.settings.noOfDays = this.noOfDays; this._routeGenerationSettingsServiceProxy .createOrEdit(this.settings) .pipe() .subscribe((result) => { this.getRouteGenSettings(); this.saving = false; this.spinnerService.hide(); this.notify.success('Saved Successfully'); }); } }