From afadcc1e3abfe2d01503a4aee7eb3a1feffce955 Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Wed, 11 Mar 2026 12:46:24 +0100 Subject: [PATCH] add html file upload via base64 for menus --- CHANGELOG.md | 7 +++++ .../create-menu/create-menu.component.html | 11 +++++++- .../create-menu/create-menu.component.ts | 27 ++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2893fdd..00882c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog +## [1.2.1] - 2026-03-11 +### Added +- Se ha añadido la funcionalidad para poder adjuntar un fichero HTML local en la creación/edición de menús, codificándolo y enviándolo en Base64 de forma transparente. + +### Improved +- Se ha mejorado la UX integrando el campo de subida de ficheros en el formulario de menús (`create-menu`) utilizando la estética nativa de Angular Material. + ## [1.2.0] - 2025-10-21 ### Added - Se ha añadido una nueva funcionalidad la cual permite poder borrar varios equipos a la vez. diff --git a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html index d1ddfa3..8f37679 100644 --- a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html +++ b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.html @@ -15,13 +15,21 @@ + + Suba el fichero que se usará como menú + + + + Resolución 640×480 (8-bit - 256 colores) 800×600 (8-bit - 256 colores) 1024×768 (8-bit - 256 colores) - 1280×1024 (8-bit - 256 colores) + 1280×1024 (8-bit - 256 colores) 640×480 (16-bit - 65k colores) 800×600 (16-bit - 65k colores) 1024×768 (16-bit - 65k colores) @@ -41,6 +49,7 @@ {{ 'defaultMenuLabel' | translate }} + diff --git a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts index b4dc91d..41cd393 100644 --- a/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts +++ b/ogWebconsole/src/app/components/menus/create-menu/create-menu.component.ts @@ -18,6 +18,8 @@ export class CreateMenuComponent implements OnInit { menuId: string | null = null; softwareProfiles: any[] = []; safeUrl: SafeResourceUrl | null = null; + selectedFile: File | null = null; + fileContent: string | null = null; constructor( private fb: FormBuilder, @@ -48,6 +50,25 @@ export class CreateMenuComponent implements OnInit { } } + onFileSelected(event: any): void { + const file = event.target.files[0]; + if (file) { + this.selectedFile = file; + + const reader = new FileReader(); + reader.onload = (e: any) => { + // e.target.result será un string en formato 'data:text/html;base64,.....' + // Nos quedamos solo con la parte Base64 dividiendo por la coma + const base64String = e.target.result.split(',')[1]; + this.fileContent = base64String; + }; + reader.readAsDataURL(file); + } else { + this.selectedFile = null; + this.fileContent = null; + } + } + ngOnInit() { if (this.data) { this.load() @@ -74,7 +95,7 @@ export class CreateMenuComponent implements OnInit { } save(): void { - const payload = { + const payload: any = { name: this.menuForm.value.name, publicUrl: this.menuForm.value.publicUrl, resolution: this.menuForm.value.resolution, @@ -82,6 +103,10 @@ export class CreateMenuComponent implements OnInit { isDefault: this.menuForm.value.isDefault, }; + if (this.fileContent) { + payload.menuHtmlContent = this.fileContent; + } + if (this.menuId) { this.http.put(`${this.baseUrl}${this.menuId}`, payload).subscribe( (response) => {