Преглед изворни кода

cambio de colores y etiquetas de colores

EmilianoOrtiz пре 3 недеља
родитељ
комит
c86883cd84

+ 2 - 2
src/app/components/process-management/multicriteria-searches/multicriteria-searches.component.html

@@ -57,7 +57,7 @@
                 <ng-container matColumnDef="ESTADO_SOLICITUD">
                   <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('estado_solicitud') }} </th>
                   <td mat-cell *matCellDef="let element">
-                    <mat-chip [class]="resourcesService.setChipList(element.ESTADO_SOLICITUD)" selected> {{ element.ESTADO_SOLICITUD }} </mat-chip>
+                    <button mat-flat-button [class]="resourcesService.setChipList(element.ESTADO_SOLICITUD)" class="white_font"> {{ element.ESTADO_SOLICITUD }} </button>
                   </td>
                 </ng-container>
                 <ng-container matColumnDef="FECHA_RESOLUCION">
@@ -185,7 +185,7 @@
                 <ng-container matColumnDef="ESTADO_WORKFLOW">
                   <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('estado_workflow') }} </th>
                   <td mat-cell *matCellDef="let element">
-                    <mat-chip [class]="resourcesService.setChipList(element.ESTADO_WORKFLOW)" selected> {{ element.ESTADO_WORKFLOW }} </mat-chip>
+                    <button mat-flat-button [class]="resourcesService.setChipList(element.ESTADO_WORKFLOW)" class="white_font"> {{ element.ESTADO_WORKFLOW }} </button>
                   </td>
                 </ng-container>
                 <ng-container matColumnDef="USUARIO_REGISTRO">

+ 205 - 98
src/app/services/resources.service.ts

