Added a dialog to check if the document is loaded as the user expects

This commit is contained in:
Peer Schütt 2025-11-21 14:12:46 +01:00
parent 56c652f38d
commit 48dcf6bba9
4 changed files with 60 additions and 1 deletions

View File

@ -1,3 +1,4 @@
using AIStudio.Dialogs;
using AIStudio.Tools.Rust; using AIStudio.Tools.Rust;
using AIStudio.Tools.Services; using AIStudio.Tools.Services;
@ -5,6 +6,8 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Components; namespace AIStudio.Components;
using DialogOptions = AIStudio.Dialogs.DialogOptions;
public partial class AttachDocuments : MSGComponentBase public partial class AttachDocuments : MSGComponentBase
{ {
[Parameter] [Parameter]
@ -31,6 +34,9 @@ public partial class AttachDocuments : MSGComponentBase
[Inject] [Inject]
private RustService RustService { get; init; } = null!; private RustService RustService { get; init; } = null!;
[Inject]
private IDialogService DialogService { get; init; } = null!;
#region Overrides of MSGComponentBase #region Overrides of MSGComponentBase
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@ -164,10 +170,17 @@ public partial class AttachDocuments : MSGComponentBase
/// The user might want to check what the Pandoc integration actually extracts from his file and therefore gives the LLM as input. /// The user might want to check what the Pandoc integration actually extracts from his file and therefore gives the LLM as input.
/// </summary> /// </summary>
/// <param name="file">The file to check.</param> /// <param name="file">The file to check.</param>
private void InvestigateFile(FileInfo file) private async Task InvestigateFile(FileInfo file)
{ {
# warning Implement Investigation of file # warning Implement Investigation of file
this.Logger.LogDebug("Investigate"); this.Logger.LogDebug("Investigate");
var dialogParameters = new DialogParameters<PandocDocumentCheckDialog>{};
var dialogReference = await this.DialogService.ShowAsync<PandocDocumentCheckDialog>("Check document content", dialogParameters, DialogOptions.FULLSCREEN);
var dialogResult = await dialogReference.Result;
if (dialogResult is null || dialogResult.Canceled)
return;
return; return;
} }
} }

View File

@ -0,0 +1,20 @@
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<MudJustifiedText Typo="Typo.body1">
@T("Here you can check if Pandoc loads your file as expected.")
</MudJustifiedText>
<ReadFileContent Text="@T("Load document")" @bind-FileContent="@this.documentContent"/>
<MudText Typo="Typo.body1">
@this.documentContent
</MudText>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
</DialogActions>
</MudDialog>

View File

@ -0,0 +1,20 @@
using System.Formats.Asn1;
using AIStudio.Components;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
/// <summary>
/// Check how your file will be loaded by Pandoc.
/// </summary>
public partial class PandocDocumentCheckDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
private string documentContent = string.Empty;
private void Cancel() => this.MudDialog.Cancel();
}

View File

@ -61,6 +61,12 @@
<ProjectReference Include="..\SourceCodeRules\SourceCodeRules\SourceCodeRules.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/> <ProjectReference Include="..\SourceCodeRules\SourceCodeRules\SourceCodeRules.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Dialogs\PandocDocumentCheckDialog.razor.cs">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<!-- Read the meta data file --> <!-- Read the meta data file -->
<Target Name="ReadMetaData" BeforeTargets="BeforeBuild"> <Target Name="ReadMetaData" BeforeTargets="BeforeBuild">
<Error Text="The ../../metadata.txt file was not found!" Condition="!Exists('../../metadata.txt')" /> <Error Text="The ../../metadata.txt file was not found!" Condition="!Exists('../../metadata.txt')" />