Finished the Pandoc integration (#487)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-05-30 22:39:16 +02:00
1 parent 5b685193ef
commit 437da0fd9b
30 files changed
+1600 -349

No files matched your search

@@ -60,6 +60,8 @@
</MudJustifiedText>
}
}
<ManagePandocDependency IntroText="@T("For some data types, such as Office files, MindWork AI Studio requires the open-source application Pandoc.")"/>
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="@T("Your security policy")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
@foreach (var policy in Enum.GetValues<DataSourceSecurity>())
@@ -60,6 +60,8 @@
</MudJustifiedText>
}
}
<ManagePandocDependency IntroText="@T("For some data types, such as Office files, MindWork AI Studio requires the open-source application Pandoc.")"/>
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="@T("Your security policy")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
@foreach (var policy in Enum.GetValues<DataSourceSecurity>())
+178 -103
View File
@@ -1,154 +1,229 @@
<MudDialog>
<TitleContent>
Install Pandoc
</TitleContent>
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
@if (this.showInstallPage)
@if (this.isInstallationInProgress)
{
<MudText Typo="Typo.h4" Class="mb-3">
@T("Please wait for the installation to complete...")
</MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="@true" Size="Size.Large" Rounded="@true"/>
}
else if (this.ShowInstallationPage)
{
<div class="mb-4">
<MudText Class="mb-2">
AI Studio relies on the <strong>free and open-sourced</strong> third-party app <strong>Pandoc</strong> to process and retrieve data from local
Office files (ex. <strong>Word</strong>) and later other text formats like LaTeX.
</MudText>
<MudText>
Unfortunately Pandoc's GPL license is not compatible with AI Studios licences, nonetheless software under GPL is generally free to use and
free of charge as well.
Therefore you have to accept Pandoc's GPL license before we can download and install Pandoc for free
automatically for you <strong>(recommended)</strong>.
However you can download it yourself manually with the instructions below.
</MudText>
<MudExpansionPanels>
<MudExpansionPanel Text="GNU General Public License v2 (GPL)" MaxHeight="300" ExpandedChanged="OnExpandedChanged">
@if (this.isLoading)
{
<MudSkeleton />
<MudSkeleton Animation="Animation.Wave" />
<MudSkeleton />
}
else if (!string.IsNullOrEmpty(this.licenseText))
{
<MudJustifiedText>@this.licenseText</MudJustifiedText>
}
</MudExpansionPanel>
</MudExpansionPanels>
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
@T("AI Studio uses the free and open-source third-party app Pandoc to process and retrieve data from local Office files (such as Word files) or to generate Office documents.")
</MudJustifiedText>
<MudJustifiedText Typo="Typo.body1">
@T("Unfortunately, Pandoc's GPL license isn't compatible with the AI Studios licenses. However, software under the GPL is free to use and free of charge. You'll need to accept the GPL license before we can download and install Pandoc for you automatically (recommended). Alternatively, you might download it yourself using the instructions below or install it otherwise, e.g., by using a package manager of your operating system.")
</MudJustifiedText>
</div>
<MudExpansionPanels Class="mb-3" MultiExpansion="@false" Outlined="false" Elevation="0">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AutoFixHigh" HeaderText="Automatic installation" IsExpanded="true">
<MudText Typo="Typo.caption">
Pandoc is distributed under the
<MudLink Typo="Typo.caption" Href="https://github.com/jgm/pandoc/blob/main/COPYRIGHT" Target="_blank">GNU General Public License v2 (GPL)</MudLink>.
By clicking "Accept GPL and Install", you agree to the terms of the GPL license <br/> and Pandoc
will be installed automatically for you. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
</MudText>
<MudButton OnClick="InstallPandocAsync" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.InstallDesktop">
Accept GPL and install for free
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="@T("View the GNU General Public License v2 (GPL)")" MaxHeight="300" ExpandedChanged="this.WhenExpandingLicence">
@if (this.isLoadingLicence)
{
<MudSkeleton/>
<MudSkeleton Animation="Animation.Wave"/>
<MudSkeleton/>
}
else if (!string.IsNullOrWhiteSpace(this.licenseText))
{
<MudMarkdown Value="@this.licenseText" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo"/>
}
</ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AutoFixHigh" HeaderText="@T("Automatic installation")" IsExpanded="true">
<MudJustifiedText Typo="Typo.body1">
@T("""Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and Install," you agree to the terms of the GPL license, and Pandoc will be installed automatically for you. Software under GPL is free of charge and free to use.""")
</MudJustifiedText>
<MudButton OnClick="this.InstallPandocAsync" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.InstallDesktop">
@T("Accept the GPL and start the installation")
</MudButton>
</ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="Manual installation">
<MudText Class="mb-2">
If you prefer to install Pandoc yourself, please follow one of these two guides. Installers are only available for Windows and Mac.
</MudText>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="@T("Manual installation")" ExpandedChanged="this.WhenExpandingManualInstallation">
<MudJustifiedText Typo="Typo.body1" Class="mb-2">
@T("If you want to install Pandoc yourself, follow one of these two guides. The first guide uses an installer and is available for Windows and macOS. Alternatively, you might use a package manager of your operating system to install Pandoc.")
</MudJustifiedText>
<MudExpansionPanels Outlined="false" Elevation="0">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AppRegistration" HeaderText="Download with installer" IsExpanded="true">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AppRegistration" HeaderText="@T("Download installer")" IsExpanded="true">
<MudList T="string">
<MudListItem T="string" Class="mb-2">
Accept the terms of the GPL license and download the latest installer with the download button below.
Eventually you need to allow the download of the installer in the download window.
<CodeTabs>
<CodeBlock Title="Windows">pandoc-@(PANDOC_VERSION)-windows-x86_64.msi</CodeBlock>
<CodeBlock Title="Mac OS x86">pandoc-@(PANDOC_VERSION)-x86_64-macOS.pkg</CodeBlock>
<CodeBlock Title="Mac OS ARM">pandoc-@(PANDOC_VERSION)-arm64-macOS.pkg</CodeBlock>
<MudJustifiedText Typo="Typo.body1">
@T("Accept the terms of the GPL license and download the latest installer with the download button below. Eventually, you need to allow the download of the installer in the download window.")
</MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedInstallerIndex">
<CodeBlock Title="Windows">pandoc-@(LATEST_PANDOC_VERSION)-windows-x86_64.msi</CodeBlock>
<CodeBlock Title="macOS ARM">pandoc-@(LATEST_PANDOC_VERSION)-arm64-macOS.pkg</CodeBlock>
<CodeBlock Title="macOS x86">pandoc-@(LATEST_PANDOC_VERSION)-x86_64-macOS.pkg</CodeBlock>
</CodeTabs>
</MudListItem>
<MudListItem T="string">
Execute the installer and follow the instructions.
<MudJustifiedText Typo="Typo.body1">
@T("Execute the installer and follow the instructions.")
</MudJustifiedText>
</MudListItem>
</MudList>
<MudText Class="mb-3" Typo="Typo.caption">
Pandoc is distributed under the <MudLink Typo="Typo.caption" Href="https://github.com/jgm/pandoc/blob/main/COPYRIGHT" Target="_blank">GNU General Public License v2 (GPL)</MudLink>.
By clicking "Accept GPL and download installer", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
</MudText>
<MudButton OnClick="@this.GetInstaller" Color="Color.Secondary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
Accept GPL and download installer
<MudJustifiedText Class="mb-3" Typo="Typo.body1">
@T("""Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and download installer," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.""")
</MudJustifiedText>
<MudButton Href="@this.downloadUrlInstaller" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading">
@T("Accept the GPL and download the installer")
</MudButton>
</ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Outlined.Archive" HeaderText="Download with archive">
<ExpansionPanel HeaderIcon="@Icons.Material.Outlined.Archive" HeaderText="Download archive">
<MudList T="string">
<MudListItem T="string" Class="mb-2">
Accept the terms of the GPL license and download the latest archive with the download button below.
<MudJustifiedText Typo="Typo.body1">
@T("Accept the terms of the GPL license and download the latest archive with the download button below.")
</MudJustifiedText>
</MudListItem>
<MudListItem T="string" Class="mb-2">
Extract the archive to a folder of your choice.
<CodeTabs>
<MudJustifiedText Typo="Typo.body1">
@T("Extract the archive to a folder of your choice, e.g.:")
</MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc</CodeBlock>
<CodeBlock Title="Mac OS">/usr/local/bin/pandoc</CodeBlock>
<CodeBlock Title="macOS">~/pandoc</CodeBlock>
<CodeBlock Title="Linux">/usr/local/bin/pandoc</CodeBlock>
</CodeTabs>
</MudListItem>
<MudListItem T="string" Class="mb-2">
Open the folder and copy the full path to the <CodeBlock IsInline="@true">pandoc.exe</CodeBlock> file into your
clipboard.
<CodeTabs>
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Mac OS">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock>
<MudJustifiedText Typo="Typo.body1">
@T("Open the folder and copy the full path to the folder where your Pandoc executable file is into your clipboard:")
</MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(LATEST_PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="macOS">~/pandoc/pandoc-@(LATEST_PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">/usr/local/bin/pandoc/pandoc-@(LATEST_PANDOC_VERSION)</CodeBlock>
</CodeTabs>
</MudListItem>
<MudListItem T="string">
Add the copied path to your systems environment variables and check the installation
by typing <br/><CodeBlock IsInline="@true">pandoc --version</CodeBlock>
into your command line interface.
<CodeTabs>
<CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc.exe @(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Mac OS">> pandoc --version<br/>> pandoc.exe @(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">> pandoc --version<br/>> pandoc.exe @(PANDOC_VERSION)</CodeBlock>
<MudJustifiedText Typo="Typo.body1">
@T("Add the copied path to your system's or user's PATH environment variable, restart your terminal, and check the installation:")
</MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc @(LATEST_PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="macOS">> pandoc --version<br/>> pandoc @(LATEST_PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">> pandoc --version<br/>> pandoc @(LATEST_PANDOC_VERSION)</CodeBlock>
</CodeTabs>
</MudListItem>
</MudList>
<MudText Class="mb-3" Typo="Typo.caption">
Pandoc is distributed under the <MudLink Typo="Typo.caption" Href="https://github.com/jgm/pandoc/blob/main/COPYRIGHT" Target="_blank">GNU General Public License v2 (GPL)</MudLink>.
By clicking "Accept GPL and archive", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
<MudJustifiedText Typo="Typo.body1">
@T("""Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and archive," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.""")
</MudJustifiedText>
</MudText>
<MudButton OnClick="@this.GetArchive" Color="Color.Secondary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
Accept GPL and download archive
<MudButton Href="@this.downloadUrlArchive" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading">
@T("Accept the GPL and download the archive")
</MudButton>
</ExpansionPanel>
</MudExpansionPanels>
</ExpansionPanel>
</MudExpansionPanels>
<div class="mt-2">
<MudButton OnClick="@this.RejectLicense" Variant="Variant.Text" Color="Color.Default">Reject GPL licence</MudButton>
</div>
}
else
{
<MudItem Class="px-8 py-2" Style="height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;">
@if (showSkeleton)
<MudItem Class="px-8 py-2">
@if (this.pandocInstallation == default)
{
<MudSkeleton SkeletonType="SkeletonType.Circle" Animation="Animation.Pulse" Class="mb-4"
Style="width: 4em; height: 4em;"/>
<MudSkeleton SkeletonType="SkeletonType.Rectangle" Animation="Animation.Pulse" Width="230px"
Height="35px"/>
}
else if (isPandocAvailable)
{
<MudIcon Class="mb-2" Style="width: 2.5em; height: 2.5em;" Icon="@Icons.Material.Filled.Check"
Color="Color.Success"/>
<MudText Typo="Typo.subtitle1" Align="Align.Center">
Pandoc ist auf Ihrem System verfügbar
</MudText>
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudSkeleton SkeletonType="SkeletonType.Circle" Width="4em" Height="4em" Animation="Animation.Pulse"/>
<MudStack Row="false" Class="d-flex flex-column flex-grow-1">
<MudSkeleton Width="90%" Animation="Animation.Wave"/>
<MudSkeleton Width="75%" Animation="Animation.Wave"/>
<MudSkeleton Width="55%"/>
<MudSkeleton Width="12%"/>
</MudStack>
</MudStack>
}
else
{
<MudIcon Class="mb-2" Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/>
<MudText Class="mb-6" Typo="Typo.subtitle1" Align="Align.Center">
Pandoc ist auf Ihrem System nicht verfügbar
</MudText>
<MudButton Color="Color.Primary" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled">
Proceed to installation
</MudButton>
switch (this.pandocInstallation)
{
case { CheckWasSuccessful: true, IsAvailable: true }:
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 2.5em; height: 2.5em;" Icon="@Icons.Material.Filled.Check" Color="Color.Success"/>
<MudJustifiedText Typo="Typo.body1">
@T("Pandoc is installed and the version meets the requirements of MindWork AI Studio.")
</MudJustifiedText>
</MudStack>
break;
case { CheckWasSuccessful: true, IsAvailable: false }:
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/>
<MudJustifiedText Typo="Typo.body1">
@T("Pandoc is installed, but the version is too old and does not meet the requirements of MindWork AI Studio. AI Studio can help you install a newer version.")
</MudJustifiedText>
</MudStack>
break;
case { CheckWasSuccessful: false }:
<MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/>
<MudJustifiedText Typo="Typo.body1">
@T("Pandoc doesn't seem to be installed on this system. AI Studio can help you install the correct version.")
</MudJustifiedText>
</MudStack>
break;
}
}
</MudItem>
}
</DialogContent>
<DialogActions>
@if (this.isInstallationInProgress)
{
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Close")
</MudButton>
}
else if (this.ShowInstallationPage)
{
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Close")
</MudButton>
<MudButton Color="Color.Warning" OnClick="@this.RejectLicense" Variant="Variant.Filled" Size="Size.Medium">
@T("Reject the GPL licence")
</MudButton>
}
else
{
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Close")
</MudButton>
@if (this.pandocInstallation != default)
{
switch (this.pandocInstallation)
{
case { CheckWasSuccessful: true, IsAvailable: false }:
case { CheckWasSuccessful: false, IsAvailable: false }:
<MudButton Color="Color.Primary" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium">
@T("Proceed to the installation")
</MudButton>
break;
case { CheckWasSuccessful: true, IsAvailable: true }:
<MudButton Color="Color.Default" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium">
@T("Re-install Pandoc")
</MudButton>
break;
}
}
}
</DialogActions>
</MudDialog>
@@ -1,19 +1,32 @@
using AIStudio.Tools.Services;
using System.Reflection;
using AIStudio.Components;
using AIStudio.Tools.Metadata;
using AIStudio.Tools.Services;
using Microsoft.AspNetCore.Components;
using SharedTools;
namespace AIStudio.Dialogs;
public partial class PandocDialog : ComponentBase
public partial class PandocDialog : MSGComponentBase
{
private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID();
[Parameter]
public bool ShowInstallationPage { get; set; }
[Parameter]
public bool ShowInitialResultInSnackbar { get; set; } = true;
[Inject]
private HttpClient HttpClient { get; set; } = null!;
[Inject]
private RustService RustService { get; init; } = null!;
[Inject]
protected IJSRuntime JsRuntime { get; init; } = null!;
[Inject]
private IDialogService DialogService { get; init; } = null!;
@@ -21,107 +34,98 @@ public partial class PandocDialog : ComponentBase
private IMudDialogInstance MudDialog { get; set; } = null!;
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger("PandocDialog");
private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/master/COPYRIGHT";
private static string PANDOC_VERSION = "1.0.0";
private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/refs/heads/main/COPYING.md";
private static string LATEST_PANDOC_VERSION = string.Empty;
private bool isPandocAvailable;
private bool showSkeleton;
private bool showInstallPage;
private PandocInstallation pandocInstallation;
private string? licenseText;
private bool isLoading;
private bool isLoadingLicence;
private bool isInstallationInProgress;
private int selectedInstallerIndex = SelectInstallerIndex();
private int selectedArchiveIndex = SelectArchiveIndex();
private string downloadUrlArchive = string.Empty;
private string downloadUrlInstaller = string.Empty;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
this.showSkeleton = true;
await this.CheckPandocAvailabilityAsync();
PANDOC_VERSION = await Pandoc.FetchLatestVersionAsync();
LATEST_PANDOC_VERSION = await Pandoc.FetchLatestVersionAsync();
await this.CheckPandocAvailabilityAsync(this.ShowInitialResultInSnackbar);
}
#endregion
private void Cancel() => this.MudDialog.Cancel();
private async Task CheckPandocAvailabilityAsync()
private async Task CheckPandocAvailabilityAsync(bool useSnackbar)
{
this.isPandocAvailable = await Pandoc.CheckAvailabilityAsync(this.RustService);
this.showSkeleton = false;
this.pandocInstallation = await Pandoc.CheckAvailabilityAsync(this.RustService, useSnackbar);
await this.InvokeAsync(this.StateHasChanged);
}
private async Task InstallPandocAsync()
{
this.isInstallationInProgress = true;
this.StateHasChanged();
await Pandoc.InstallAsync(this.RustService);
this.isInstallationInProgress = false;
this.MudDialog.Close(DialogResult.Ok(true));
await this.DialogService.ShowAsync<PandocDialog>("pandoc dialog");
await this.DialogService.ShowAsync<PandocDialog>("Pandoc Installation", DialogOptions.FULLSCREEN);
}
private void ProceedToInstallation() => this.showInstallPage = true;
private async Task GetInstaller()
{
var uri = await Pandoc.GenerateInstallerUriAsync();
var filename = this.FilenameFromUri(uri);
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
}
private async Task GetArchive()
{
var uri = await Pandoc.GenerateUriAsync();
var filename = this.FilenameFromUri(uri);
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
}
private void ProceedToInstallation() => this.ShowInstallationPage = true;
private async Task RejectLicense()
{
var message = "Pandoc is open-source and free of charge, but if you reject Pandoc's license, it can not be installed and some of AIStudios data retrieval features will be disabled (e.g. using Office files like Word)." +
"This decision can be revoked at any time. Are you sure you want to reject the license?";
var message = T("Pandoc is open-source and free, but if you reject its license, you can't install it and some MindWork AI Studio features will be limited (like the integration of Office files) or unavailable (like the generation of Office files). You can change your decision anytime. Are you sure you want to reject the license?");
var dialogParameters = new DialogParameters
{
{ "Message", message },
};
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>("Reject Pandoc's licence", dialogParameters, DialogOptions.FULLSCREEN);
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(T("Reject Pandoc's Licence"), dialogParameters, DialogOptions.FULLSCREEN);
var dialogResult = await dialogReference.Result;
if (dialogResult is null || dialogResult.Canceled)
dialogReference.Close();
else
this.Cancel();
}
private string FilenameFromUri(string uri)
private async Task WhenExpandingManualInstallation(bool isExpanded)
{
var index = uri.LastIndexOf('/');
return uri[(index + 1)..];
if(string.IsNullOrWhiteSpace(this.downloadUrlArchive))
this.downloadUrlArchive = await Pandoc.GenerateArchiveUriAsync();
if(string.IsNullOrWhiteSpace(this.downloadUrlInstaller))
this.downloadUrlInstaller = await Pandoc.GenerateInstallerUriAsync();
}
private async Task OnExpandedChanged(bool isExpanded)
private async Task WhenExpandingLicence(bool isExpanded)
{
if (isExpanded)
{
this.isLoading = true;
this.isLoadingLicence = true;
try
{
await Task.Delay(600);
this.licenseText = await this.LoadLicenseTextAsync();
}
catch (Exception ex)
{
this.licenseText = "Error loading license text, please consider following the links to read the GPL.";
LOG.LogError("Error loading GPL license text:\n{ErrorMessage}", ex.Message);
this.licenseText = T("Error loading license text, please consider following the links to read the GPL.");
LOG.LogError("Error loading GPL license text: {ErrorMessage}", ex.Message);
}
finally
{
this.isLoading = false;
this.isLoadingLicence = false;
}
}
else
{
await Task.Delay(350);
this.licenseText = string.Empty;
}
}
@@ -130,7 +134,34 @@ public partial class PandocDialog : ComponentBase
{
var response = await this.HttpClient.GetAsync(LICENCE_URI);
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
return content;
return await response.Content.ReadAsStringAsync();
}
// ReSharper disable RedundantSwitchExpressionArms
private static int SelectInstallerIndex() => CPU_ARCHITECTURE switch
{
RID.OSX_ARM64 => 1,
RID.OSX_X64 => 2,
RID.WIN_ARM64 => 0,
RID.WIN_X64 => 0,
_ => 0,
};
private static int SelectArchiveIndex() => CPU_ARCHITECTURE switch
{
RID.OSX_ARM64 => 1,
RID.OSX_X64 => 1,
RID.WIN_ARM64 => 0,
RID.WIN_X64 => 0,
RID.LINUX_ARM64 => 2,
RID.LINUX_X64 => 2,
_ => 0,
};
// ReSharper restore RedundantSwitchExpressionArms
}