瀏覽代碼

Modifiación de errores y cambios en responsividad de administrador

JeanBenitez 1 年之前
父節點
當前提交
9bb62a2d6a

+ 6 - 1
sistema-mantenimiento-front/src/app/components/personal-management/subcontratist/contract-history/contract-history.component.html

@@ -9,11 +9,16 @@
       <h2>{{ errorStr }}</h2>
     </div>
   }
-  <app-search-card
+
+  @if (!isLoading) {
+    <app-search-card
     [dataSource]="dataSource"
     [disabled]="isLoading || isLoadingForm"
     (dataValue)="dataSource = $event"
   />
+  }
+  
+
   <div class="animated fadeIn" [ngClass]="{ table_dialog_details_column: !isLoading && !hasError, hidden: isLoading }">
     <table mat-table [dataSource]="dataSource" matSort class="animated fadeIn" [style.display]="isLoading || hasError ? 'none' : 'revert'">
       <ng-container matColumnDef="CONTRACT_NAME">

+ 51 - 76
sistema-mantenimiento-front/src/app/components/personal-management/subcontratist/subcontratist.component.ts

@@ -125,10 +125,7 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
     }
   }
 
-  public async openDialog(typeForm: string, element?: any) {
-    console.log(typeForm);
-    console.log(element);
-    
+  public async openDialog(typeForm: string, element?: any) {    
     if (typeForm === 'REG') {
 
       const typeFormSubcontract: TypeFormSubcontract = {
@@ -252,51 +249,40 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
   }
 
   public async getSubcontratists() {
-    try{
-      this.isLoading = true;
-      this.hasError = false;
-      this.errorStr = '';
-      
-      let idUser = localStorage.getItem('idusuario')!;
-      let subcontratists: SubcontratistsResponse = await lastValueFrom(this._subcontratistService.getConsultOfSubcontratists(idUser, 1));
-
-      this.hasError = subcontratists.error;
-      this.errorStr = subcontratists.msg;
-
-      if(!this.hasError){
-        let subcontratistsArr: SubcontratistItem[] = [];
-        subcontratists.response.forEach(item => {
-          let regFormatted = this._functionsService.orderDate(item.REGISTER_DATE);
-          let modFormatted = null;
-
-          if(item.UPDATE_DATE != null){
-            modFormatted = this._functionsService.orderDate(item.UPDATE_DATE);
-          }
-          
-          item.REGISTER_DATE = regFormatted!;
-          item.UPDATE_DATE = modFormatted!;
-
-          subcontratistsArr.push(item);
-        }),
-
-        this.dataSourceSubcontratists.data = subcontratistsArr;
-        // this.dataSourceSubcontratists.sort = this.sort2;
-        // this.dataSourceSubcontratists.paginator = this.paginator2;
-      }
-      
-      this.isLoading = false;
-    }catch(error: any){
-      if(error.error == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
-      }else if(error.error.msg == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
-      }else{
-        this.errorStr = error.error.msg;
-      }
+    this.isLoading = true;
+    
+    const USER: string = this.resourcesService.getUser();
+    const LINE: number = this.resourcesService.getLineNumber();
+    await lastValueFrom(this._subcontratistService.getConsultOfSubcontratists(USER, LINE)).then(
+      (responseData: SubcontratistsResponse) => {
+        this.hasError = responseData.error;
+        if (!responseData.error) {
 
-      this.hasError = true;
-      this.isLoading = false;
-    }
+          let subcontratistsArr: SubcontratistItem[] = [];
+          responseData.response.forEach(item => {
+            let regFormatted = this._functionsService.orderDate(item.REGISTER_DATE);
+            let modFormatted = null;
+
+            if(item.UPDATE_DATE != null){
+              modFormatted = this._functionsService.orderDate(item.UPDATE_DATE);
+            }
+            
+            item.REGISTER_DATE = regFormatted!;
+            item.UPDATE_DATE = modFormatted!;
+
+            subcontratistsArr.push(item);
+          }),
+
+          this.dataSourceSubcontratists.data = subcontratistsArr;
+
+        } else {
+          this.errorStr = responseData.msg;
+          this.resourcesService.openSnackBar(`${ responseData.msg }`);
+        }
+      }, (httpErrorResponse: HttpErrorResponse) => this.resourcesService.checkErrors(httpErrorResponse)
+    );
+
+    this.isLoading = false;
   }
 
   private async deleteSubcontratist(subcontratistId: string) {
@@ -337,35 +323,24 @@ export class SubcontratistComponent implements OnInit, AfterViewInit {
   }
 
   public async getContractsBySubcontratists() {
-    try{
-      let idUser = localStorage.getItem('idusuario')!;
-
-      const USER: string = this.resourcesService.getUser();
-      const LINE: number = this.resourcesService.getLineNumber();
-      let contracts: ContractsBySubcontratistsResponse = await lastValueFrom(this._subcontratistService.getContractsOfEverySubcontratist(USER, LINE));
-      
-      this.hasError = contracts.error;
-      this.errorStr = contracts.msg;
-
-      if(!this.hasError){
-        this.dataSourceContracts = new MatTableDataSource(contracts.response);
-        this.dataSourceContracts.paginator = this.paginator;
-        this.dataSourceContracts.sort = this.sort;
-      }
-
-      this.isLoading = false;
-    }catch(error: any){
-      if(error.error == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
-      }else if(error.error.msg == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
-      }else{
-        this.errorStr = error.error.msg;
-      }
+    this.isLoading = true;
+    
+    const USER: string = this.resourcesService.getUser();
+    const LINE: number = this.resourcesService.getLineNumber();
+    await lastValueFrom(this._subcontratistService.getContractsOfEverySubcontratist(USER, LINE)).then(
+      (responseData: ContractsBySubcontratistsResponse) => {
+        
+        this.hasError = responseData.error;
+        if (!responseData.error) {
+          this.dataSourceContracts.data = responseData.response;
+        } else {
+          this.errorStr = responseData.msg;
+          this.resourcesService.openSnackBar(responseData.msg);
+        }
+      }, (httpErrorResponse: HttpErrorResponse) => this.resourcesService.checkErrors(httpErrorResponse)
+    );
 
-      this.hasError = true;
-      this.isLoading = false;
-    }
+    this.isLoading = false;
   }
 
   // Método de filtrado de datos

+ 1 - 1
sistema-mantenimiento-front/src/app/components/system-admin/email-config/new-email-server/new-email-server.component.html

@@ -18,7 +18,7 @@
                 <p style="font-style: italic; font-size: 16px; overflow-wrap: anywhere; text-align: center;">{{ errorStr }}</p>
             </div>
             <div class="mat-card-content-form prevent-select animated fadeIn" *ngIf="!isLoading && !hasError">
-                <form [formGroup]="serverForm">
+                <form [formGroup]="serverForm" style="height: calc(100vh - 280px); overflow: auto;">
                     <div class="form-container">
                         <div class="form-input">
                             <mat-form-field class="full-width" appearance="outline">