|
|
@@ -1,4 +1,5 @@
|
|
|
import { FinalFileResponse } from './../../../../interfaces/final-file.interface';
|
|
|
+import * as socketService from './../../../../services/socket.service';
|
|
|
import { DocumentManagementService } from './../../../../services/gdel/document-management.service';
|
|
|
import { SocketService } from './../../../../services/socket.service';
|
|
|
import { AdvicesService } from './../../../../services/advices.service';
|
|
|
@@ -84,10 +85,10 @@ export class NewAdviceComponent implements OnInit {
|
|
|
private _snackBar: MatSnackBar,
|
|
|
private _dialg: MatDialog,
|
|
|
private _advicesService: AdvicesService,
|
|
|
- private _socketService: SocketService,
|
|
|
- private _route: ActivatedRoute,
|
|
|
+ private _socketService: socketService.SocketService,
|
|
|
+ private _route: ActivatedRoute,
|
|
|
private _documentManagement: DocumentManagementService,
|
|
|
- ) {
|
|
|
+ ) {
|
|
|
this.isLoading = true;
|
|
|
this.isUploading = false;
|
|
|
this.hasError = false;
|
|
|
@@ -150,7 +151,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
let idEnc = localStorage.getItem('idusuario')!;
|
|
|
let idDec = await this._encService.desencriptar(idEnc);
|
|
|
let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc));
|
|
|
-
|
|
|
+
|
|
|
let users: UsersResponse = await lastValueFrom(this._usersProfilesService.getUsers(shortEnc.response.encrypted, 1));
|
|
|
this.errorStr = users.msg;
|
|
|
this.hasError = users.error;
|
|
|
@@ -180,16 +181,16 @@ export class NewAdviceComponent implements OnInit {
|
|
|
});
|
|
|
|
|
|
this.divisions.push(profilesGroup);
|
|
|
-
|
|
|
+
|
|
|
let usersGroup: DivisionGroup = {
|
|
|
name: 'Usuarios',
|
|
|
division: []
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
users.response.forEach(user => {
|
|
|
let userName = this.buildName(user.NOMBRE, user.APEPAT, user.APEMAT);
|
|
|
let userID = `user-${user.IDUSUARIO}`;
|
|
|
-
|
|
|
+
|
|
|
let userDisplay: Division = {
|
|
|
value: userID,
|
|
|
viewValue: userName
|
|
|
@@ -201,7 +202,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
});
|
|
|
|
|
|
this.divisions.push(usersGroup);
|
|
|
-
|
|
|
+
|
|
|
if(this.isNew){
|
|
|
let initialFiles: TempFileInfo[] = [];
|
|
|
this.dataSource = new MatTableDataSource(initialFiles);
|
|
|
@@ -227,7 +228,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
async getAdvice(idAvi: string){
|
|
|
try{
|
|
|
let aviShort = await lastValueFrom(this._encService.shortEncrypt(idAvi));
|
|
|
-
|
|
|
+
|
|
|
let idEnc = localStorage.getItem('idusuario');
|
|
|
let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc!));
|
|
|
|
|
|
@@ -242,7 +243,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
let cadu = advice.response.CADUCIDAD;
|
|
|
let caduArr = cadu.split(' ');
|
|
|
let caduObj = new Date(`${caduArr[0]}T00:00:00.000`);
|
|
|
-
|
|
|
+
|
|
|
this.adviceDate.setValue(caduObj.toISOString());
|
|
|
this.adviceHour.setValue(caduArr[1]);
|
|
|
|
|
|
@@ -258,11 +259,11 @@ export class NewAdviceComponent implements OnInit {
|
|
|
name: idDec,
|
|
|
size: this.formatBytes(file.response.PESO)
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
this.attached.push(fileInfo);
|
|
|
});
|
|
|
this.dataSource = new MatTableDataSource(this.attached);
|
|
|
-
|
|
|
+
|
|
|
this.getData();
|
|
|
}catch(error: any){
|
|
|
this.isLoading = false;
|
|
|
@@ -311,7 +312,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
let date = this.adviceDate.value;
|
|
|
let time = this.adviceHour.value;
|
|
|
let dateTime = '';
|
|
|
-
|
|
|
+
|
|
|
if(typeof date == 'string'){
|
|
|
dateTime = `${date.split('T')[0]} ${time}`;
|
|
|
}else{
|
|
|
@@ -380,7 +381,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
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];
|
|
|
|
|
|
@@ -435,7 +436,7 @@ export class NewAdviceComponent implements OnInit {
|
|
|
name: fileData.name,
|
|
|
size: this.formatBytes(fileData.size),
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
this.attached.push(uploadedFile);
|
|
|
this.dataSource = new MatTableDataSource(this.attached);
|
|
|
this.isUploading = false;
|
|
|
@@ -582,9 +583,9 @@ export class NewAdviceComponent implements OnInit {
|
|
|
try{
|
|
|
let response = await lastValueFrom(this._advicesService.publishAdvice(body));
|
|
|
let idav = response.response.idav;
|
|
|
-
|
|
|
+
|
|
|
this._socketService.publishAdvice(idav);
|
|
|
-
|
|
|
+
|
|
|
this.openSnackBar('Aviso publicado correctamente');
|
|
|
}catch(error: any){
|
|
|
let msg = '';
|