Simplify EnvelopeReceiverPage logic and update settings
Removed redundant `EnvelopeKey` checks in `LogoutAsync` and `OnInitializedAsync` methods, simplifying logout and initialization logic. Updated navigation URL to `/envelope/login/`. Streamlined document fetching logic by removing unnecessary conditions. Added logging in `CreateReportInstance` to track report creation. Enabled `ForceToUseFakeDocument` in `appsettings.json` to default to using fake documents. These changes improve code clarity and align behavior with updated requirements.
This commit is contained in:
@@ -162,18 +162,16 @@
|
||||
</svg>
|
||||
PDF exportieren
|
||||
</button>
|
||||
@if (!string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
||||
<button class="btn btn-sm btn-outline-danger" @onclick="LogoutAsync" disabled="@IsLoggingOut" title="Abmelden">
|
||||
<button class="btn btn-sm btn-outline-danger" @onclick="LogoutAsync" disabled="@IsLoggingOut" title="Abmelden">
|
||||
@if (IsLoggingOut) {
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
} else {
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z"/>
|
||||
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z"/>
|
||||
</svg>
|
||||
</svg>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -311,33 +309,29 @@ Shown="OnPopupShownAsync">
|
||||
int _lastOverlayViewerKey = -1;
|
||||
|
||||
async Task LogoutAsync() {
|
||||
if (string.IsNullOrWhiteSpace(EnvelopeKey) || IsLoggingOut) return;
|
||||
if (IsLoggingOut) return;
|
||||
IsLoggingOut = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await AuthService.LogoutEnvelopeReceiverAsync(EnvelopeKey);
|
||||
Navigation.NavigateTo($"/login/{Uri.EscapeDataString(EnvelopeKey)}", forceLoad: true);
|
||||
Navigation.NavigateTo($"/envelope/login/{Uri.EscapeDataString(EnvelopeKey)}", forceLoad: true);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync() {
|
||||
if (!string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
||||
var hasAccess = await AuthService.CheckEnvelopeAccessAsync(EnvelopeKey);
|
||||
if (!hasAccess) {
|
||||
Navigation.NavigateTo($"/login/{Uri.EscapeDataString(EnvelopeKey)}");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveSignatureTab = SignatureTabDraw;
|
||||
SignaturePopupVisible = true;
|
||||
SignatureValidationMessage = null;
|
||||
PopupValidationMessage = null;
|
||||
}
|
||||
var hasAccess = await AuthService.CheckEnvelopeAccessAsync(EnvelopeKey);
|
||||
if (!hasAccess) {
|
||||
Navigation.NavigateTo($"/envelope/login/{Uri.EscapeDataString(EnvelopeKey)}");
|
||||
return;
|
||||
}
|
||||
|
||||
_annotations = await AnnotationService.GetAnnotationsAsync(EnvelopeKey ?? "fake");
|
||||
_envelopeReceiver = await EnvelopeReceiverService.GetAsync(EnvelopeKey ?? "fake");
|
||||
ActiveSignatureTab = SignatureTabDraw;
|
||||
SignaturePopupVisible = true;
|
||||
SignatureValidationMessage = null;
|
||||
PopupValidationMessage = null;
|
||||
|
||||
if (!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
||||
_annotations = await AnnotationService.GetAnnotationsAsync(EnvelopeKey);
|
||||
_envelopeReceiver = await EnvelopeReceiverService.GetAsync(EnvelopeKey);
|
||||
|
||||
if (!AppOptions.Value.ForceToUseFakeDocument) {
|
||||
var (pdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
|
||||
if (pdfBytes is { Length: > 0 })
|
||||
_basePdfBytes = pdfBytes;
|
||||
@@ -573,7 +567,8 @@ Shown="OnPopupShownAsync">
|
||||
}
|
||||
}
|
||||
|
||||
XtraReport CreateReportInstance() {
|
||||
XtraReport CreateReportInstance() {
|
||||
Console.WriteLine("Created with predefinedReports");
|
||||
return ReportStorage.TryGetReport("LargeDatasetReport", out var savedReport)
|
||||
? savedReport
|
||||
: PredefinedReports.ReportsFactory.GetReport("LargeDatasetReport");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"Api": {
|
||||
"BaseUrl": "",
|
||||
"ForceToUseFakeDocument": false
|
||||
"ForceToUseFakeDocument": true
|
||||
},
|
||||
"PdfViewer": {
|
||||
"ThumbnailBaseScale": 0.75,
|
||||
|
||||
Reference in New Issue
Block a user