Browse Source

Integración de cambios

Jose Brito 2 years ago
parent
commit
05571c8475

+ 278 - 28
sistema-mantenimiento-back/app/Http/Controllers/DocumentManagementController.php

@@ -8,47 +8,49 @@ use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Carbon;
 
-class DocumentManagementController extends Controller{
+class DocumentManagementController extends Controller
+{
     private $responseController;
     private $encryptionController;
     private $functionsController;
 
-    public function __construct(){
+    public function __construct()
+    {
         $this->responseController = new ResponseController();
         $this->encryptionController = new EncryptionController();
         $this->functionsController = new FunctionsController();
     }
 
-    public function downloadFile($token, $idUser, $line){
-        DB::enableQueryLog();
+    public function downloadFile($token, $idUser, $line)
+    {
 
         $tokenInfo = DB::table('S002V01TTODE')->where([
             ['TODE_NULI', '=', $line],
             ['TODE_TOKE', '=', $token]
         ])->first();
 
-        if(is_null($tokenInfo)){
+        if (is_null($tokenInfo)) {
             return $this->responseController->makeResponse(true, 'El token de descarga no existe.', [], 404);
-        }else if($tokenInfo->TODE_ESTA != 'Activo'){
+        } else if ($tokenInfo->TODE_ESTA != 'Activo') {
             return $this->responseController->makeResponse(true, 'El token de descarga ya fue utilizado.', [], 401);
         }
 
         $token = $this->encryptionController->shortDec($token);
-        if(!$token){
+        if (!$token) {
             return $this->responseController->makeResponse(true, 'El token de descarga no está encriptado correctamente.', [], 400);
         }
 
         $tokenArr = explode("|", $token);
-        if(count($tokenArr) != 3){
+        if (count($tokenArr) != 3) {
             return $this->responseController->makeResponse(true, 'Estructura de token inválida.', [], 401);
-        }else if(intval($tokenArr[1]) != $tokenInfo->TODE_LLAL){
+        } else if (intval($tokenArr[1]) != $tokenInfo->TODE_LLAL) {
             return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
-        }else if($tokenArr[2] != 'syp'){
+        } else if ($tokenArr[2] != 'syp') {
             return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
         }
 
         $idUser = $this->encryptionController->shortDec($idUser);
-        if(!$idUser){
+        if (!$idUser) {
             return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
         }
 
@@ -57,7 +59,7 @@ class DocumentManagementController extends Controller{
             ['USUA_NULI', '=', $line]
         ])->first();
 
-        if(is_null($usr)){
+        if (is_null($usr)) {
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
         }
 
@@ -84,7 +86,7 @@ class DocumentManagementController extends Controller{
             'TODE_USDE' => $idUser,
             'TODE_FEDE' => $nowStr
         ]);
-        
+
         $file = DB::table('S002V01TAFAL')->where([
             ['AFAL_NULI', '=', $nuli],
             ['AFAL_COMO', '=', $como],
@@ -96,23 +98,25 @@ class DocumentManagementController extends Controller{
             ['AFAL_EXTE', '=', $exte],
         ])->first();
 
-        if(is_null($usr)){
+        $aux = DB::getQueryLog();
+
+        if (is_null($file)) {
             return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
         }
-
         return response()->download($file->AFAL_UBIC);
     }
 
-    public function getDownloadToken($idFile, $idUser, $line){
+    public function getDownloadToken($idFile, $idUser, $line)
+    {
         DB::enableQueryLog();
 
         $idFile = $this->encryptionController->shortDec($idFile);
-        if(!$idFile){
+        if (!$idFile) {
             return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
         }
 
         $idUser = $this->encryptionController->shortDec($idUser);
-        if(!$idUser){
+        if (!$idUser) {
             return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
         }
 
@@ -121,7 +125,7 @@ class DocumentManagementController extends Controller{
             ['USUA_NULI', '=', $line]
         ])->first();
 
-        if(is_null($usr)){
+        if (is_null($usr)) {
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
         }
 
@@ -137,7 +141,7 @@ class DocumentManagementController extends Controller{
         $nuve = $codiArr[1];
         $noar = $suffArr[0];
         $exte = $suffArr[1];
-        
+
         $file = DB::table('S002V01TAFAL')->where([
             ['AFAL_NULI', '=', $nuli],
             ['AFAL_COMO', '=', $como],
@@ -149,7 +153,8 @@ class DocumentManagementController extends Controller{
             ['AFAL_EXTE', '=', $exte],
         ])->first();
 
-        if(is_null($file)){
+        $aux = DB::getQueryLog();
+        if (is_null($file)) {
             return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
         }
 
@@ -174,16 +179,17 @@ class DocumentManagementController extends Controller{
         return $this->responseController->makeResponse(false, 'EXITO', ['TOKEN' => $token]);
     }
 
-    public function getFileInfo($id, $idUser, $line){
+    public function getFileInfo($id, $idUser, $line)
+    {
         DB::enableQueryLog();
 
         $id = $this->encryptionController->shortDec($id);
-        if(!$id){
+        if (!$id) {
             return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
         }
 
         $idUser = $this->encryptionController->shortDec($idUser);
-        if(!$idUser){
+        if (!$idUser) {
             return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
         }
 
@@ -192,7 +198,7 @@ class DocumentManagementController extends Controller{
             ['USUA_NULI', '=', $line]
         ])->first();
 
-        if(is_null($usr)){
+        if (is_null($usr)) {
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
         }
 
@@ -221,12 +227,256 @@ class DocumentManagementController extends Controller{
             ['AFAL_NUVE', '=', $nuve],
         ])->first();
 
-        if(is_null($fileInfo)){
+        if (is_null($fileInfo)) {
             return $this->responseController->makeResponse(true, 'El archivo solicitado no está registrado.', [], 404);
-        }else if($fileInfo->ESTADO != 'Activo'){
+        } else if ($fileInfo->ESTADO != 'Activo') {
             return $this->responseController->makeResponse(true, 'El archivo solicitado no está disponible.', [], 404);
         }
 
         return $this->responseController->makeResponse(false, 'EXITO', $fileInfo);
     }
-}
+
+    public function getDocuments($idUser, $line)
+    {
+        DB::enableQueryLog();
+        $idUser = $this->encryptionController->shortDec($idUser);
+        if (!$idUser) {
+            return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la solicitud no está encriptado correctamente', [], 400);
+        }
+
+        $documents = DB::table('s002v01tafal')->select(
+            'AFAL_NOAR as NOMBRE_ARC',
+            'AFAL_EXTE as EXTENSION',
+            'AFAL_TAMA as TAMANIO',
+            'AFAL_NUVE as VERSION',
+            'AFAL_FECR as FECHA_REGISTRO',
+            'AFAL_USRE as PROPIETARIO',
+            'AFAL_UBIC as URL',
+            'AFAL_USAC AS ACCESO',
+            'AFAL_ESTA AS ESTADO',
+            'AFAL_NULI AS NUMERO_LINEA',
+            'AFAL_CLDO AS CLASIFICACION',
+            'AFAL_COMO AS MODULO',
+            'AFAL_NUSE AS SECUENCIAL'
+        )->where('AFAL_USRE', $idUser)->get()->all();
+
+        $nowStr = Carbon::now('America/Mexico_city')->toDateTimeString();
+        $actions = DB::getQueryLog();
+
+        //$this->functionsController->registerActivity($actions, $idUser, $nowStr, $line);
+        return $this->responseController->makeresponse(false, "EXITO", $documents);
+    }
+
+    public function getInfoDocument($idUser, $line, $idDocument)
+    {
+        DB::enableQueryLog();
+        $idUser = $this->encryptionController->shortDec($idUser);
+        if (!$idUser) {
+            return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la solicitud no está encriptado correctamente', [], 400);
+        }
+
+        $idDocument = $this->encryptionController->shortDec($idDocument);
+        if (!$idDocument) {
+            return $this->responseController->makeResponse(true, 'El ID del documento no está encriptado correctamente', [], 400);
+        }
+
+        $document = DB::table('s002v01tafal')->where('AFAL_USRE', $idUser)->where('AFAL_ID', $idDocument)->get();
+
+        $nowStr = Carbon::now('America/Mexico_city')->toDateTimeString();
+        $actions = DB::getQueryLog();
+
+        //$this->functionsController->registerActivity($actions, $idUser, $nowStr, $line);
+        return $this->responseController->makeresponse(false, "EXITO", $document);
+    }
+
+    public function moveFinalFile(Request $request)
+    {
+        DB::enableQueryLog();
+        $validator = Validator::make($request->all(), [
+            'id_user' => 'required|string',
+            'linea' => 'required|integer',
+            'audiencia' => 'required|json',
+            'archivos' => 'required|json',
+            'cldo' => 'required|string',
+            ''
+        ]);
+
+        if($validator->fails()){
+            return $this->responseController->makeResponse(
+                true,
+                "Se encontraron uno o más errores.",
+                $this->responseController->makeErrors(
+                    $validator->errors()->messages()
+                ),
+                401
+            );
+        }
+
+        $advice = $request->all();
+        $idUser = $this->encryptionController->decrypt($advice['id_user']);
+        if(!$idUser){
+            return $this->responseController->makeResponse(true, "El ID del usuario que realizó la petición no fue encriptado correctamente", [], 400);
+        }
+
+        $usr = DB::table('S002V01TUSUA')->where([
+            ['USUA_IDUS', '=', $idUser],
+            ['USUA_NULI', '=', $advice['linea']]
+        ])->first();
+
+        if(is_null($usr)){
+            return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
+        }
+
+        $filesArr = json_decode($advice['archivos'], true);
+        $nowStr = Carbon::now('America/Mexico_city')->toDateTimeString();
+        $attachedArr = [];
+        foreach($filesArr as $file){
+            $idFile = $file['id'];
+            $idFile = $this->encryptionController->decrypt($idFile);
+            if(!$idFile){
+                return $this->responseController->makeResponse(true, "El ID del archivo $file[name] no fue encriptado correctamente", [], 400);
+            }
+
+            $fileObj = DB::table('S002V01TARTE')->where([
+                ['ARTE_IDAR', '=', $idFile],
+                ['ARTE_NULI', '=', $advice['linea']]
+            ])->first();
+
+            if(is_null($fileObj)){
+                return $this->responseController->makeResponse(true, "El ID del archivo $file[name] no existe", [], 404);
+            }else if($fileObj->ARTE_ESTA == 'Eliminado'){
+                return $this->responseController->makeResponse(true, "El archivo $file[name] está eliminado", [], 404);
+            }
+
+            $fileSaved = $this->moveFinalFile($advice['linea'], 'AV', $fileObj, 'S002V01M01ADSI', 'S002V01F03CRAV', 'S002V01P02CNAV');
+            if(!$fileSaved[0]){
+                return $this->responseController->makeResponse(true, "El archivo no pudo guardarse: $fileSaved[1]", [], 500);
+            }
+            
+            $attachedArr[] = $this->encryptionController->encrypt($fileSaved[1]);
+
+            DB::table('S002V01TARTE')->where([
+                ['ARTE_IDAR', '=', $idFile],
+                ['ARTE_NULI', '=', $advice['linea']],
+            ])->update([
+                'ARTE_ESTA' => 'Eliminado',
+                'ARTE_USMO' => $idUser,
+                'ARTE_FEMO' => $nowStr
+            ]);
+        }
+
+        $ubiTempFile = $file->ARTE_UBTE;
+        $ubiFileArr = explode('tempFiles', $ubiTempFile);
+        $ubic = $ubiFileArr[0] . 'files' . $ubiFileArr[1];
+
+        $como = substr($module, -4);
+        $date = Carbon::now('America/Mexico_city')->toDateTimeString();
+        $dateArr = explode(' ', $date);
+        $dateStr = $dateArr[0];
+        $dA = explode('-', $dateStr);
+        $dA[0] = substr($dA[0], -2);
+        $fecr = implode('', $dA);
+
+        $nameStr = $file->ARTE_NOAR;
+        $nameArr = explode('.', $nameStr);
+
+        $nuve = 0;
+        $nuse = 0;
+
+        $lastSec = DB::table('S002V01TAFAL')->where([
+            ['AFAL_NULI', '=', $line],
+            ['AFAL_COMO', '=', $como],
+            ['AFAL_CLDO', '=', $cldo]
+        ])->orderBy('AFAL_NUSE', 'desc')->first();
+
+        if (is_null($lastSec)) {
+            $nuse = 1;
+        } else {
+            $nuse = $lastSec->AFAL_NUSE + 1;
+        }
+
+        $lastVersion = DB::table('S002V01TAFAL')->where([
+            ['AFAL_NULI', '=', $line],
+            ['AFAL_NOAR', '=', $nameArr[0]],
+            ['AFAL_EXTE', '=', $nameArr[1]],
+        ])->orderBy('AFAL_NUVE', 'desc')->first();
+
+        if (is_null($lastVersion)) {
+            $nuve = 1;
+        } else {
+            $nuve = $lastVersion->AFAL_NUVE + 1;
+        }
+
+        if ($nuve > 99) return [false, 'El archivo llegó al número máximo de versiones'];
+        if ($nuse > 999999) return [false, 'El archivo llegó al número de secuencia máximo'];
+
+
+        $noar = $nameArr[0];
+        $exte = $nameArr[1];
+
+        if (strlen($noar) > 100) return [false, 'El nombre del archivo tiene una longitud mayor a 100 caracteres'];
+        $tama = $file->ARTE_TAMA;
+        $usac = json_encode([$file->ARTE_USRE]);
+        $usre = $file->ARTE_USRE;
+        $fere = $file->ARTE_FERE;
+
+        DB::table('S002V01TAFAL')->insert([
+            'AFAL_NULI' => $line,
+            'AFAL_COMO' => $como,
+            'AFAL_CLDO' => $cldo,
+            'AFAL_FECR' => $fecr,
+            'AFAL_NUSE' => $nuse,
+            'AFAL_NUVE' => $nuve,
+            'AFAL_NOAR' => $noar,
+            'AFAL_EXTE' => $exte,
+            'AFAL_TAMA' => $tama,
+            'AFAL_UBIC' => $ubic,
+            'AFAL_USAC' => $usac,
+            'AFAL_USRE' => $usre,
+            'AFAL_FERE' => $fere
+        ]);
+
+        if (file_exists($file->ARTE_UBTE)) {
+            rename($file->ARTE_UBTE, $ubic);
+        }
+
+        $codigo = "";
+        if (strlen($line) < 2) {
+            $codigo .= "0$line-";
+        } else {
+            $codigo .= "$line-";
+        }
+
+        $codigo .= "$como-$cldo-$fecr-";
+        switch (strlen($nuse)) {
+            case 1:
+                $codigo .= "00000$nuse";
+                break;
+            case 2:
+                $codigo .= "0000$nuse";
+                break;
+            case 3:
+                $codigo .= "000$nuse";
+                break;
+            case 4:
+                $codigo .= "00$nuse";
+                break;
+            case 5:
+                $codigo .= "0$nuse";
+                break;
+            default:
+                $codigo .= "$nuse";
+                break;
+        }
+
+        if (strlen($nuve) < 2) {
+            $codigo .= "=0$nuve=";
+        } else {
+            $codigo .= "=$nuve=";
+        }
+
+        $codigo .= "$noar.$exte";
+
+        return [true, $codigo];
+    }
+}

+ 13 - 49
sistema-mantenimiento-front/src/app/components/failure-analysis/failure/failure.component.html

@@ -47,23 +47,24 @@
       <div class="override-table">
         <!-- TABLA -->
         <table mat-table [dataSource]="dataSource" matSort class="animated fadeIn" *ngIf="!isLoading">
-          <ng-container matColumnDef="NUMERO_FALLA">
+          <ng-container matColumnDef="FALL_NUFA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Código de Falla</th>
             <td mat-cell *matCellDef="let element">{{ element.FALL_NUFA }}</td>
           </ng-container>
-          <ng-container matColumnDef="CODIGO_EQUIPAMIENTO">
+          <!-- <ng-container matColumnDef="FALL_COEQ">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Equipamiento</th>
             <td mat-cell *matCellDef="let element">{{ element.FALL_COEQ }}</td>
-          </ng-container>
-          <ng-container matColumnDef="FALLA">
+          </ng-container> -->
+          <ng-container matColumnDef="LIFA_NOFA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Falla</th>
             <td mat-cell *matCellDef="let element">{{ element.LIFA_NOFA }}</td>
           </ng-container>
-          <ng-container matColumnDef="CAUSA">
+          <!--
+          <ng-container matColumnDef="FALL_CAUS">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Causa</th>
             <td mat-cell *matCellDef="let element">{{ element.FALL_CAUS }}</td>
           </ng-container>
-          <ng-container matColumnDef="CLASIFICACION">
+          <ng-container matColumnDef="FALL_CLAS">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Clásificación</th>
             <td mat-cell *matCellDef="let element">
               <b *ngIf="element.FALL_CLAS === 'Bajo'" class="green_primary_font">{{ element.FALL_CLAS }}</b>
@@ -72,23 +73,19 @@
               <b *ngIf="element.FALL_CLAS === 'Crítico'" class="red_dark_font">{{ element.FALL_CLAS }}</b>
             </td>
           </ng-container>
-          <ng-container matColumnDef="FECHA_EMISION">
+          <ng-container matColumnDef="FALL_FEFA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Fecha de Emisión</th>
             <td mat-cell *matCellDef="let element">{{ resourcesService.formatOnlyDate(element.FALL_FEFA) }}</td>
           </ng-container>
-          <!-- <ng-container matColumnDef="LIMITE_VALOR">
-            <th mat-header-cell *matHeaderCellDef mat-sort-header>Valor Límite Permitido</th>
-            <td mat-cell *matCellDef="let element">{{ element.FALL_LIVA }} {{ element.LIME_ACRO }}</td>
-          </ng-container> -->
-          <ng-container matColumnDef="USUARIO_REGISTRA">
+          <ng-container matColumnDef="FALL_USRE">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Usuario Modificación</th>
             <td mat-cell *matCellDef="let element">{{ resourcesService.selectUser(element.FALL_USRE, element.FALL_USMO) }}</td>
           </ng-container>
-          <ng-container matColumnDef="FECHA_REGISTRA">
+          <ng-container matColumnDef="FALL_FERE">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Fecha Modificación</th>
             <td mat-cell *matCellDef="let element">{{ resourcesService.formatDate(element.FALL_FERE, element.FALL_FEMO) }}</td>
           </ng-container>
-          <ng-container matColumnDef="ESTADO">
+          <ng-container matColumnDef="FALL_ESTA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Estado</th>
             <td mat-cell *matCellDef="let element">
               <mat-chip-listbox>
@@ -98,20 +95,9 @@
             </td>
           </ng-container>
 
-          <ng-container matColumnDef="ACCIONES">
+          <ng-container matColumnDef="ACTIONS">
             <th mat-header-cell *matHeaderCellDef>Acciones</th>
             <td mat-cell *matCellDef="let element">
-              <!-- <button mat-mini-fab color="accent" *ngIf="btnSmall" [disabled]="element.SINT_ESTA == 'Inactivo' || isLoadingForm" [matMenuTriggerFor]="menu" #menuTrigger class="override-no-shadow">
-                <mat-icon>settings</mat-icon>
-              </button>
-              <mat-menu #menu="matMenu">
-                <button mat-menu-item (click)="openDialog('UPD', element)">
-                  <mat-icon>edit</mat-icon> Editar Falla
-                </button>
-                <button mat-menu-item (click)="openDialog('DEL', element)">
-                  <mat-icon>delete</mat-icon> Eliminar Falla
-                </button>
-              </mat-menu> -->
               <button
                 mat-mini-fab
                 color="primary"
@@ -121,30 +107,8 @@
                 (click)="viewChart(element)">
                 <mat-icon>bar_chart</mat-icon>
               </button>
-
-              <div *ngIf="!btnSmall">
-
-                <!-- <button
-                  mat-mini-fab
-                  color="primary"
-                  class="override-no-shadow mr-4"
-                  [disabled]="element.FALL_ESTA == 'Inactivo' || isLoadingForm"
-                  matTooltip="Editar Falla"
-                  (click)="openDialog('UPD', element)">
-                  <mat-icon>edit</mat-icon>
-                </button>
-                <button
-                  mat-mini-fab
-                  color="warn"
-                  class="override-no-shadow mr-4"
-                  [disabled]="element.FALL_ESTA == 'Inactivo' || isLoadingForm"
-                  matTooltip="Eliminar Falla"
-                  (click)="openDialog('DEL', element)">
-                  <mat-icon>delete</mat-icon>
-                </button> -->
-              </div>
             </td>
-          </ng-container>
+          </ng-container> -->
 
           <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
           <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>

+ 12 - 1
sistema-mantenimiento-front/src/app/components/failure-analysis/failure/failure.component.ts

@@ -45,7 +45,18 @@ export class FailureComponent implements OnInit, AfterViewInit {
 
     this.txtBuscador = '';
 
-    this.displayedColumns = ['NUMERO_FALLA','CODIGO_EQUIPAMIENTO','FALLA','CAUSA','CLASIFICACION','FECHA_EMISION',/* 'LIMITE_VALOR', */'USUARIO_REGISTRA','FECHA_REGISTRA','ESTADO','ACCIONES']
+    this.displayedColumns = [
+      'FALL_NUFA',
+      // 'FALL_COEQ',
+      'LIFA_NOFA'
+      // 'FALL_CAUS',
+      // 'FALL_CLAS',
+      // 'FALL_FEFA',
+      // 'FALL_USRE',
+      // 'FALL_FERE',
+      // 'FALL_ESTA',
+      // 'ACTIONS',
+    ]
     this.dataSource = new MatTableDataSource<GetFailure>();
   }
 

+ 10 - 9
sistema-mantenimiento-front/src/app/components/failure-analysis/symptom/symptom.component.html

@@ -47,19 +47,19 @@
       <div class="override-table">
         <!-- TABLA -->
         <table mat-table [dataSource]="dataSource" matSort class="animated fadeIn" *ngIf="!isLoading">
-          <ng-container matColumnDef="CODIGO_EQUIPAMIENTO">
+          <ng-container matColumnDef="SINT_COEQ">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Equipamiento</th>
             <td mat-cell *matCellDef="let element">{{ element.SINT_COEQ }}</td>
           </ng-container>
-          <ng-container matColumnDef="FALLA">
+          <ng-container matColumnDef="LIFA_NOFA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Falla</th>
             <td mat-cell *matCellDef="let element">{{ element.LIFA_NOFA }}</td>
           </ng-container>
-          <ng-container matColumnDef="CAUSA">
+          <ng-container matColumnDef="SINT_CAUS">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Causa</th>
             <td mat-cell *matCellDef="let element">{{ element.SINT_CAUS }}</td>
           </ng-container>
-          <ng-container matColumnDef="CLASIFICACION">
+          <ng-container matColumnDef="SINT_CLAS">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Clásificación</th>
             <td mat-cell *matCellDef="let element">
               <b *ngIf="element.SINT_CLAS === 'Bajo'" class="green_primary_font">{{ element.SINT_CLAS }}</b>
@@ -68,19 +68,19 @@
               <b *ngIf="element.SINT_CLAS === 'Crítico'" class="red_dark_font">{{ element.SINT_CLAS }}</b>
             </td>
           </ng-container>
-          <ng-container matColumnDef="LIMITE_VALOR">
+          <ng-container matColumnDef="SINT_LIVA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Valor Límite Permitido</th>
             <td mat-cell *matCellDef="let element">{{ element.SINT_LIVA }} {{ element.LIME_ACRO }}</td>
           </ng-container>
-          <ng-container matColumnDef="USUARIO_REGISTRA">
+          <ng-container matColumnDef="SINT_USRE">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Usuario Modificación</th>
             <td mat-cell *matCellDef="let element">{{ resourcesService.selectUser(element.SINT_USRE, element.SINT_USMO) }}</td>
           </ng-container>
-          <ng-container matColumnDef="FECHA_REGISTRA">
+          <ng-container matColumnDef="SINT_FERE">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Fecha Modificación</th>
             <td mat-cell *matCellDef="let element">{{ resourcesService.formatDate(element.SINT_FERE, element.SINT_FEMO) }}</td>
           </ng-container>
-          <ng-container matColumnDef="ESTADO">
+          <ng-container matColumnDef="SINT_ESTA">
             <th mat-header-cell *matHeaderCellDef mat-sort-header>Estado</th>
             <td mat-cell *matCellDef="let element">
               <mat-chip-listbox>
@@ -90,7 +90,7 @@
             </td>
           </ng-container>
 
-          <ng-container matColumnDef="ACCIONES">
+          <ng-container matColumnDef="ACTIONS">
             <th mat-header-cell *matHeaderCellDef>Acciones</th>
             <td mat-cell *matCellDef="let element">
               <button mat-mini-fab color="accent" *ngIf="btnSmall" [disabled]="element.SINT_ESTA == 'Inactivo' || isLoadingForm" [matMenuTriggerFor]="menu" #menuTrigger class="override-no-shadow">
@@ -152,3 +152,4 @@
     <mat-paginator [pageSizeOptions]="[10, 50, 100]" class="override-paginator"></mat-paginator>
   </mat-card>
 </main>
+

+ 24 - 4
sistema-mantenimiento-front/src/app/components/failure-analysis/symptom/symptom.component.ts

@@ -1,6 +1,8 @@
 import { HttpErrorResponse } from '@angular/common/http';
-import { Component, OnInit } from '@angular/core';
+import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
+import { MatPaginator } from '@angular/material/paginator';
+import { MatSort } from '@angular/material/sort';
 import { MatTableDataSource } from '@angular/material/table';
 import { lastValueFrom } from 'rxjs';
 import { GetSymptom, ResponseDataGet } from 'src/app/interfaces/ANFA/symptom.interface';
@@ -15,7 +17,7 @@ import { SymptomFormComponent } from './symptom-form/symptom-form.component';
   templateUrl: './symptom.component.html',
   styleUrls: ['./symptom.component.css']
 })
-export class SymptomComponent implements OnInit {
+export class SymptomComponent implements OnInit, AfterViewInit {
 
   public isLoading: boolean;
   public isLoadingForm: boolean;
@@ -26,6 +28,9 @@ export class SymptomComponent implements OnInit {
   public displayedColumns: Array<string>;
   public dataSource: MatTableDataSource<GetSymptom>;
 
+  @ViewChild(MatPaginator) paginator!: MatPaginator;
+  @ViewChild(MatSort) sort!: MatSort;
+
   constructor(
     private _symptomService: SymptomService,
     public resourcesService: ResourcesService,
@@ -37,7 +42,17 @@ export class SymptomComponent implements OnInit {
 
     this.txtBuscador = '';
 
-    this.displayedColumns = ['CODIGO_EQUIPAMIENTO','FALLA','CAUSA','CLASIFICACION','LIMITE_VALOR','USUARIO_REGISTRA','FECHA_REGISTRA','ESTADO','ACCIONES']
+    this.displayedColumns = [
+      'SINT_COEQ',
+      'LIFA_NOFA',
+      'SINT_CAUS',
+      'SINT_CLAS',
+      'SINT_LIVA',
+      'SINT_USRE',
+      'SINT_FERE',
+      'SINT_ESTA',
+      'ACTIONS'
+    ]
     this.dataSource = new MatTableDataSource<GetSymptom>();
   }
 
@@ -45,11 +60,16 @@ export class SymptomComponent implements OnInit {
     this.getSymptoms();
   }
 
+  ngAfterViewInit(): void {
+    this.dataSource.paginator = this.paginator;
+    this.dataSource.sort = this.sort;
+  }
+
   public async getSymptoms() {
     this.isLoading = true;
     await lastValueFrom(this._symptomService.getSymptom()).then(
       (responseData: ResponseDataGet) => {
-        this.dataSource = new MatTableDataSource<GetSymptom>(responseData.response);
+        this.dataSource.data = responseData.response;
       }, (error: HttpErrorResponse) => this.resourcesService.checkErrors(error)
     );
     this.isLoading = false;

+ 1 - 1
sistema-mantenimiento-front/src/app/components/forms-management/module-management/module-management-form/module-management-form.component.ts

@@ -30,7 +30,7 @@ export class ModuleManagementFormComponent implements OnInit {
     @Inject(MAT_DIALOG_DATA) public dialogData: DialogModule
   ) {
     this.isLoading = false;
-    this.numberForm = '0000000001';
+    this.numberForm = '0000000006';
     this.titleForm = '';
     this.arrFields = [];
     this.getDynamicForm();

+ 19 - 32
sistema-mantenimiento-front/src/app/components/gdel/addo/addo.component.html

@@ -1,7 +1,7 @@
 <div class="items-container animated fadeIn">
     <div id="navigation" class="mb-8">
-        <div class="prev-page prevent-select indigo_primary_background mat-elevation-z8"
-            [routerLink]="['/sam/GDEL']" matRipple>
+        <div class="prev-page prevent-select indigo_primary_background mat-elevation-z8" [routerLink]="['/sam/GDEL']"
+            matRipple>
             <mat-icon style="color: white;">arrow_back</mat-icon>
             <div class="page-name ml-4">Administración de documentos</div>
         </div>
@@ -23,22 +23,6 @@
         </mat-card-content>
         <mat-card-content class="mat-card-content-fill prevent-select animated fadeIn" *ngIf="!isLoading && !hasError">
             <div class="row-advices pt-8">
-                <mat-form-field appearance="outline" style="width: calc(50% - 8px);">
-                    <mat-label>Nombre del archivo</mat-label>
-                    <input type="text" matInput maxlength="100" #NOAR [formControl]="AFAL_NOAR"
-                        [errorStateMatcher]="errorMatcher">
-                    <mat-hint align="end">{{NOAR.value.length}} / 100</mat-hint>
-                    <mat-error *ngIf="AFAL_NOAR.hasError('required')">
-                        El nombre del documento es <strong>requerido</strong>.
-                    </mat-error>
-                    <mat-error *ngIf="AFAL_NOAR.hasError('minlength')">
-                        El nombre del documento debe tener al menos <strong>8 caracteres</strong>.
-                    </mat-error>
-                    <mat-error *ngIf="AFAL_NOAR.hasError('maxlength')">
-                        El nombre del documento debe tener máximo <strong>100 caracteres</strong>.
-                    </mat-error>
-                </mat-form-field>
-
                 <mat-form-field appearance="outline" style="width: calc(50% - 8px);">
                     <mat-label>Clasificación del documento</mat-label>
                     <mat-select #CLDO [formControl]="AFAL_CLDO" [errorStateMatcher]="errorMatcher">
@@ -49,20 +33,6 @@
                         La clasificación del documento es <strong>requerido</strong>.
                     </mat-error>
                 </mat-form-field>
-            </div>
-
-            <div class="row-advices pt-8">
-                <mat-form-field appearance="outline" style="width: calc(50% - 8px);">
-                    <mat-label>Código del módulo</mat-label>
-                    <mat-select #COMO [formControl]="AFAL_COMO" [errorStateMatcher]="errorMatcher">
-                        <mat-option *ngFor="let mod of modules; let i = index;"
-                            [value]=mod.MODU_IDMO>{{mod.MODU_NOMB}}</mat-option>
-                    </mat-select>
-                    <mat-error *ngIf="AFAL_COMO.hasError('required')">
-                        El código del módulo es <strong>requerido</strong>.
-                    </mat-error>
-                </mat-form-field>
-
                 <mat-form-field appearance="outline" style="width: calc(50% - 8px);">
                     <mat-label>Usuarios con acceso</mat-label>
                     <mat-select multiple [formControl]="AFAL_USAC">
@@ -78,6 +48,19 @@
                 </mat-form-field>
             </div>
 
+            <div class="row-advices pt-8">
+                <mat-form-field appearance="outline" style="width: calc(50% - 8px);">
+                    <mat-label>Código del módulo</mat-label>
+                    <mat-select #COMO [formControl]="AFAL_COMO" [errorStateMatcher]="errorMatcher">
+                        <mat-option *ngFor="let mod of modules; let i = index;"
+                            [value]=mod.MODU_IDMO>{{mod.MODU_NOMB}}</mat-option>
+                    </mat-select>
+                    <mat-error *ngIf="AFAL_COMO.hasError('required')">
+                        El código del módulo es <strong>requerido</strong>.
+                    </mat-error>
+                </mat-form-field>
+            </div>
+
             <div class="row-advices pt-8">
                 <input type="file" name="file" id="file" #file class="hidden" (change)="checkFile($event)">
                 <button type="button" mat-stroked-button style="width: calc(50% - 8px);transform: translateX(50%);"
@@ -131,6 +114,10 @@
                 </tr>
             </table>
         </mat-card-content>
+        <mat-card-actions align="end">
+            <button mat-button (click)="registerDocument()" *ngIf="isNew">Registrar documento</button>
+            <!--  <button mat-button (click)="updateAdvice()" *ngIf="!isNew">Guardar cambios</button> -->
+        </mat-card-actions>
     </mat-card>
 </div>
 

+ 87 - 44
sistema-mantenimiento-front/src/app/components/gdel/addo/addo.component.ts

@@ -24,6 +24,7 @@ import { GETBGMService } from 'src/app/services/forms-management/getbgm/getbgm.s
 import { UsersProfilesService } from 'src/app/services/users-profiles.service';
 import { UsersResponse } from 'src/app/interfaces/users.interface';
 import { ProfilesResponse } from 'src/app/interfaces/profiles.interface';
+import { GdelService } from 'src/app/services/gdel/gdel.service';
 export interface TempFileInfo {
   id: string;
   name: string;
@@ -92,7 +93,7 @@ export class ADDOComponent implements OnInit {
     private _moduloService: GETBGMService,
     private _routeActivated: ActivatedRoute,
     private _snackBar: MatSnackBar,
-    private _documentManagement: DocumentManagementService,
+    private _documentManagement: GdelService,
     private _usersProfilesService: UsersProfilesService
   ) {
     this.isNew = false;
@@ -111,7 +112,7 @@ export class ADDOComponent implements OnInit {
   }
 
   ngOnInit(): void {
-    this.consultarModulos();
+    this.getModulesInfo();
     this._routeActivated.queryParams.subscribe((params) => {
       let idDoc = params['idDoc'];
       this.isNew = idDoc == undefined;
@@ -217,49 +218,46 @@ export class ADDOComponent implements OnInit {
 
   }
 
-  checkFile(event: any) {
-    let fileTypes = availableFiles;
-    let sizes = Object.keys(fileTypes);
-    let extensions = Object.values(fileTypes);
-    let maxSizeMB = 0;
-
-    let extArr = event.target.files[0].name.split('.').reverse();
-    let extStr = extArr[0];
-
-    let i = 0;
-    extensions.forEach((ext) => {
-      let size = parseInt(sizes[i]);
+  async registerDocument(){
+    let hasErrorForm = false;
 
-      if (ext.includes(extStr)) maxSizeMB = size;
-      i++;
-    });
+    if(this.AFAL_CLDO.invalid){
+      this.AFAL_CLDO.markAsTouched();
+      hasErrorForm = true;
+    }
 
-    if (maxSizeMB == 0) {
-      this.openSnackBar(`Los archivos ${extStr} no están soportados`);
-    } else {
-      let maxFileSize = 1048576 * maxSizeMB;
-      let fileSize = event.target.files[0].size;
+    if(this.AFAL_COMO.invalid){
+      this.AFAL_COMO.markAsTouched();
+      hasErrorForm = true;
+    }
 
-      if (fileSize > maxFileSize) {
-        this.openSnackBar(
-          `El tamaño del archivo supera el límite de ${maxSizeMB} MB`
-        );
-      } else {
-        let alreadyAttached = false;
-        this.attached.forEach((file) => {
-          alreadyAttached =
-            file.name == event.target.files[0].name &&
-            file.size == this.formatBytes(event.target.files[0].size);
-        });
+    if(this.AFAL_USAC.invalid){
+      this.AFAL_USAC.markAsTouched();
+      hasErrorForm = true;
+    }
 
-        if (alreadyAttached) {
-          this.openSnackBar('El archivo seleccionado ya fue adjuntado.');
-        } else {
-          this.isUploading = true;
-          this.uploadTmp(event.target.files[0]);
-        }
-      }
+    if(hasErrorForm){
+      this.openSnackBar('Antes de continuar debe completar los campos señalados.');
+    }else{
+      console.log('ya paso');
+      let attachedStr = JSON.stringify(this.attached);
+      let idEnc = localStorage.getItem('idusuario');
+      let audience = this.AFAL_USAC.value;
+
+      let body = {
+        id_user: idEnc,
+        linea: 1,
+        audiencia: audience,
+        archivos: attachedStr,
+        cldo: this.AFAL_CLDO.value,
+        como: this.AFAL_COMO,
+        noar: this.AFAL_NOAR
+      };
+
+      console.log(body);
+      
     }
+
   }
 
   async uploadTmp(fileData: any) {
@@ -347,12 +345,12 @@ export class ADDOComponent implements OnInit {
   }
 
   async downloadFile(idFile: string) {
-    /*     try{
+    try{
       let shortAvi = await lastValueFrom(this._encService.shortEncrypt(idFile));
       let idEnc = localStorage.getItem('idusuario');
       let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc!));
 
-      let downloadToken = await lastValueFrom(this._advicesService.getDownloadToken(shortAvi.response.encrypted, shortEnc.response.encrypted, 1));
+      let downloadToken = await lastValueFrom(this._documentManagement.getDownloadToken(shortAvi.response.encrypted, shortEnc.response.encrypted, 1));
       //this.downloadLink = "http://git.ittec.mx/sam/public/api/download-file///1";
       this.downloadLink = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
       console.log(this.downloadLink);
@@ -368,10 +366,10 @@ export class ADDOComponent implements OnInit {
       }
 
       this.openSnackBar(msg);
-    } */
+    } 
   }
 
-  public async consultarModulos() {
+  public async getModulesInfo() {
     this.isLoading = true;
     await lastValueFrom(this._moduloService.getModules()).then(
       (data: ResponseData) => {
@@ -384,6 +382,51 @@ export class ADDOComponent implements OnInit {
     this.isLoading = false;
   }
 
+  checkFile(event: any) {
+    let fileTypes = availableFiles;
+    let sizes = Object.keys(fileTypes);
+    let extensions = Object.values(fileTypes);
+    let maxSizeMB = 0;
+
+    let extArr = event.target.files[0].name.split('.').reverse();
+    let extStr = extArr[0];
+
+    let i = 0;
+    extensions.forEach((ext) => {
+      let size = parseInt(sizes[i]);
+
+      if (ext.includes(extStr)) maxSizeMB = size;
+      i++;
+    });
+
+    if (maxSizeMB == 0) {
+      this.openSnackBar(`Los archivos ${extStr} no están soportados`);
+    } else {
+      let maxFileSize = 1048576 * maxSizeMB;
+      let fileSize = event.target.files[0].size;
+
+      if (fileSize > maxFileSize) {
+        this.openSnackBar(
+          `El tamaño del archivo supera el límite de ${maxSizeMB} MB`
+        );
+      } else {
+        let alreadyAttached = false;
+        this.attached.forEach((file) => {
+          alreadyAttached =
+            file.name == event.target.files[0].name &&
+            file.size == this.formatBytes(event.target.files[0].size);
+        });
+
+        if (alreadyAttached) {
+          this.openSnackBar('El archivo seleccionado ya fue adjuntado.');
+        } else {
+          this.isUploading = true;
+          this.uploadTmp(event.target.files[0]);
+        }
+      }
+    }
+  }
+
   formatBytes(bytes: number, decimals = 2) {
     if (bytes === 0) return '0 Bytes';
 

+ 6 - 4
sistema-mantenimiento-front/src/app/components/gdel/gdel.component.html

@@ -62,7 +62,7 @@
                                     <mat-icon>note_add</mat-icon>
                                 </button>
                                 <button mat-mini-fab color="info" matTooltip="Actualizar Datos"
-                                    class="override-no-shadow mr-10" (click)="getDocuments()">
+                                    class="override-no-shadow mr-10" (click)="refreshDocuments()">
                                     <mat-icon>refresh</mat-icon>
                                 </button>
                             </div>
@@ -79,7 +79,7 @@
                                         <th mat-header-cell *matHeaderCellDef mat-sort-header>Código</th>
                                         <td mat-cell *matCellDef="let row"
                                             style="overflow:hidden; white-space:nowrap; text-overflow: ellipsis;">{{
-                                            row.ID }} </td>
+                                            row.NOMBRE_ARC }} </td>
                                     </ng-container>
 
                                     <ng-container matColumnDef="NAME">
@@ -134,9 +134,11 @@
                                                     <mat-icon>history</mat-icon>
                                                 </button>
                                                 <button mat-mini-fab color="info" class="override-no-shadow mr-4"
-                                                    matTooltip="Descargar">
+                                                    matTooltip="Descargar" (click)="downloadFile(element.ID)">
                                                     <mat-icon>download</mat-icon>
                                                 </button>
+                                                <a #download [href]="downloadLink" target="_blank" [download]="element.NOMBRE_ARC"></a>
+
                                                 <button mat-mini-fab color="warn" class="override-no-shadow mr-4"
                                                     matTooltip="Eliminar">
                                                     <mat-icon>delete</mat-icon>
@@ -162,7 +164,7 @@
                                                     <button mat-menu-item>
                                                         <mat-icon>history</mat-icon> Historial de Versiones
                                                     </button>
-                                                    <button mat-menu-item>
+                                                    <button mat-menu-item (click)="downloadFile(element.ID)">
                                                         <mat-icon>download</mat-icon> Descargar
                                                     </button>
                                                     <button mat-menu-item>

+ 74 - 40
sistema-mantenimiento-front/src/app/components/gdel/gdel.component.ts

@@ -33,6 +33,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
   public dataSource: MatTableDataSource<any>;
   @ViewChild(MatPaginator) paginator!: MatPaginator;
   @ViewChild(MatSort) sort!: MatSort;
+  @ViewChild('download') a?: ElementRef;
 
   public isLoading: boolean;
   public isLoadingForm: boolean;
@@ -41,6 +42,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
   public ulOptSmall: boolean;
   public txtBuscador: string;
   public clickedIndex: any = 0;
+  public downloadLink: String;
   public options = [
     {
       id: 1,
@@ -65,7 +67,6 @@ export class GDELComponent implements AfterViewInit, OnInit {
     private _dialog: MatDialog,
     private _router: Router,
     public dialog: MatDialog,
-    private _documentManagement: DocumentManagementService,
     private _gdelService: GdelService,
     private _snackBar: MatSnackBar
   ) {
@@ -85,6 +86,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
     this.btnSmall = false;
     this.ulOptSmall = false;
     this.txtBuscador = '';
+    this.downloadLink = '';
   }
 
   ngOnInit(): void {
@@ -132,25 +134,39 @@ export class GDELComponent implements AfterViewInit, OnInit {
     let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc));
 
     let documents: any = await lastValueFrom(
-      this._gdelService.getDocumentsByUser(
-        shortEnc.response.encrypted,
-        1
-      )
+      this._gdelService.getDocumentsByUser(shortEnc.response.encrypted, 1)
     );
 
     if (documents.error) {
       this.openSnackBar(documents.msg);
     } else {
       for (let index = 0; index < documents.response.length; index++) {
+        let codeSAM =
+          documents.response[index].NUMERO_LINEA +
+          '-' +
+          documents.response[index].MODULO +
+          '-' +
+          documents.response[index].CLASIFICACION +
+          '-' +
+          documents.response[index].FECHA_REGISTRO +
+          '-' +
+          documents.response[index].SECUENCIAL +
+          '=' +
+          documents.response[index].VERSION +
+          '=' +
+          documents.response[index].NOMBRE_ARC +
+          '.' +
+          documents.response[index].EXTENSION;
+        let encript = await this._encService.encriptar(codeSAM);
+        let short = await lastValueFrom(this._encService.shortEncrypt(encript));
+        documents.response[index].ID = short.response.encrypted;
         documents.response[index].TAMANIO = this.formatBytes(
           documents.response[index].TAMANIO
         );
       }
       this.dataSource.data = documents.response;
       this.isLoading = false;
-
     }
-    console.log(documents);
   }
 
   async modifyDocument(idDocument: number) {
@@ -183,25 +199,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
     this.ulOptSmall = window.innerWidth <= 1405;
   }
 
-  selectTab(index: number) {
-    this.active = index;
-    console.log(index);
-    
-    switch (index) {
-      case 0:
-        this.getDocuments();
-        break;
-      case 1:
-        this.getShareDocuments();
-        break;
-      case 2:
-        break;
-      default:
-        break;
-    }
-  }
-
-  public openViewer(url: string) {
+   public openViewer(url: string) {
     let dialogRef: any;
     let fileData = {
       url: url,
@@ -257,31 +255,36 @@ export class GDELComponent implements AfterViewInit, OnInit {
   }
 
   // Funcion para descargar archivos
-  async downloadFile(idFile: string) {
-    console.log('descargar archivo');
-
-    /*     try{
-      let shortAvi = await lastValueFrom(this._encService.shortEncrypt(idFile));
+  async downloadFile(idFile: any) {
+    try {
       let idEnc = localStorage.getItem('idusuario');
       let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc!));
 
-      let downloadToken = await lastValueFrom(this._advicesService.getDownloadToken(shortAvi.response.encrypted, shortEnc.response.encrypted, 1));
-      //this.downloadLink = "http://git.ittec.mx/sam/public/api/download-file///1";
-      this.downloadLink = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
-      console.log(this.downloadLink);
+      let downloadToken = await lastValueFrom(
+        this._gdelService.getDownloadToken(
+          idFile,
+          shortEnc.response.encrypted,
+          1
+        )
+      );
+      //this.downloadL  ink = "http://git.ittec.mx/sam/public/api/download-file///1";
+      //this.downloadLink = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
+      this.downloadLink = `http://192.168.1.2:8000/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
+      console.log(this.downloadLink );
+      
       this.a?.nativeElement.click();
-    }catch(error: any){
+    } catch (error: any) {
       let msg = '';
-      if(error.error == undefined){
+      if (error.error == undefined) {
         msg = 'Ocurrió un error inesperado.';
-      }else if(error.error.msg == undefined){
+      } else if (error.error.msg == undefined) {
         msg = 'Ocurrió un error inesperado.';
-      }else{
+      } else {
         msg = error.error.msg;
       }
 
       this.openSnackBar(msg);
-    } */
+    }
   }
 
   public goBack(steps: number) {
@@ -305,4 +308,35 @@ export class GDELComponent implements AfterViewInit, OnInit {
       duration: 2500,
     });
   }
+
+  selectTab(index: number) {
+    this.active = index;
+    switch (index) {
+      case 0:
+        this.getDocuments();
+        break;
+      case 1:
+        this.getShareDocuments();
+        break;
+      case 2:
+        break;
+      default:
+        break;
+    }
+  }
+
+  refreshDocuments() {
+    switch (this.active) {
+      case 0:
+        this.getDocuments();
+        break;
+      case 1:
+        this.getShareDocuments();
+        break;
+      case 2:
+        break;
+      default:
+        break;
+    }
+  }
 }

+ 3 - 0
sistema-mantenimiento-front/src/app/components/system-admin/advices/new-advice/new-advice.component.ts

@@ -251,6 +251,7 @@ export class NewAdviceComponent implements OnInit {
       this.adviceHour.setValue(caduArr[1]);
 
       let adjuStr = advice.response.ADJUNTOS;
+      
       let adjuArr = JSON.parse(adjuStr);
 
       adjuArr.forEach((adju: any) => {
@@ -352,6 +353,8 @@ export class NewAdviceComponent implements OnInit {
   }
 
   async downloadFile(idFile: string){
+    console.log(idFile);
+    
     try{
       this.downloadEnabled = false;
 

+ 2 - 0
sistema-mantenimiento-front/src/app/services/gdel/document-management.service.ts

@@ -23,6 +23,8 @@ export class DocumentManagementService {
     return this.postQuery('delete-file', body).pipe(map((data: any) => data));
   }
 
+  
+
   getQuery(query: string) {
     const JWT = `Bearer ${localStorage.getItem('token')}`;
     const URL = `${apiTemp}${query}`;

+ 19 - 1
sistema-mantenimiento-front/src/app/services/gdel/gdel.service.ts

@@ -19,11 +19,29 @@ export class GdelService {
     const URL = `${apiUriAlan}${query}`;
     return this.http.get(URL, {
       headers: new HttpHeaders({
-        Authorization: JWT
+        Authorization: JWT,
       })
     });
   }
 
+  getFileInfo(id: string, idUser: string, line: number) {
+    return this.getQuery(`get-file-info/${id}/${idUser}/${line}`).pipe(
+      map((data: any) => data)
+    );
+  }
+
+  uploadTempFile(body: any) {
+    return this.postQuery('upload-file', body).pipe(map((data: any) => data));
+  }
+
+  deleteTempFile(body: any) {
+    return this.postQuery('delete-file', body).pipe(map((data: any) => data));
+  }
+
+  getDownloadToken(id: string, idUser: string, line: number){
+    return this.getQuery(`get-download-token/${id}/${idUser}/${line}`).pipe(map((data: any) => data));
+  }
+
   postQuery(query: string, body: any){
     const JWT = `Bearer ${localStorage.getItem('token')}`;
     const URL = `${apiUriAlan}${query}`;