|
|
@@ -1,18 +1,27 @@
|
|
|
import { Component, Inject, OnInit } from '@angular/core';
|
|
|
-import { NotificationAction, NotificationDetailsResponse, NotificationsListItem } from '../../../interfaces/notification.interface';
|
|
|
-import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
|
|
|
+import {
|
|
|
+ NotificationAction,
|
|
|
+ NotificationDetailsResponse,
|
|
|
+ NotificationsListItem,
|
|
|
+} from '../../../interfaces/notification.interface';
|
|
|
+import {
|
|
|
+ MAT_DIALOG_DATA,
|
|
|
+ MatDialog,
|
|
|
+ MatDialogRef,
|
|
|
+} from '@angular/material/dialog';
|
|
|
import { EncService } from '../../../services/enc.service';
|
|
|
import { NotificationsService } from '../../../services/notifications.service';
|
|
|
import { ResourcesService } from '../../../services/resources.service';
|
|
|
import { CorrectiveMaintenanceService } from '../../../services/corrective-maintenance.service';
|
|
|
+import { GdelService } from '../../../services/gdel.service';
|
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
import { CorrectiveOrderDetailsComponent } from '../../corrective-maintenance/operations-management/corrective-order-details/corrective-order-details.component';
|
|
|
|
|
|
@Component({
|
|
|
- selector: 'app-notification-dialog',
|
|
|
- templateUrl: './notification-dialog.component.html',
|
|
|
- styleUrl: './notification-dialog.component.css',
|
|
|
- standalone: false
|
|
|
+ selector: 'app-notification-dialog',
|
|
|
+ templateUrl: './notification-dialog.component.html',
|
|
|
+ styleUrl: './notification-dialog.component.css',
|
|
|
+ standalone: false,
|
|
|
})
|
|
|
export class NotificationDialogComponent implements OnInit {
|
|
|
idNotification: string;
|
|
|
@@ -29,7 +38,8 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
private _dialog: MatDialog,
|
|
|
private _resourcesService: ResourcesService,
|
|
|
private _correctiveMaintenanceService: CorrectiveMaintenanceService,
|
|
|
- private _dialogRef: MatDialogRef<NotificationDialogComponent>,
|
|
|
+ private _gdelService: GdelService,
|
|
|
+ private _dialogRef: MatDialogRef<NotificationDialogComponent>
|
|
|
) {
|
|
|
this.idNotification = '';
|
|
|
this.isLoading = true;
|
|
|
@@ -42,30 +52,38 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
this.init();
|
|
|
}
|
|
|
|
|
|
- async init(){
|
|
|
- this.idNotification = await this._encService.decrypt(this._data.idNotification);
|
|
|
+ async init() {
|
|
|
+ this.idNotification = await this._encService.decrypt(
|
|
|
+ this._data.idNotification
|
|
|
+ );
|
|
|
this.getNotification();
|
|
|
}
|
|
|
|
|
|
- async getNotification(){
|
|
|
- try{
|
|
|
+ async getNotification() {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let notification: NotificationDetailsResponse = await lastValueFrom(this._notificationsService.getNotification(
|
|
|
- this._data.idNotification,
|
|
|
- 'S',
|
|
|
- idUser,
|
|
|
- 1
|
|
|
- ));
|
|
|
+ let notification: NotificationDetailsResponse = await lastValueFrom(
|
|
|
+ this._notificationsService.getNotification(
|
|
|
+ this._data.idNotification,
|
|
|
+ 'S',
|
|
|
+ idUser,
|
|
|
+ 1
|
|
|
+ )
|
|
|
+ );
|
|
|
|
|
|
this.hasError = notification.error;
|
|
|
this.errorStr = notification.msg;
|
|
|
|
|
|
- if(!this.hasError){
|
|
|
- let notificationActionsArr: NotificationAction[] = JSON.parse(notification.response.ACCIONES);
|
|
|
-
|
|
|
+ if (!this.hasError) {
|
|
|
+ let notificationActionsArr: NotificationAction[] = JSON.parse(
|
|
|
+ notification.response.ACCIONES
|
|
|
+ );
|
|
|
+
|
|
|
notification.response.ACCIONES_ARR = notificationActionsArr;
|
|
|
if (notification.response.ID_ORDEN !== null) {
|
|
|
- notification.response.ID_ORDEN = await this._encService.decrypt(notification.response.ID_ORDEN);
|
|
|
+ notification.response.ID_ORDEN = await this._encService.decrypt(
|
|
|
+ notification.response.ID_ORDEN
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
this.notification = notification.response;
|
|
|
@@ -73,14 +91,14 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
this.isLoading = false;
|
|
|
- }catch(error: any){
|
|
|
+ } catch (error: any) {
|
|
|
console.log(error);
|
|
|
-
|
|
|
- if(error.error == undefined){
|
|
|
+
|
|
|
+ if (error.error == undefined) {
|
|
|
this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.errorStr = error.error.msg;
|
|
|
}
|
|
|
|
|
|
@@ -89,38 +107,65 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- executeNotificationAction(func: string, params: string){
|
|
|
+ executeNotificationAction(func: string, params: string) {
|
|
|
let paramsArr = JSON.parse(params);
|
|
|
- switch(func){
|
|
|
- case "openCorrectiveWorkOrderDetails":
|
|
|
+ switch (func) {
|
|
|
+ case 'openCorrectiveWorkOrderDetails':
|
|
|
this.openCorrectiveWorkOrderDetails(paramsArr[0]);
|
|
|
- break;
|
|
|
- case "validateCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'validateCorrectiveWorkOrder':
|
|
|
this.validateCorrectiveWorkOrder(paramsArr[0]);
|
|
|
- break;
|
|
|
- case "openModule":
|
|
|
+ break;
|
|
|
+ case 'openModule':
|
|
|
console.log(paramsArr[0]);
|
|
|
-
|
|
|
+
|
|
|
this._dialogRef.close(`go|${paramsArr[0]}`);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case 'processLoadArchives':
|
|
|
+ this.processLoadArchives(paramsArr);
|
|
|
+ break;
|
|
|
default:
|
|
|
- this._resourcesService.openSnackBar('La función seleccionada no existe.');
|
|
|
- break;
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La función seleccionada no existe.'
|
|
|
+ );
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//FUNCIONES POSIBLES PARA LAS NOTIFICACIONES
|
|
|
- openCorrectiveWorkOrderDetails(idOrder: string){
|
|
|
+ async processLoadArchives(params: any) {
|
|
|
+ try {
|
|
|
+ let idUser = localStorage.getItem('idusuario')!;
|
|
|
+ let body = {
|
|
|
+ id_user: idUser,
|
|
|
+ linea: '1',
|
|
|
+ temp_files: params.temp_files,
|
|
|
+ individual_temp_files: params.individual_temp_files
|
|
|
+ };
|
|
|
+
|
|
|
+ await lastValueFrom(this._gdelService.processZipFile(body));
|
|
|
+ this._resourcesService.openSnackBar('Archivos procesados correctamente.');
|
|
|
+ this._dialogRef.close();
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error?.msg) {
|
|
|
+ this._resourcesService.openSnackBar(error.error.msg);
|
|
|
+ } else {
|
|
|
+ this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ openCorrectiveWorkOrderDetails(idOrder: string) {
|
|
|
this._dialog.open(CorrectiveOrderDetailsComponent, {
|
|
|
width: '480px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
- }
|
|
|
- })
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- async validateCorrectiveWorkOrder(idOrder: string){
|
|
|
- try{
|
|
|
+ async validateCorrectiveWorkOrder(idOrder: string) {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
let formData = new FormData();
|
|
|
|
|
|
@@ -128,15 +173,19 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
formData.append('linea', '1');
|
|
|
formData.append('id_order', idOrder);
|
|
|
|
|
|
- await lastValueFrom(this._correctiveMaintenanceService.approveWorkOrder(formData));
|
|
|
- this._resourcesService.openSnackBar('La orden de trabajo se aprobó correctamente.');
|
|
|
+ await lastValueFrom(
|
|
|
+ this._correctiveMaintenanceService.approveWorkOrder(formData)
|
|
|
+ );
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La orden de trabajo se aprobó correctamente.'
|
|
|
+ );
|
|
|
this._dialogRef.close();
|
|
|
- }catch(error: any){
|
|
|
- if(error.error.msg == undefined){
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error.msg == undefined) {
|
|
|
this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this._resourcesService.openSnackBar(error.error.msg);
|
|
|
}
|
|
|
}
|