mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-11-23 10:50:21 +00:00
Fixed bug where Pandoc installation was not checked
This commit is contained in:
parent
11ca24e48e
commit
8a5e2a96d9
@ -1,8 +1,11 @@
|
|||||||
|
using AIStudio.Dialogs;
|
||||||
using AIStudio.Tools.Rust;
|
using AIStudio.Tools.Rust;
|
||||||
using AIStudio.Tools.Services;
|
using AIStudio.Tools.Services;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
||||||
|
|
||||||
namespace AIStudio.Components;
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
public partial class ReadFileContent : MSGComponentBase
|
public partial class ReadFileContent : MSGComponentBase
|
||||||
@ -16,6 +19,12 @@ public partial class ReadFileContent : MSGComponentBase
|
|||||||
[Inject]
|
[Inject]
|
||||||
private RustService RustService { get; init; } = null!;
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private IDialogService DialogService { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private ILogger<ReadFileContent> Logger { get; init; } = null!;
|
||||||
|
|
||||||
private async Task SelectFile()
|
private async Task SelectFile()
|
||||||
{
|
{
|
||||||
var selectedFile = await this.RustService.SelectFile(T("Select file to read its content"));
|
var selectedFile = await this.RustService.SelectFile(T("Select file to read its content"));
|
||||||
@ -38,6 +47,26 @@ public partial class ReadFileContent : MSGComponentBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that Pandoc is installed and ready:
|
||||||
|
var pandocState = await Pandoc.CheckAvailabilityAsync(this.RustService, showSuccessMessage: false);
|
||||||
|
if (!pandocState.IsAvailable)
|
||||||
|
{
|
||||||
|
var dialogParameters = new DialogParameters<PandocDialog>
|
||||||
|
{
|
||||||
|
{ x => x.ShowInitialResultInSnackbar, false },
|
||||||
|
};
|
||||||
|
|
||||||
|
var dialogReference = await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), dialogParameters, DialogOptions.FULLSCREEN);
|
||||||
|
await dialogReference.Result;
|
||||||
|
|
||||||
|
pandocState = await Pandoc.CheckAvailabilityAsync(this.RustService, showSuccessMessage: true);
|
||||||
|
if (!pandocState.IsAvailable)
|
||||||
|
{
|
||||||
|
this.Logger.LogError("Pandoc is not available after installation attempt.");
|
||||||
|
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, T("Pandoc may be required for importing files.")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var fileContent = await this.RustService.ReadArbitraryFileData(selectedFile.SelectedFilePath, int.MaxValue);
|
var fileContent = await this.RustService.ReadArbitraryFileData(selectedFile.SelectedFilePath, int.MaxValue);
|
||||||
await this.FileContentChanged.InvokeAsync(fileContent);
|
await this.FileContentChanged.InvokeAsync(fileContent);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user