@@ -9,30 +9,48 @@ import { RequestUserNumberLine } from '../interfaces/response-data';
 import { lastValueFrom } from 'rxjs';
 
 @Injectable({
-  providedIn: 'root'
+  providedIn: 'root',
 })
 export class ResourcesService {
   arrMonth: Array<string>;
   arrMonthLabel: Array<string>;
   weekDay: Array<any>;
   weekDays: Array<string>;
-  
+
   constructor(
     private _encService: EncService,
     private _matSnackBar: MatSnackBar,
     private _router: Router,
-    private _httpClient: HttpClient,
+    private _httpClient: HttpClient
   ) {
     this.arrMonth = [
-      '01', '02', '03', '04',
-      '05', '06', '07', '08',
-      '09', '10', '11', '12'
+      '01',
+      '02',
+      '03',
+      '04',
+      '05',
+      '06',
+      '07',
+      '08',
+      '09',
+      '10',
+      '11',
+      '12',
     ];
 
     this.arrMonthLabel = [
-      'Enero','Febrero','Marzo','Abril',
-      'Mayo','Junio','Julio','Agosto',
-      'Septiembre','Octubre','Noviembre','Diciembre'
+      'Enero',
+      'Febrero',
+      'Marzo',
+      'Abril',
+      'Mayo',
+      'Junio',
+      'Julio',
+      'Agosto',
+      'Septiembre',
+      'Octubre',
+      'Noviembre',
+      'Diciembre',
     ];
 
     this.weekDay = [
@@ -42,75 +60,108 @@ export class ResourcesService {
       { week: 'Miércoles', acronym: 'Mié' },
       { week: 'Jueves', acronym: 'Jue' },
       { week: 'Viernes', acronym: 'Vie' },
-      { week:  'Sábado', acronym: 'Sáb' }
+      { week: 'Sábado', acronym: 'Sáb' },
     ];
 
-    this.weekDays = ['Domingos', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábados'];
+    this.weekDays = [
+      'Domingos',
+      'Lunes',
+      'Martes',
+      'Miércoles',
+      'Jueves',
+      'Viernes',
+      'Sábados',
+    ];
   }
 
   public checkErrors(httpErrorResponse: HttpErrorResponse) {
     console.log(httpErrorResponse);
 
-    if (httpErrorResponse.ok === false && httpErrorResponse.error.hasOwnProperty('error')) {
+    if (
+      httpErrorResponse.ok === false &&
+      httpErrorResponse.error.hasOwnProperty('error')
+    ) {
       let responseData: ResponseData = httpErrorResponse.error;
       if (responseData.error) {
-
-        if (typeof(responseData.response) === 'object') {
+        if (typeof responseData.response === 'object') {
           const KEYS: Array<string> = Object.keys(responseData.response);
 
           if (KEYS.length > 0) {
             const DATAERROR: string = KEYS.toString().replace(',', ', ').trim();
-            this.openSnackBar(`Ocurrió un error en ${ KEYS.length > 1 ? 'los campos' : 'el campo'} ${DATAERROR}`);
+            this.openSnackBar(
+              `Ocurrió un error en ${
+                KEYS.length > 1 ? 'los campos' : 'el campo'
+              } ${DATAERROR}`
+            );
           } else {
             console.log('test');
             if (responseData.msg.includes('ERR_GLB_USU003')) {
-              return { reload: true }
+              return { reload: true };
             }
             this.openSnackBar(`${responseData.msg}`);
           }
-
-        } else if (typeof(responseData.response) === 'string'){
+        } else if (typeof responseData.response === 'string') {
           this.openSnackBar(`${responseData.msg} (${responseData.response})`);
         } else {
-          this.openSnackBar('Ha ocurrido un error inesperado, favor de comunicarse con el departamento de TI.');
+          this.openSnackBar(
+            'Ha ocurrido un error inesperado, favor de comunicarse con el departamento de TI.'
+          );
         }
       } else {
         this.openSnackBar(`${responseData.msg}`);
       }
-    } else if (httpErrorResponse.ok === false && httpErrorResponse.error.hasOwnProperty('message') && httpErrorResponse.error.hasOwnProperty('exception')) {
+    } else if (
+      httpErrorResponse.ok === false &&
+      httpErrorResponse.error.hasOwnProperty('message') &&
+      httpErrorResponse.error.hasOwnProperty('exception')
+    ) {
       const errorException: ResponseErrorException = httpErrorResponse.error;
       const arrController: Array<string> = errorException.file.split('\\');
-      const controller: string = arrController[arrController.length-1];
-      this.openSnackBar(`Ocurrió un error inesperado: ${errorException.message} en ${controller}:${errorException.line}`);
-    } else if (httpErrorResponse.message.includes("Http failure response for") && httpErrorResponse.statusText === "Unknown Error") {
-      this.openSnackBar('No fue posible conectar con el servidor del SAM, favor de contactar al departamento de TI.');
-    } else if (httpErrorResponse.status == 408){
-      this.openSnackBar('Su conexión no fue apta para conectar con los servidores del SAM.');
+      const controller: string = arrController[arrController.length - 1];
+      this.openSnackBar(
+        `Ocurrió un error inesperado: ${errorException.message} en ${controller}:${errorException.line}`
+      );
+    } else if (
+      httpErrorResponse.message.includes('Http failure response for') &&
+      httpErrorResponse.statusText === 'Unknown Error'
+    ) {
+      this.openSnackBar(
+        'No fue posible conectar con el servidor del SAM, favor de contactar al departamento de TI.'
+      );
+    } else if (httpErrorResponse.status == 408) {
+      this.openSnackBar(
+        'Su conexión no fue apta para conectar con los servidores del SAM.'
+      );
     } else {
-      this.openSnackBar('Ocurrió un error inesperado, favor de contactar al departamento de TI.');
+      this.openSnackBar(
+        'Ocurrió un error inesperado, favor de contactar al departamento de TI.'
+      );
     }
 
-    return null
+    return null;
   }
 
   public checkErrorsStr(httpErrorResponse: HttpErrorResponse): string {
     console.log(httpErrorResponse);
 
-    if (httpErrorResponse.ok === false && httpErrorResponse.error.hasOwnProperty('error')) {
+    if (
+      httpErrorResponse.ok === false &&
+      httpErrorResponse.error.hasOwnProperty('error')
+    ) {
       let responseData: ResponseData = httpErrorResponse.error;
       if (responseData.error) {
-
-        if (typeof(responseData.response) === 'object' ) {
+        if (typeof responseData.response === 'object') {
           const KEYS: Array<string> = Object.keys(responseData.response);
 
           if (KEYS.length > 0) {
             const DATAERROR: string = KEYS.toString().replace(',', ', ').trim();
-            return `Ocurrió un error en ${ KEYS.length > 1 ? 'los campos' : 'el campo'} ${DATAERROR}`;
+            return `Ocurrió un error en ${
+              KEYS.length > 1 ? 'los campos' : 'el campo'
+            } ${DATAERROR}`;
           } else {
             return `${responseData.msg}`;
           }
-
-        } else if (typeof(responseData.response) === 'string'){
+        } else if (typeof responseData.response === 'string') {
           return `${responseData.msg} (${responseData.response})`;
         } else {
           return 'Ha ocurrido un error inesperado, favor de comunicarse con el departamento de TI.';
@@ -118,18 +169,22 @@ export class ResourcesService {
       } else {
         return `${responseData.msg}`;
       }
-    } else if (httpErrorResponse.ok === false && httpErrorResponse.error.hasOwnProperty('message') && httpErrorResponse.error.hasOwnProperty('exception')) {
+    } else if (
+      httpErrorResponse.ok === false &&
+      httpErrorResponse.error.hasOwnProperty('message') &&
+      httpErrorResponse.error.hasOwnProperty('exception')
+    ) {
       const errorException: ResponseErrorException = httpErrorResponse.error;
       const arrController: Array<string> = errorException.file.split('\\');
-      const controller: string = arrController[arrController.length-1];
+      const controller: string = arrController[arrController.length - 1];
       return `Ocurrió un error inesperado: ${errorException.message} en ${controller}:${errorException.line}`;
-
-    } else if (httpErrorResponse.message.includes("Http failure response for") && httpErrorResponse.statusText === "Unknown Error") {
+    } else if (
+      httpErrorResponse.message.includes('Http failure response for') &&
+      httpErrorResponse.statusText === 'Unknown Error'
+    ) {
       return 'No fue posible conectar con el servidor del SAM, favor de contactar al departamento de TI.';
-
-    } else if (httpErrorResponse.status == 408){
+    } else if (httpErrorResponse.status == 408) {
       return 'Su conexión no fue apta para conectar con los servidores del SAM.';
-
     } else {
       return 'Ocurrió un error inesperado, favor de contactar al departamento de TI.';
     }
@@ -141,7 +196,9 @@ export class ResourcesService {
     if (idusuario !== null && idusuario !== undefined) {
       return idusuario;
     } else {
-      this.openSnackBarAfter('Ocurrió un error al obtener el usuario, inicie sesión de nuevo.');
+      this.openSnackBarAfter(
+        'Ocurrió un error al obtener el usuario, inicie sesión de nuevo.'
+      );
       localStorage.clear();
       this._router.navigate(['login']);
       return '';
@@ -154,7 +211,9 @@ export class ResourcesService {
       const USER_DEC = await this._encService.decrypt(IDUSUARIO);
       return USER_DEC;
     } else {
-      this.openSnackBarAfter('Ocurrió un error al obtener el usuario, inicie sesión de nuevo.');
+      this.openSnackBarAfter(
+        'Ocurrió un error al obtener el usuario, inicie sesión de nuevo.'
+      );
       localStorage.clear();
       this._router.navigate(['login']);
       return '';
@@ -166,7 +225,9 @@ export class ResourcesService {
     if (token !== null && token !== undefined) {
       return token;
     } else {
-      this.openSnackBarAfter('Ocurrió un error al obtener el token, favor de iniciar sesión nuevamente.');
+      this.openSnackBarAfter(
+        'Ocurrió un error al obtener el token, favor de iniciar sesión nuevamente.'
+      );
       localStorage.clear();
       this._router.navigate(['login']);
       return '';
@@ -178,36 +239,46 @@ export class ResourcesService {
   }
 
   // Ejecuta un mensaje
-  public openSnackBar(message: string, action: string = "Cerrar", timer: number = 7000) {
+  public openSnackBar(
+    message: string,
+    action: string = 'Cerrar',
+    timer: number = 7000
+  ) {
     this._matSnackBar.open(message, action, {
-      duration: timer
+      duration: timer,
     });
   }
 
   //Ejecuta un mensaje después de otro mensaje
-  public openSnackBarAfter(message: string, action: string = "Cerrar", timer: number = 7000) {
+  public openSnackBarAfter(
+    message: string,
+    action: string = 'Cerrar',
+    timer: number = 7000
+  ) {
     setTimeout(() => {
       this._matSnackBar.open(message, action, {
-        duration: timer
+        duration: timer,
       });
-    }, 1500)
+    }, 1500);
   }
 
   // Obtiene la fecha actual en formato DD-MM-YYYY
   public getDateFormat(): string {
     let dateFormat: Date = new Date();
-    return `${dateFormat.getDate()}-${this.arrMonth[dateFormat.getMonth()]}-${dateFormat.getFullYear()}`;
+    return `${dateFormat.getDate()}-${
+      this.arrMonth[dateFormat.getMonth()]
+    }-${dateFormat.getFullYear()}`;
   }
 
   // Obtiene una fecha de tipo Date y regresa una fecha en formato YYY-MM-DD
-  public getDateFormatCalendar(date:Date): string {
+  public getDateFormatCalendar(date: Date): string {
     let day: string = date.getDate().toString();
     let month: string = this.arrMonth[date.getMonth()];
     let year: string = date.getFullYear().toString();
     return `${year}-${month}-${day}`;
   }
 
-  public getDateFormatCalendarFormat(date:Date): string {
+  public getDateFormatCalendarFormat(date: Date): string {
     let day: string = date.getDate().toString();
     let month: string = this.arrMonth[date.getMonth()];
     let year: string = date.getFullYear().toString();
@@ -215,54 +286,74 @@ export class ResourcesService {
   }
 
   // Obtiene dos fechas y regresa la fecha que esté disponible
-  public formatDate(dateRegister:string | null | undefined, dateUpdate:string | undefined | null): string {
-    let date:string = '';
+  public formatDate(
+    dateRegister: string | null | undefined,
+    dateUpdate: string | undefined | null
+  ): string {
+    let date: string = '';
     if (typeof dateRegister === 'string' && dateUpdate === null) {
       date = dateRegister;
-    } else if (typeof dateRegister === 'string' && dateUpdate !== null && dateUpdate !== undefined) {
+    } else if (
+      typeof dateRegister === 'string' &&
+      dateUpdate !== null &&
+      dateUpdate !== undefined
+    ) {
       date = dateUpdate;
     } else {
       return 'ERR';
     }
-    let arrDateTime:Array<string> = date.split(' ');
-    let arrDate:Array<string> = arrDateTime[0].split('-');
+    let arrDateTime: Array<string> = date.split(' ');
+    let arrDate: Array<string> = arrDateTime[0].split('-');
     return `${arrDate[2]}-${arrDate[1]}-${arrDate[0]} ${arrDateTime[1]}`;
   }
 
   // Obtiene una fecha de tipo String de formato DATETIME y regresa una fecha en formato DD-MM-YYYY HH:MM:SS
-  public formatOnlyDatetime(date:string): string {
-    let arrDateHour:Array<string> = date.split(' ');
-    let arrDate:Array<string> = arrDateHour[0].split('-');
+  public formatOnlyDatetime(date: string): string {
+    let arrDateHour: Array<string> = date.split(' ');
+    let arrDate: Array<string> = arrDateHour[0].split('-');
     return `${arrDate[2]}-${arrDate[1]}-${arrDate[0]} ${arrDateHour[1]}`;
   }
-  
+
   // Obtiene una fecha tipo String de formato YYYY-MM-DD y regresa una fecha en formato DD-MM-YYYY
-  public formatOnlyDate(date:string):string {
-    let arrDate:Array<string> = date.split('-');
+  public formatOnlyDate(date: string): string {
+    let arrDate: Array<string> = date.split('-');
     return `${arrDate[2]}-${arrDate[1]}-${arrDate[0]}`;
   }
 
   // Obtiene una fecha de tipo String de formato YYYY-MM-DD y regresa una fecha de tipo DATE
-  public formatStrDateToDate(strDate:string): Date {
-    let arrDate:Array<string> = strDate.split('-');
-    return new Date(parseInt(arrDate[0]), parseInt(arrDate[1])-1, parseInt(arrDate[2]));
+  public formatStrDateToDate(strDate: string): Date {
+    let arrDate: Array<string> = strDate.split('-');
+    return new Date(
+      parseInt(arrDate[0]),
+      parseInt(arrDate[1]) - 1,
+      parseInt(arrDate[2])
+    );
   }
 
   // Obtiene una fecha de tipo String de formato YYYY-MM-DD y regresa una fecha de tipo DATE
-  public formatStrDateToDate2(strDate:string): Date {
-    let arrDate:Array<string> = strDate.split('-');
-    return new Date(parseInt(arrDate[0]), parseInt(arrDate[1]), parseInt(arrDate[2]));
+  public formatStrDateToDate2(strDate: string): Date {
+    let arrDate: Array<string> = strDate.split('-');
+    return new Date(
+      parseInt(arrDate[0]),
+      parseInt(arrDate[1]),
+      parseInt(arrDate[2])
+    );
   }
 
-  public resizeText(text:string, numCaracteres:number) {    
-    let textResize: string = (text.toString()).trim();
-    let contact:string = textResize.length > numCaracteres ? '...' : '';
+  public resizeText(text: string, numCaracteres: number) {
+    let textResize: string = text.toString().trim();
+    let contact: string = textResize.length > numCaracteres ? '...' : '';
     return textResize.substring(0, numCaracteres) + contact;
   }
 
-  public selectUser(userRegister: string|undefined, userUpdate: string | null | undefined):string {
-
-    if (typeof userRegister === 'string' && (userUpdate === null || userUpdate === undefined) ) {
+  public selectUser(
+    userRegister: string | undefined,
+    userUpdate: string | null | undefined
+  ): string {
+    if (
+      typeof userRegister === 'string' &&
+      (userUpdate === null || userUpdate === undefined)
+    ) {
       return userRegister;
     } else if (userUpdate !== null && userUpdate !== undefined) {
       return userUpdate;
@@ -271,10 +362,12 @@ export class ResourcesService {
     }
   }
 
-  public getTypeFile(codeFile:string): string {
+  public getTypeFile(codeFile: string): string {
     const arrCatgory: Array<CategoryFile> = docClassification;
 
-    let dataFile = arrCatgory.find((element:CategoryFile) => element.code === codeFile);
+    let dataFile = arrCatgory.find(
+      (element: CategoryFile) => element.code === codeFile
+    );
     if (dataFile === null || dataFile === undefined) {
       return 'No encontrado';
     }
@@ -284,15 +377,15 @@ export class ResourcesService {
 
   public async convertisBase64($event: File) {
     return new Promise((resolve, reject) => {
-      var fr = new FileReader();  
+      var fr = new FileReader();
       fr.onload = () => {
-        resolve(fr.result )
+        resolve(fr.result);
       };
       fr.onerror = reject;
-    });    
+    });
   }
 
-  public moneyFormat(money:number): string {
+  public moneyFormat(money: number): string {
     let newFormat: string = '';
 
     const formatter = new Intl.NumberFormat('en-US', {
@@ -309,19 +402,24 @@ export class ResourcesService {
   }
 
   public onResize(): boolean {
-    return window.innerWidth <= 1050
+    return window.innerWidth <= 1050;
   }
 
   public innerWidth(): number {
     return window.innerWidth;
   }
 
-  public applyFilter(event: any, type: string, dataSource: MatTableDataSource<any>, isLoading: boolean, ): MatTableDataSource<any> {
+  public applyFilter(
+    event: any,
+    type: string,
+    dataSource: MatTableDataSource<any>,
+    isLoading: boolean
+  ): MatTableDataSource<any> {
     if (!isLoading) {
-      let filterValue:string;
+      let filterValue: string;
       if (type == 'INP') {
         filterValue = (event.target as HTMLInputElement).value;
-      }else{
+      } else {
         // this.txtSearch = event;
         filterValue = event;
       }
@@ -349,14 +447,14 @@ export class ResourcesService {
     const requestUserNumberLine: RequestUserNumberLine = {
       USUARIO: this.getUser(),
       NUMERO_LINEA: this.getLineNumber(),
-    }
+    };
 
     return requestUserNumberLine;
   }
 
   public setChipList(typeList: string): string {
     let background: string = '';
-    switch( typeList ) {
+    switch (typeList) {
       case 'Activo':
         background = 'teal_dark_background';
         break;
@@ -450,23 +548,32 @@ export class ResourcesService {
       case 'Expirado':
         background = 'red_dark_background';
         break;
+      case 'Aprobada':
+        background = 'teal_dark_background';
+        break;
+      case 'Rechazada':
+        background = 'red_dark_background';
+        break;
+      case 'Validada por timeout':
+        background = 'green_dark_background';
+        break;
     }
 
     return background;
   }
 
-  async fileExists(url: string){
-    try{
+  async fileExists(url: string) {
+    try {
       let res: any = await lastValueFrom(this._httpClient.get(url).pipe());
-      if(res.status == 200){
+      if (res.status == 200) {
         return true;
-      }else{
+      } else {
         return false;
       }
-    }catch(error: any){
-      if(error.status == 200){
+    } catch (error: any) {
+      if (error.status == 200) {
         return true;
-      }else{
+      } else {
         return false;
       }
     }
@@ -474,9 +581,9 @@ export class ResourcesService {
 }
 
 export interface ResponseData {
-  error: Boolean,
-  msg: string,
-  response: any[]
+  error: Boolean;
+  msg: string;
+  response: any[];
 }
 
 export interface ResponseErrorException {
@@ -489,4 +596,4 @@ export interface ResponseErrorException {
 export interface CategoryFile {
   category: string;
   code: string;
-}
+}