From 72cbccab8c3b19bd0d6e748f0ce947db69a9c633 Mon Sep 17 00:00:00 2001 From: TekH Date: Sun, 31 May 2026 07:30:23 +0200 Subject: [PATCH] Add ForceToUseFakeDocument option for document loading Introduced a new `ForceToUseFakeDocument` property in `ApiOptions` to control whether the application uses a fake document for testing or bypasses certain conditions for document loading. Updated `ReportViewer.razor` to respect this configuration, including changes to conditional rendering logic and dependency injection for `IOptions`. Removed test code that forced `EnvelopeKey` to `null` during initialization. Updated `appsettings.json` to include the new `ForceToUseFakeDocument` property with a default value of `true`. Added necessary `using` directives and dependencies for the updated functionality. --- EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs | 2 ++ EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor | 9 +++++++-- EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs b/EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs index 83983f59..bec9f280 100644 --- a/EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs +++ b/EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs @@ -5,4 +5,6 @@ public class ApiOptions public const string SectionName = "Api"; public string BaseUrl { get; set; } = string.Empty; + + public bool ForceToUseFakeDocument { get; set; } = false; } diff --git a/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor b/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor index b65dcb47..7c159404 100644 --- a/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor +++ b/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor @@ -1,10 +1,13 @@ @page "/receiver" @page "/receiver/{EnvelopeKey}" @using System.Drawing +@using DevExpress.Blazor +@using DevExpress.Blazor.PdfViewer @using DevExpress.Drawing @using DevExpress.Utils @using DevExpress.XtraPrinting @using DevExpress.XtraPrinting.Drawing +@using Microsoft.JSInterop @using XtraReport = DevExpress.XtraReports.UI.XtraReport @using BottomMarginBand = DevExpress.XtraReports.UI.BottomMarginBand @using XRLabel = DevExpress.XtraReports.UI.XRLabel @@ -13,7 +16,10 @@ @using ImageSizeMode = DevExpress.XtraPrinting.ImageSizeMode @using EnvelopeGenerator.ReceiverUI.Services @using DevExpress.Blazor.Reporting +@using Microsoft.Extensions.Options +@using EnvelopeGenerator.ReceiverUI.Options @inject IJSRuntime JSRuntime +@inject IOptions AppOptions @inject InMemoryReportStorageWebExtension ReportStorage @inject EnvelopeGenerator.ReceiverUI.Services.DocumentService DocumentService @@ -122,7 +128,7 @@
-@if(!string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) { +@if(!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) { } else if(Report is not null) { @@ -170,7 +176,6 @@ protected override async Task OnInitializedAsync() { - EnvelopeKey = null; // Force report generation for testing. Remove this line to enable EnvelopeKey-based loading. if (!string.IsNullOrWhiteSpace(EnvelopeKey)) { (PdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey); return; diff --git a/EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json b/EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json index 98c7ba79..d81df0c0 100644 --- a/EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json +++ b/EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json @@ -1,5 +1,6 @@ { "Api": { - "BaseUrl": "https://localhost:8088" + "BaseUrl": "https://localhost:8088", + "ForceToUseFakeDocument": true } }