diff --git a/apps/admin/src/api/schema.d.ts b/apps/admin/src/api/schema.d.ts index 9a9f430..d1d64a1 100644 --- a/apps/admin/src/api/schema.d.ts +++ b/apps/admin/src/api/schema.d.ts @@ -969,6 +969,7 @@ export interface components { vistaInicialYaw?: number | null; /** Format: double */ vistaInicialPitch?: number | null; + textoAlt?: string | null; }; ActualizarHotspotRequest: { tipo?: components["schemas"]["TipoHotspot"]; @@ -1037,6 +1038,7 @@ export interface components { vistaInicialYaw?: number | null; /** Format: double */ vistaInicialPitch?: number | null; + textoAlt?: string | null; }; CrearHotspotRequest: { /** Format: int32 */ @@ -1115,6 +1117,7 @@ export interface components { vistaInicialYaw?: number | null; /** Format: double */ vistaInicialPitch?: number | null; + textoAlt?: string | null; hotspots?: components["schemas"]["Hotspot"][] | null; }; EscenaDto: { @@ -1134,6 +1137,7 @@ export interface components { vista_inicial_yaw?: number | null; /** Format: double */ vista_inicial_pitch?: number | null; + texto_alt?: string | null; }; Hotspot: { /** Format: int32 */ diff --git a/services/api/DTOs/AdminRequests.cs b/services/api/DTOs/AdminRequests.cs index 22b1592..2bafe1f 100644 --- a/services/api/DTOs/AdminRequests.cs +++ b/services/api/DTOs/AdminRequests.cs @@ -32,8 +32,8 @@ public record ActualizarLugarRequest(string Nombre, string Slug); // --- DTOs de Escena --- // ImagenUrl es opcional: lo normal es crear la escena vacía y luego subir la // panorámica con POST /api/admin/escenas/{id}/imagen. -public record CrearEscenaRequest(int LugarId, int? PoiId, string? Nombre, string? ImagenUrl, string? ImagenUrlBaja, bool EsEscenaPrincipal, int Orden, double? VistaInicialYaw, double? VistaInicialPitch); -public record ActualizarEscenaRequest(int? PoiId, string? Nombre, string? ImagenUrl, string? ImagenUrlBaja, bool EsEscenaPrincipal, int Orden, double? VistaInicialYaw, double? VistaInicialPitch); +public record CrearEscenaRequest(int LugarId, int? PoiId, string? Nombre, string? ImagenUrl, string? ImagenUrlBaja, bool EsEscenaPrincipal, int Orden, double? VistaInicialYaw, double? VistaInicialPitch, string? TextoAlt); +public record ActualizarEscenaRequest(int? PoiId, string? Nombre, string? ImagenUrl, string? ImagenUrlBaja, bool EsEscenaPrincipal, int Orden, double? VistaInicialYaw, double? VistaInicialPitch, string? TextoAlt); // --- DTOs de Hotspot --- public record CrearHotspotRequest(int EscenaId, Models.TipoHotspot Tipo, double Pitch, double Yaw, int? EscenaDestinoId, int? PoiId, string? Etiqueta); diff --git a/services/api/DTOs/ContenidoMappers.cs b/services/api/DTOs/ContenidoMappers.cs index 0053417..78b74ef 100644 --- a/services/api/DTOs/ContenidoMappers.cs +++ b/services/api/DTOs/ContenidoMappers.cs @@ -11,7 +11,7 @@ internal static class Dto public static EscenaDto Escena(Escena e) => new(e.Id, e.LugarId, e.PoiId, e.Nombre, e.ImagenUrl, e.ImagenUrlBaja, e.EsEscenaPrincipal, e.Orden, - e.VistaInicialYaw, e.VistaInicialPitch); + e.VistaInicialYaw, e.VistaInicialPitch, e.TextoAlt); public static HotspotDto Hotspot(Hotspot h) => new(h.Id, h.EscenaId, h.Tipo, h.Pitch, h.Yaw, h.EscenaDestinoId, h.PoiId, h.Etiqueta); diff --git a/services/api/DTOs/EscenaDto.cs b/services/api/DTOs/EscenaDto.cs index 0fec7c2..7ad274d 100644 --- a/services/api/DTOs/EscenaDto.cs +++ b/services/api/DTOs/EscenaDto.cs @@ -4,4 +4,4 @@ namespace TourVirtualUTB.Api.DTOs; public sealed record EscenaDto(int id, int lugar_id, int? poi_id, string? nombre, string? imagen_url, string? imagen_url_baja, bool es_escena_principal, int orden, - double? vista_inicial_yaw, double? vista_inicial_pitch); \ No newline at end of file + double? vista_inicial_yaw, double? vista_inicial_pitch, string? texto_alt); \ No newline at end of file diff --git a/services/api/Migrations/20261111044747_AgregarTextoAltEscena.Designer.cs b/services/api/Migrations/20261111044747_AgregarTextoAltEscena.Designer.cs new file mode 100644 index 0000000..2b907c6 --- /dev/null +++ b/services/api/Migrations/20261111044747_AgregarTextoAltEscena.Designer.cs @@ -0,0 +1,418 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TourVirtualUTB.Api.Data; + +#nullable disable + +namespace TourVirtualUTB.Api.Migrations +{ + [DbContext(typeof(TourDbContext))] + [Migration("20261111044747_AgregarTextoAltEscena")] + partial class AgregarTextoAltEscena + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Escena", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EsEscenaPrincipal") + .HasColumnType("boolean"); + + b.Property("ImagenUrl") + .HasColumnType("text"); + + b.Property("ImagenUrlBaja") + .HasColumnType("text"); + + b.Property("LugarId") + .HasColumnType("integer"); + + b.Property("Nombre") + .HasColumnType("text"); + + b.Property("Orden") + .HasColumnType("integer"); + + b.Property("PoiId") + .HasColumnType("integer"); + + b.Property("TextoAlt") + .HasColumnType("text"); + + b.Property("VistaInicialPitch") + .HasColumnType("double precision"); + + b.Property("VistaInicialYaw") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("LugarId"); + + b.HasIndex("PoiId"); + + b.ToTable("Escenas"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Hotspot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EscenaDestinoId") + .HasColumnType("integer"); + + b.Property("EscenaId") + .HasColumnType("integer"); + + b.Property("Etiqueta") + .HasColumnType("text"); + + b.Property("Pitch") + .HasColumnType("double precision"); + + b.Property("PoiId") + .HasColumnType("integer"); + + b.Property("Tipo") + .HasColumnType("integer"); + + b.Property("Yaw") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("EscenaDestinoId"); + + b.HasIndex("EscenaId"); + + b.HasIndex("PoiId"); + + b.ToTable("Hotspots"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Lugar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MapaUrl") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.HasKey("Id"); + + b.HasIndex("Slug") + .IsUnique(); + + b.ToTable("Lugares"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Medio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DuracionSeg") + .HasColumnType("integer"); + + b.Property("Idioma") + .HasMaxLength(35) + .HasColumnType("character varying(35)"); + + b.Property("Orden") + .HasColumnType("integer"); + + b.Property("PoiId") + .HasColumnType("integer"); + + b.Property("SubtitulosUrl") + .HasColumnType("text"); + + b.Property("TextoAlt") + .HasColumnType("text"); + + b.Property("Tipo") + .HasColumnType("integer"); + + b.Property("Url") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("PoiId"); + + b.ToTable("Medios"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Poi", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Activo") + .HasColumnType("boolean"); + + b.Property("Audiencias") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Categoria") + .HasColumnType("text"); + + b.Property("Descripcion") + .HasColumnType("text"); + + b.Property("EscenaPrincipalId") + .HasColumnType("integer"); + + b.Property("Lat") + .HasColumnType("double precision"); + + b.Property("Lng") + .HasColumnType("double precision"); + + b.Property("LugarId") + .HasColumnType("integer"); + + b.Property("MapX") + .HasColumnType("double precision"); + + b.Property("MapY") + .HasColumnType("double precision"); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("character varying(120)"); + + b.HasKey("Id"); + + b.HasIndex("EscenaPrincipalId"); + + b.HasIndex("LugarId"); + + b.ToTable("Pois"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Ruta", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Activa") + .HasColumnType("boolean"); + + b.Property("Audiencia") + .HasColumnType("integer"); + + b.Property("Descripcion") + .HasColumnType("text"); + + b.Property("LugarId") + .HasColumnType("integer"); + + b.Property("Nombre") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LugarId"); + + b.ToTable("Rutas"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.RutaPoi", b => + { + b.Property("RutaId") + .HasColumnType("integer"); + + b.Property("PoiId") + .HasColumnType("integer"); + + b.Property("Orden") + .HasColumnType("integer"); + + b.HasKey("RutaId", "PoiId"); + + b.HasIndex("PoiId"); + + b.ToTable("RutaPois"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Escena", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Lugar", "Lugar") + .WithMany("Escenas") + .HasForeignKey("LugarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourVirtualUTB.Api.Models.Poi", "Poi") + .WithMany("Escenas") + .HasForeignKey("PoiId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Lugar"); + + b.Navigation("Poi"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Hotspot", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Escena", "EscenaDestino") + .WithMany() + .HasForeignKey("EscenaDestinoId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("TourVirtualUTB.Api.Models.Escena", "Escena") + .WithMany("Hotspots") + .HasForeignKey("EscenaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourVirtualUTB.Api.Models.Poi", "Poi") + .WithMany() + .HasForeignKey("PoiId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Escena"); + + b.Navigation("EscenaDestino"); + + b.Navigation("Poi"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Medio", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Poi", "Poi") + .WithMany("Medios") + .HasForeignKey("PoiId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poi"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Poi", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Escena", "EscenaPrincipal") + .WithMany() + .HasForeignKey("EscenaPrincipalId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("TourVirtualUTB.Api.Models.Lugar", "Lugar") + .WithMany("Pois") + .HasForeignKey("LugarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EscenaPrincipal"); + + b.Navigation("Lugar"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Ruta", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Lugar", "Lugar") + .WithMany("Rutas") + .HasForeignKey("LugarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lugar"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.RutaPoi", b => + { + b.HasOne("TourVirtualUTB.Api.Models.Poi", "Poi") + .WithMany() + .HasForeignKey("PoiId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TourVirtualUTB.Api.Models.Ruta", "Ruta") + .WithMany("Pois") + .HasForeignKey("RutaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poi"); + + b.Navigation("Ruta"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Escena", b => + { + b.Navigation("Hotspots"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Lugar", b => + { + b.Navigation("Escenas"); + + b.Navigation("Pois"); + + b.Navigation("Rutas"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Poi", b => + { + b.Navigation("Escenas"); + + b.Navigation("Medios"); + }); + + modelBuilder.Entity("TourVirtualUTB.Api.Models.Ruta", b => + { + b.Navigation("Pois"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/services/api/Migrations/20261111044747_AgregarTextoAltEscena.cs b/services/api/Migrations/20261111044747_AgregarTextoAltEscena.cs new file mode 100644 index 0000000..29534ce --- /dev/null +++ b/services/api/Migrations/20261111044747_AgregarTextoAltEscena.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TourVirtualUTB.Api.Migrations +{ + /// + public partial class AgregarTextoAltEscena : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TextoAlt", + table: "Escenas", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "TextoAlt", + table: "Escenas"); + } + } +} diff --git a/services/api/Migrations/TourDbContextModelSnapshot.cs b/services/api/Migrations/TourDbContextModelSnapshot.cs index 0d3333d..1e7d32e 100644 --- a/services/api/Migrations/TourDbContextModelSnapshot.cs +++ b/services/api/Migrations/TourDbContextModelSnapshot.cs @@ -50,6 +50,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PoiId") .HasColumnType("integer"); + b.Property("TextoAlt") + .HasColumnType("text"); + b.Property("VistaInicialPitch") .HasColumnType("double precision"); diff --git a/services/api/Models/Escena.cs b/services/api/Models/Escena.cs index fc70329..30291c3 100644 --- a/services/api/Models/Escena.cs +++ b/services/api/Models/Escena.cs @@ -20,5 +20,12 @@ public class Escena public int Orden { get; set; } public double? VistaInicialYaw { get; set; } public double? VistaInicialPitch { get; set; } + + /// + /// Qué se ve en la panorámica, para quien no la ve. Lo lee el lector de + /// pantalla en el visor 360 (WCAG 1.1.1); si falta, la app lee la + /// descripción del POI. + /// + public string? TextoAlt { get; set; } public ICollection Hotspots { get; set; } = new List(); } \ No newline at end of file diff --git a/services/api/Services/ContenidoService.cs b/services/api/Services/ContenidoService.cs index 2074b08..65dfe1e 100644 --- a/services/api/Services/ContenidoService.cs +++ b/services/api/Services/ContenidoService.cs @@ -193,7 +193,8 @@ public async Task CrearEscenaAsync(CrearEscenaRequest request) EsEscenaPrincipal = request.EsEscenaPrincipal, Orden = request.Orden, VistaInicialYaw = request.VistaInicialYaw, - VistaInicialPitch = request.VistaInicialPitch + VistaInicialPitch = request.VistaInicialPitch, + TextoAlt = TextoONull(request.TextoAlt) }; db.Escenas.Add(escena); @@ -214,6 +215,7 @@ public async Task CrearEscenaAsync(CrearEscenaRequest request) escena.Orden = request.Orden; escena.VistaInicialYaw = request.VistaInicialYaw; escena.VistaInicialPitch = request.VistaInicialPitch; + escena.TextoAlt = TextoONull(request.TextoAlt); await db.SaveChangesAsync(); return Dto.Escena(escena); @@ -403,4 +405,8 @@ public async Task EliminarRutaAsync(int id) // como relleno; ninguno es una ruta real del bucket. private static string? RutaONull(string? ruta) => string.IsNullOrWhiteSpace(ruta) || ruta.Trim() is "string" or "temp" ? null : ruta.Trim(); + + // Vacío y "string" (el valor de ejemplo de Swagger) cuentan como "sin texto". + private static string? TextoONull(string? texto) => + string.IsNullOrWhiteSpace(texto) || texto.Trim() == "string" ? null : texto.Trim(); }