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<ApiOptions>`. 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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<ApiOptions> AppOptions
|
||||
@inject InMemoryReportStorageWebExtension ReportStorage
|
||||
@inject EnvelopeGenerator.ReceiverUI.Services.DocumentService DocumentService
|
||||
|
||||
@@ -122,7 +128,7 @@
|
||||
</DxPopup>
|
||||
|
||||
<div class="receiver-viewer-wrapper">
|
||||
@if(!string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) {
|
||||
@if(!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) {
|
||||
<DxPdfViewer @key="ViewerKey" CssClass="w-100 h-100" DocumentContent="PdfBytes" />
|
||||
} else if(Report is not null) {
|
||||
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"Api": {
|
||||
"BaseUrl": "https://localhost:8088"
|
||||
"BaseUrl": "https://localhost:8088",
|
||||
"ForceToUseFakeDocument": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user