|
|
@@ -9,6 +9,7 @@ import { FilterNotificate, RequestNotificate, ResponseDataFilterNotificate } fro
|
|
|
import { UsersProfilesService } from '../../../../services/users-profiles.service';
|
|
|
import { ProcessManagementService } from '../../../../services/process-management/process-management.service';
|
|
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
|
+import { EncService } from '../../../../services/enc.service';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-search-notificate',
|
|
|
@@ -21,8 +22,7 @@ export class SearchNotificateComponent implements OnInit {
|
|
|
public isLoading: boolean;
|
|
|
|
|
|
public arrUsers: UserResponse[];
|
|
|
- public arrUsersStr: string[];
|
|
|
- public filteredOptionsUser!: Observable<string[]>;
|
|
|
+ public estadosNotificacion = ['Leido', 'No leido'];
|
|
|
|
|
|
constructor(
|
|
|
public resourcesService: ResourcesService,
|
|
|
@@ -30,19 +30,17 @@ export class SearchNotificateComponent implements OnInit {
|
|
|
private _dialogReg: MatDialogRef<false | FilterNotificate[]>,
|
|
|
private _usersProfilesService: UsersProfilesService,
|
|
|
private _processManagementService: ProcessManagementService,
|
|
|
+ private _encService: EncService,
|
|
|
) {
|
|
|
this.formGroup = this._createFormGroup();
|
|
|
this.isLoading = false;
|
|
|
|
|
|
this.arrUsers = [];
|
|
|
- this.arrUsersStr = [];
|
|
|
}
|
|
|
|
|
|
private _createFormGroup(): FormGroup {
|
|
|
return new FormGroup({
|
|
|
- NUMERO_NOTIFICACION: new FormControl(null, Validators.min(1)),
|
|
|
- USUARIO_NOTIFICADO: new FormControl(null),
|
|
|
- TIPO_NOTIFICACION: new FormControl(null),
|
|
|
+ USUARIOS_NOTIFICADOS: new FormControl([]),
|
|
|
ESTADO_NOTIFICACION: new FormControl(null),
|
|
|
FECHA_INICIO: new FormControl<Date | null>(null),
|
|
|
FECHA_FINAL: new FormControl<Date | null>(null),
|
|
|
@@ -54,25 +52,21 @@ export class SearchNotificateComponent implements OnInit {
|
|
|
await this._getUsers();
|
|
|
this.isLoading = false;
|
|
|
|
|
|
- this.filteredOptionsUser = this.formGroup.controls['USUARIO_NOTIFICADO'].valueChanges.pipe(
|
|
|
- startWith(''),
|
|
|
- map( value => {
|
|
|
- value = value === null || value === undefined ? '' : value;
|
|
|
- const filterValue = value.toLowerCase();
|
|
|
- return this.arrUsersStr.filter(option => option.toLowerCase().includes(filterValue));
|
|
|
- })
|
|
|
- )
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private async _getUsers() {
|
|
|
const user: string = this.resourcesService.getUser();
|
|
|
const line: number = this.resourcesService.getLineNumber();
|
|
|
await lastValueFrom(this._usersProfilesService.getUsers(user, line)).then(
|
|
|
- (responseData: UsersResponse) => {
|
|
|
+ async (responseData: UsersResponse) => {
|
|
|
if (!responseData.error) {
|
|
|
+ for (let index = 0; index < responseData.response.length; index++) {
|
|
|
+ let element = responseData.response[index];
|
|
|
+ element.IDUSUARIO = await this._encService.decrypt(element.IDUSUARIO);
|
|
|
+ responseData.response[index] = element;
|
|
|
+ }
|
|
|
this.arrUsers = responseData.response;
|
|
|
- this.arrUsersStr = responseData.response.map((userResponse: UserResponse) =>
|
|
|
- `${userResponse.NOMBRE} ${userResponse.APEPAT}${userResponse.APEMAT === null || userResponse.APEMAT === undefined || userResponse.APEMAT === '' ? '' : ` ${userResponse.APEMAT}` } (${userResponse.IDUSUARIO})`);
|
|
|
} else {
|
|
|
this.resourcesService.openSnackBar(`${responseData.msg}`);
|
|
|
}
|
|
|
@@ -86,45 +80,18 @@ export class SearchNotificateComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
public async search() {
|
|
|
- let numeroNotificacion = this.formGroup.controls['NUMERO_NOTIFICACION'].value;
|
|
|
- if (numeroNotificacion !== null && numeroNotificacion !== undefined && numeroNotificacion !== '') {
|
|
|
- numeroNotificacion = parseInt(numeroNotificacion);
|
|
|
- if ( numeroNotificacion <= 0 ) {
|
|
|
- this.resourcesService.openSnackBar(`Ocurrió un error con el formato del número de notificación.`);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (numeroNotificacion % 1 !== 0) {
|
|
|
- this.resourcesService.openSnackBar(`El número de notificación debe ser un número entero.`);
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- numeroNotificacion = null;
|
|
|
- }
|
|
|
-
|
|
|
- let usuarioNotificado = this.formGroup.controls['USUARIO_NOTIFICADO'].value;
|
|
|
- if (usuarioNotificado !== null && usuarioNotificado !== undefined && usuarioNotificado !== '') {
|
|
|
- usuarioNotificado = usuarioNotificado.toString().trim();
|
|
|
- if ( !usuarioNotificado.includes('(') || !usuarioNotificado.includes(')') ) {
|
|
|
- this.resourcesService.openSnackBar(`Debe elegir una opción de la lista desplegable en el campo del usuario notificado.`);
|
|
|
- return;
|
|
|
- }
|
|
|
- usuarioNotificado = usuarioNotificado.split('(')[1].split(')')[0];
|
|
|
- } else {
|
|
|
- usuarioNotificado = null;
|
|
|
- }
|
|
|
-
|
|
|
- let tipoNotificacion = this.formGroup.controls['TIPO_NOTIFICACION'].value;
|
|
|
- if (tipoNotificacion !== null && tipoNotificacion !== undefined && tipoNotificacion !== '') {
|
|
|
- tipoNotificacion = tipoNotificacion.toString().trim();
|
|
|
+ let usuariosNotificados = this.formGroup.controls['USUARIOS_NOTIFICADOS'].value;
|
|
|
+ if (usuariosNotificados && usuariosNotificados.length > 0) {
|
|
|
+ usuariosNotificados = usuariosNotificados;
|
|
|
} else {
|
|
|
- tipoNotificacion = null;
|
|
|
+ usuariosNotificados = null;
|
|
|
}
|
|
|
|
|
|
- let estadoNotificacion = this.formGroup.controls['ESTADO_NOTIFICACION'].value;
|
|
|
- if (estadoNotificacion !== null && estadoNotificacion !== undefined && estadoNotificacion !== '') {
|
|
|
- estadoNotificacion = estadoNotificacion.toString().trim();
|
|
|
+ let estado = this.formGroup.controls['ESTADO_NOTIFICACION'].value;
|
|
|
+ if (estado !== null && estado !== undefined && estado !== '') {
|
|
|
+ estado = estado.toString().trim();
|
|
|
} else {
|
|
|
- estadoNotificacion = null;
|
|
|
+ estado = null;
|
|
|
}
|
|
|
|
|
|
let fechaInicio = this.formGroup.controls['FECHA_INICIO'].value;
|
|
|
@@ -154,12 +121,10 @@ export class SearchNotificateComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
const REQUEST_NOTIFICATE: RequestNotificate = {
|
|
|
- 'NUMERO_NOTIFICACION': numeroNotificacion,
|
|
|
- 'USUARIO_NOTIFICACION': usuarioNotificado,
|
|
|
- 'TIPO_NOTIFICACION': tipoNotificacion,
|
|
|
- 'ESTADO_NOTIFICACION': estadoNotificacion,
|
|
|
+ 'USUARIOS_NOTIFICADOS': usuariosNotificados,
|
|
|
+ 'ESTADO': estado,
|
|
|
'FECHA_INICIO': fechaInicio,
|
|
|
- 'FECHA_FINAL': fechaFinal,
|
|
|
+ 'FECHA_FIN': fechaFinal,
|
|
|
'USUARIO': this.resourcesService.getUser(),
|
|
|
'NUMERO_LINEA': this.resourcesService.getLineNumber(),
|
|
|
}
|