utn-cli 2.0.40 → 2.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/templates/frontend/src/app/Componentes/Nucleo/subir-archivo/subir-archivo.component.html
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<p>Archivo seleccionado: {{ Archivo.name }}</p>
|
|
27
27
|
}
|
|
28
28
|
<!-- Input oculto para seleccionar archivos manualmente -->
|
|
29
|
-
<input type="file" #EntradDeArchivo hidden (change)="ArchivoSeleccionado($event)">
|
|
29
|
+
<input type="file" #EntradDeArchivo hidden (change)="ArchivoSeleccionado($event)" [accept]="FormatosPermitidos.join(',')">
|
|
30
30
|
</div>
|
|
31
31
|
} @else {
|
|
32
32
|
@if(ListaArchivos.length === 0) {
|
package/templates/frontend/src/app/Componentes/Nucleo/subir-archivo/subir-archivo.component.ts
CHANGED
|
@@ -20,6 +20,7 @@ export class SubirArchivoComponent implements OnInit {
|
|
|
20
20
|
Permiso = '--Permiso=' + this.data.Permiso;
|
|
21
21
|
Etiqueta = this.data.Etiqueta + this.Permiso;
|
|
22
22
|
EsEditable = this.data.EsEditable;
|
|
23
|
+
FormatosPermitidos: string[] = [];
|
|
23
24
|
Token: any;
|
|
24
25
|
public RutaParaListar: string = 'misc/listarArchivos/';
|
|
25
26
|
public RutaParaDescargar: string = 'misc/descargarArchivo/';
|
|
@@ -32,6 +33,9 @@ export class SubirArchivoComponent implements OnInit {
|
|
|
32
33
|
if (this.data.RutaParaDescargar) {
|
|
33
34
|
this.RutaParaDescargar = this.data.RutaParaDescargar;
|
|
34
35
|
}
|
|
36
|
+
if (this.data.FormatosPermitidos) {
|
|
37
|
+
this.FormatosPermitidos = this.data.FormatosPermitidos;
|
|
38
|
+
}
|
|
35
39
|
this.ListarArchivos(this.Etiqueta)
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -53,15 +57,34 @@ export class SubirArchivoComponent implements OnInit {
|
|
|
53
57
|
const archivoZona = event.target as HTMLElement;
|
|
54
58
|
archivoZona.classList.remove('arrastrar');
|
|
55
59
|
if (event.dataTransfer?.files.length && this.EsEditable) {
|
|
56
|
-
|
|
60
|
+
const archivoArrastrado = event.dataTransfer.files[0];
|
|
61
|
+
if (this.ValidarFormato(archivoArrastrado)) {
|
|
62
|
+
this.Archivo = archivoArrastrado;
|
|
63
|
+
} else {
|
|
64
|
+
alert('Formato de archivo no permitido. Los formatos permitidos son: ' + this.FormatosPermitidos.join(', '));
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
ArchivoSeleccionado(event: Event) {
|
|
61
70
|
const entrada = event.target as HTMLInputElement;
|
|
62
71
|
if (entrada.files?.length) {
|
|
63
|
-
|
|
72
|
+
const archivoSeleccionado = entrada.files[0];
|
|
73
|
+
if (this.ValidarFormato(archivoSeleccionado)) {
|
|
74
|
+
this.Archivo = archivoSeleccionado;
|
|
75
|
+
} else {
|
|
76
|
+
alert('Formato de archivo no permitido. Los formatos permitidos son: ' + this.FormatosPermitidos.join(', '));
|
|
77
|
+
entrada.value = ''; // Limpiar el input
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ValidarFormato(archivo: File): boolean {
|
|
83
|
+
if (this.FormatosPermitidos.length === 0) {
|
|
84
|
+
return true;
|
|
64
85
|
}
|
|
86
|
+
const nombreArchivo = archivo.name.toLowerCase();
|
|
87
|
+
return this.FormatosPermitidos.some(formato => nombreArchivo.endsWith(formato.toLowerCase()));
|
|
65
88
|
}
|
|
66
89
|
|
|
67
90
|
AbrirGestorDeArchivos() {
|