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 const string SectionName = "Api";
|
||||||
|
|
||||||
public string BaseUrl { get; set; } = string.Empty;
|
public string BaseUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public bool ForceToUseFakeDocument { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
@page "/receiver"
|
@page "/receiver"
|
||||||
@page "/receiver/{EnvelopeKey}"
|
@page "/receiver/{EnvelopeKey}"
|
||||||
@using System.Drawing
|
@using System.Drawing
|
||||||
|
@using DevExpress.Blazor
|
||||||
|
@using DevExpress.Blazor.PdfViewer
|
||||||
@using DevExpress.Drawing
|
@using DevExpress.Drawing
|
||||||
@using DevExpress.Utils
|
@using DevExpress.Utils
|
||||||
@using DevExpress.XtraPrinting
|
@using DevExpress.XtraPrinting
|
||||||
@using DevExpress.XtraPrinting.Drawing
|
@using DevExpress.XtraPrinting.Drawing
|
||||||
|
@using Microsoft.JSInterop
|
||||||
@using XtraReport = DevExpress.XtraReports.UI.XtraReport
|
@using XtraReport = DevExpress.XtraReports.UI.XtraReport
|
||||||
@using BottomMarginBand = DevExpress.XtraReports.UI.BottomMarginBand
|
@using BottomMarginBand = DevExpress.XtraReports.UI.BottomMarginBand
|
||||||
@using XRLabel = DevExpress.XtraReports.UI.XRLabel
|
@using XRLabel = DevExpress.XtraReports.UI.XRLabel
|
||||||
@@ -13,7 +16,10 @@
|
|||||||
@using ImageSizeMode = DevExpress.XtraPrinting.ImageSizeMode
|
@using ImageSizeMode = DevExpress.XtraPrinting.ImageSizeMode
|
||||||
@using EnvelopeGenerator.ReceiverUI.Services
|
@using EnvelopeGenerator.ReceiverUI.Services
|
||||||
@using DevExpress.Blazor.Reporting
|
@using DevExpress.Blazor.Reporting
|
||||||
|
@using Microsoft.Extensions.Options
|
||||||
|
@using EnvelopeGenerator.ReceiverUI.Options
|
||||||
@inject IJSRuntime JSRuntime
|
@inject IJSRuntime JSRuntime
|
||||||
|
@inject IOptions<ApiOptions> AppOptions
|
||||||
@inject InMemoryReportStorageWebExtension ReportStorage
|
@inject InMemoryReportStorageWebExtension ReportStorage
|
||||||
@inject EnvelopeGenerator.ReceiverUI.Services.DocumentService DocumentService
|
@inject EnvelopeGenerator.ReceiverUI.Services.DocumentService DocumentService
|
||||||
|
|
||||||
@@ -122,7 +128,7 @@
|
|||||||
</DxPopup>
|
</DxPopup>
|
||||||
|
|
||||||
<div class="receiver-viewer-wrapper">
|
<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" />
|
<DxPdfViewer @key="ViewerKey" CssClass="w-100 h-100" DocumentContent="PdfBytes" />
|
||||||
} else if(Report is not null) {
|
} else if(Report is not null) {
|
||||||
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
||||||
@@ -170,7 +176,6 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync() {
|
protected override async Task OnInitializedAsync() {
|
||||||
|
|
||||||
EnvelopeKey = null; // Force report generation for testing. Remove this line to enable EnvelopeKey-based loading.
|
|
||||||
if (!string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
if (!string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
||||||
(PdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
|
(PdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Api": {
|
"Api": {
|
||||||
"BaseUrl": "https://localhost:8088"
|
"BaseUrl": "https://localhost:8088",
|
||||||
|
"ForceToUseFakeDocument": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user