feat(CustomImages): Implementiert anstelle von Bildern, um mehrere Bilder über ein Wörterbuch zu konfigurieren

This commit is contained in:
Developer 02 2025-02-13 00:48:47 +01:00
parent 1e34042f77
commit 41b5b62f2c
9 changed files with 32 additions and 25 deletions

View File

@ -0,0 +1,6 @@
namespace EnvelopeGenerator.Web.Models;
public class CustomImages : Dictionary<string, Image>
{
public new Image this[string key] => TryGetValue(key, out var img) && img is not null ? img : new();
}

View File

@ -0,0 +1,10 @@
namespace EnvelopeGenerator.Web.Models;
public class Image
{
public string Src { get; init; } = string.Empty;
public Dictionary<string, string> Classes { get; init; } = new();
public string GetClassIn(string page) => Classes.TryGetValue(page, out var cls) && cls is not null ? cls : string.Empty;
}

View File

@ -1,11 +0,0 @@
namespace EnvelopeGenerator.Web.Models
{
public class Img
{
public string Src { get; init; } = string.Empty;
public Dictionary<string, string> Classes { get; init; } = new();
public string ClassIn(string page) => Classes.TryGetValue(page, out var cls) && cls is not null ? cls : string.Empty;
}
}

View File

@ -161,7 +161,7 @@ try
builder.Services.AddMemoryCache(); builder.Services.AddMemoryCache();
builder.ConfigureBySection<Img>(); builder.ConfigureBySection<CustomImages>();
var app = builder.Build(); var app = builder.Build();

View File

@ -4,7 +4,7 @@
@{ @{
//TODO: Create view model //TODO: Create view model
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string; var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
var logo = _logoOpt.Value; var cImg = _cImgOpt.Value;
ViewData["Title"] = _localizer[WebKey.DocProtected]; ViewData["Title"] = _localizer[WebKey.DocProtected];
var userCulture = ViewData["UserCulture"] as Culture; var userCulture = ViewData["UserCulture"] as Culture;
string codeType = ViewData["CodeType"] is string _codeType ? _codeType : "accessCode"; string codeType = ViewData["CodeType"] is string _codeType ? _codeType : "accessCode";
@ -24,7 +24,7 @@
<header class="text-center"> <header class="text-center">
<div class="header-1 alert alert-secondary" role="alert"> <div class="header-1 alert alert-secondary" role="alert">
<h3 class="text">@_localizer[WebKey.WelcomeToTheESignPortal]</h3> <h3 class="text">@_localizer[WebKey.WelcomeToTheESignPortal]</h3>
<img class="@logo.ClassIn("Locked")" src="@logo.Src" /> <img class="@cImg["Company"].GetClassIn("Locked")" src="@cImg["Company"].Src" />
</div> </div>
<div class="icon locked @(viaTFA ? "tfa" : "") mt-4 mb-1"> <div class="icon locked @(viaTFA ? "tfa" : "") mt-4 mb-1">
<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" fill="currentColor" class="bi bi-shield-lock" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" fill="currentColor" class="bi bi-shield-lock" viewBox="0 0 16 16">

View File

@ -1,6 +1,6 @@
@{ @{
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string; var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
var logo = _logoOpt.Value; var cImg = _cImgOpt.Value;
ViewData["Title"] = _localizer["Home"]; ViewData["Title"] = _localizer["Home"];
var userCulture = ViewData["UserCulture"] as Culture; var userCulture = ViewData["UserCulture"] as Culture;
} }
@ -8,7 +8,7 @@
<header class="text-center"> <header class="text-center">
<div class="header-1 alert alert-secondary" role="alert"> <div class="header-1 alert alert-secondary" role="alert">
<h3 class="text">@_localizer[WebKey.WelcomeToTheESignPortal]</h3> <h3 class="text">@_localizer[WebKey.WelcomeToTheESignPortal]</h3>
<img class="@logo.ClassIn("Locked")" src="@logo.Src" /> <img class="@cImg["Company"].GetClassIn("Locked")" src="@cImg["Company"].Src" />
</div> </div>
<div class="icon mt-4 mb-1"> <div class="icon mt-4 mb-1">
<img src="~/img/sign_flow_min.svg"> <img src="~/img/sign_flow_min.svg">

View File

@ -1,6 +1,6 @@
@{ @{
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string; var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
var logo = _logoOpt.Value; var cImg = _cImgOpt.Value;
} }
@using DigitalData.Core.DTO; @using DigitalData.Core.DTO;
@using EnvelopeGenerator.Application.DTOs; @using EnvelopeGenerator.Application.DTOs;
@ -66,7 +66,7 @@
</div> </div>
<div class="dd-card-info"> <div class="dd-card-info">
<div class="logo"> <div class="logo">
<img class="@logo.ClassIn("Show")" src="@logo.Src" alt="logo"> <img class="@cImg["Company"].GetClassIn("Show")" src="@cImg["Company"].Src" alt="logo">
</div> </div>
<h2>@($"{envelope?.Title}".TrySanitize(_sanitizer))</h2> <h2>@($"{envelope?.Title}".TrySanitize(_sanitizer))</h2>
@if (isReadOnly) @if (isReadOnly)

View File

@ -11,5 +11,5 @@
@inject HighlightHtmlSanitizer _hlSanitizer @inject HighlightHtmlSanitizer _hlSanitizer
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor _accessor @inject Microsoft.AspNetCore.Http.IHttpContextAccessor _accessor
@inject Cultures _cultures @inject Cultures _cultures
@inject IOptions<Img> _logoOpt @inject IOptions<CustomImages> _cImgOpt
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -103,11 +103,13 @@
"Platforms": [ "javascript" ] "Platforms": [ "javascript" ]
} }
], ],
"Img": { "CustomImages": {
"Src": "/img/digital_data.svg", "Company": {
"Classes": { "Src": "/img/digital_data.svg",
"Show": "dd-show-logo", "Classes": {
"Locked": "dd-locked-logo" "Show": "dd-show-logo",
"Locked": "dd-locked-logo"
}
} }
}, },
"DispatcherParams": { "DispatcherParams": {
@ -139,6 +141,6 @@
"EnvelopeHistory": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ], "EnvelopeHistory": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],
"EmailOut": [ "TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD" ], "EmailOut": [ "TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD" ],
"EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ], "EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ],
"Receiver": [ ] "Receiver": []
} }
} }