60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
|
|
import { USER_RIGHTS } from 'src/app/shared/enums/USER_RIGHTS.enum';
|
|
import { Page } from 'src/app/shared/models/paging/page.interface';
|
|
import { SystemException } from 'src/app/shared/models/system-exception.interface';
|
|
import { AuthService } from 'src/app/shared/services/auth.service';
|
|
import { ApplicationLevelExceptionService } from 'src/app/shared/services/administration/application-level-exception.service';
|
|
import { ErrorHandlingService } from 'src/app/shared/services/error-handling/error-handling.service';
|
|
import { environment } from 'src/environments/environment';
|
|
import { ApplicationLevelFormComponent } from '../../forms/application-level-form/application-level-form.component';
|
|
|
|
@Component({
|
|
selector: 'app-application-level-search-form',
|
|
templateUrl: './application-level-search-form.component.html',
|
|
styleUrls: ['./application-level-search-form.component.scss']
|
|
})
|
|
export class ApplicationLevelSearchFormComponent implements OnInit {
|
|
|
|
@Input() set paginationEventRequest(value: { page: number, offset: number }) {
|
|
|
|
// This setter may be called on page setup without arguments.
|
|
if (!value) {
|
|
return;
|
|
}
|
|
// this._value = Object.assign(value);
|
|
this.search(value.page, value.offset);
|
|
}
|
|
|
|
@Output() searchResults = new EventEmitter<Page<SystemException>>();
|
|
@Output() loading = new EventEmitter<boolean>();
|
|
@ViewChild(ApplicationLevelFormComponent)
|
|
private searchCriteriaForm: ApplicationLevelFormComponent;
|
|
_value : {page: number , offset: number};
|
|
|
|
constructor(private applicationLevelService: ApplicationLevelExceptionService,private errorHandlingService: ErrorHandlingService, private auth: AuthService) { }
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
search(pageNumber = 0, pageSize = 10) {
|
|
this.loading.emit(true);
|
|
this.applicationLevelService.searchByCriteriaPaged(pageNumber, pageSize, this.searchCriteriaForm?.formValue(), 'search').subscribe((results: Page<SystemException>) => {
|
|
this.searchResults.emit(results);
|
|
this.loading.emit(false);
|
|
},
|
|
err => {
|
|
this.errorHandlingService.showHttpResponseError(err)
|
|
this.loading.emit(false);
|
|
});
|
|
}
|
|
|
|
canPreviewLevelExceptions(): boolean {
|
|
return this.auth.userHasRightForClient(USER_RIGHTS.K01, environment.globalRightsClientID);
|
|
}
|
|
|
|
clear() {
|
|
this.searchCriteriaForm.resetForm();
|
|
}
|
|
|
|
}
|