|
|
@@ -17,6 +17,11 @@ import { ResourcesService } from 'src/app/services/resources/resources.service';
|
|
|
import { CommnetsDialogComponent } from './commnets-dialog/commnets-dialog.component';
|
|
|
import { TransferOrderDialogComponent } from './transfer-order-dialog/transfer-order-dialog.component';
|
|
|
import { StatusTimelineComponent } from './status-timeline/status-timeline.component';
|
|
|
+import { Permissions, PermissionsInterface } from 'src/app/interfaces/permissions.interface';
|
|
|
+import { SocketService } from 'src/app/services/socket.service';
|
|
|
+import { UserConsultResponse } from 'src/app/interfaces/user.interface';
|
|
|
+import { UsersProfilesService } from 'src/app/services/users-profiles.service';
|
|
|
+import { ProfileInterface } from 'src/app/interfaces/profile.interface';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-operations-management',
|
|
|
@@ -39,6 +44,11 @@ export class OperationsManagementComponent implements OnInit {
|
|
|
@ViewChild(MatPaginator) paginator?: MatPaginator;
|
|
|
@ViewChild(MatSort) sort?: MatSort;
|
|
|
|
|
|
+ operationsConsultEnabled: boolean;
|
|
|
+ /*manualActivationEnabled: boolean;
|
|
|
+ workOrderGenerationEnabled: boolean;
|
|
|
+ workOrderTransfer: boolean;*/
|
|
|
+
|
|
|
constructor(
|
|
|
private _activatedRoute: ActivatedRoute,
|
|
|
private _router: Router,
|
|
|
@@ -48,6 +58,8 @@ export class OperationsManagementComponent implements OnInit {
|
|
|
private _functionsService: FunctionsService,
|
|
|
private _dialog: MatDialog,
|
|
|
private _resourcesService: ResourcesService,
|
|
|
+ private _socketService: SocketService,
|
|
|
+ private _usersProfilesService: UsersProfilesService,
|
|
|
) {
|
|
|
this.isLoading = true;
|
|
|
this.hasError = false;
|
|
|
@@ -57,6 +69,8 @@ export class OperationsManagementComponent implements OnInit {
|
|
|
|
|
|
this.txtBuscador = '';
|
|
|
this.btnSmall = window.innerWidth <= 1405;
|
|
|
+
|
|
|
+ this.operationsConsultEnabled = true;
|
|
|
}
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
@@ -68,6 +82,58 @@ export class OperationsManagementComponent implements OnInit {
|
|
|
this.init(data);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ this._socketService.refreshPermissions().subscribe(async (profUpdEnc) => {
|
|
|
+ try{
|
|
|
+ let idUser = localStorage.getItem('idusuario')!;
|
|
|
+ let usrInfo: UserConsultResponse = await lastValueFrom(this._usersProfilesService.getUser(idUser, idUser, 1));
|
|
|
+
|
|
|
+ if(usrInfo.error){
|
|
|
+ this._resourcesService.openSnackBar('ERR_NPE000: Ocurrió un error inesperado.');
|
|
|
+ }else{
|
|
|
+ let idProfDec = await this._encService.decrypt(usrInfo.response.PERFIL);
|
|
|
+ let currentProfile = await this._encService.decrypt(localStorage.getItem('perfil')!);
|
|
|
+
|
|
|
+ if(idProfDec != currentProfile){
|
|
|
+ this._router.navigate(['/sam/home']);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let profileUpdated = await this._encService.decrypt(`${profUpdEnc}`);
|
|
|
+ if(profileUpdated == currentProfile){
|
|
|
+ let profile = localStorage.getItem('perfil')!;
|
|
|
+ let profInfo: ProfileInterface = await lastValueFrom(this._usersProfilesService.getProfile(
|
|
|
+ profile,
|
|
|
+ idUser,
|
|
|
+ 1
|
|
|
+ ));
|
|
|
+
|
|
|
+ let permArr = await this._functionsService.processPermissions(profInfo.response.PERMISOS.permissions);
|
|
|
+ let modPerm = permArr.filter(item => item.id == 'S002V01M09GMCO');
|
|
|
+ if(modPerm.length > 0){
|
|
|
+ let subPerm = modPerm[0].children.filter(item => item.id == 'S002V01S01ORTR');
|
|
|
+ if(subPerm.length > 0){
|
|
|
+ let funPerm = subPerm[0].children.filter(item => item.id == 'S002V01F01GEOP');
|
|
|
+ if(funPerm.length > 0){
|
|
|
+ let operationsConsultEnabled = funPerm[0].children.filter(item => item.id == 'S002V01P01COOP');
|
|
|
+ if(operationsConsultEnabled.length > 0){
|
|
|
+ this.operationsConsultEnabled = operationsConsultEnabled[0].access > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(error: any){
|
|
|
+ if(error.error == undefined){
|
|
|
+ this._resourcesService.openSnackBar('ERR_PAD001: Ocurrió un error inesperado.');
|
|
|
+ }else if(error.error.msg == undefined){
|
|
|
+ this._resourcesService.openSnackBar('ERR_PAD002: Ocurrió un error inesperado.');
|
|
|
+ }else{
|
|
|
+ this._resourcesService.openSnackBar(`ERR_PAD003: ${error.error.msg}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
async init(dataEnc: string){
|
|
|
@@ -157,6 +223,31 @@ export class OperationsManagementComponent implements OnInit {
|
|
|
this.dataSource = new MatTableDataSource(workOrdersArr);
|
|
|
this.dataSource.paginator = this.paginator!;
|
|
|
this.dataSource.sort = this.sort!;
|
|
|
+
|
|
|
+ let permissionsEnc = localStorage.getItem('permisos');
|
|
|
+ let permissionsDec = '';
|
|
|
+ if(permissionsEnc == '' || permissionsEnc == undefined || permissionsEnc == null){
|
|
|
+ permissionsDec = '[]';
|
|
|
+ }else{
|
|
|
+ permissionsDec = await this._encService.decrypt(permissionsEnc!);
|
|
|
+ }
|
|
|
+
|
|
|
+ let permissionsArr: Permissions = JSON.parse(permissionsDec);
|
|
|
+ if(permissionsArr.permissions != undefined){
|
|
|
+ let modPerm = permissionsArr.permissions.filter(item => item.id == 'S002V01M09GMCO');
|
|
|
+ if(modPerm.length > 0){
|
|
|
+ let subPerm = modPerm[0].children.filter(item => item.id == 'S002V01S01ORTR');
|
|
|
+ if(subPerm.length > 0){
|
|
|
+ let funPerm = subPerm[0].children.filter(item => item.id == 'S002V01F01GEOP');
|
|
|
+ if(funPerm.length > 0){
|
|
|
+ let operationsConsultEnabled = funPerm[0].children.filter(item => item.id == 'S002V01P01COOP');
|
|
|
+ if(operationsConsultEnabled.length > 0){
|
|
|
+ this.operationsConsultEnabled = operationsConsultEnabled[0].access > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
this.isLoading = false;
|