From cecf777827cc5e877b5100077dd052e91097f680 Mon Sep 17 00:00:00 2001 From: krut_ni Date: Mon, 26 May 2025 16:43:36 +0200 Subject: [PATCH] WIP: Adjusted styling for user experience and added installation with installers; Added async loading of license text --- .../Components/CodeTabs.razor | 2 +- .../Dialogs/PandocDialog.razor | 233 +++++++++++------- .../Dialogs/PandocDialog.razor.cs | 44 +++- 3 files changed, 186 insertions(+), 93 deletions(-) diff --git a/app/MindWork AI Studio/Components/CodeTabs.razor b/app/MindWork AI Studio/Components/CodeTabs.razor index 1a6dacc1..de1f8cbf 100644 --- a/app/MindWork AI Studio/Components/CodeTabs.razor +++ b/app/MindWork AI Studio/Components/CodeTabs.razor @@ -1,4 +1,4 @@ - + @foreach (var block in blocks) { diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDialog.razor index 4d1638d5..67bd306c 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor @@ -1,106 +1,157 @@ -@using ReverseMarkdown.Converters - + Install Pandoc @if (this.showInstallPage) { -
- - AI Studio relies on the third-party app Pandoc to process and retrieve data from local - Office files (ex. Word) and later other text formats like LaTeX. - - - Unfortunately Pandocs GPL license is not compatible with AI Studios licences. - Therefore you have to accept Pandocs GPL license before we can download and install Pandoc automatically for you (recommended). - However you can download it yourself manually with the instructions below. - -
- - - - 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.
+
+ + AI Studio relies on the third-party app Pandoc to process and retrieve data from + local + Office files (ex. Word) and later other text formats like LaTeX. - Accept GPL and Install - - - If you prefer to install Pandoc yourself, please follow these steps: + Unfortunately Pandocs GPL license is not compatible with AI Studios licences. + Therefore you have to accept Pandocs GPL license before we can download and install Pandoc + automatically for you (recommended). + However you can download it yourself manually with the instructions below. - - - Accept the terms of the GPL license and download the latest archive with the button below. - - - Extract the archive to a folder of your choice. - - C:\Users\%USERNAME%\pandoc - /usr/local/bin/pandoc - /usr/local/bin/pandoc - - - - Open the folder and copy the full path to the pandoc.exe file into you clipboard. - - C:\Users\%USERNAME%\pandoc\pandoc-3.7.0-windows-x86_64\pandoc-3.7.0 - /usr/local/bin/pandoc/pandoc-3.7.0-x86_64-macOS/pandoc-3.7.0 - /usr/local/bin/pandoc/pandoc-3.7.0-linux-amd64/pandoc-3.7.0 - - - - Add the copied path to your systems environment variables and check the installation by typing - pandoc --version into your command line interface. - - pandoc.exe --version
pandoc.exe 3.7.0
- pandoc --version
pandoc.exe 3.7.0
- pandoc --version
pandoc.exe 3.7.0
-
-
-
- - Pandoc is distributed under the GNU General Public License v2 (GPL). - By clicking "Accept GPL and Download", you agree to the terms of the GPL license. - - Accept GPL and Download -
- -
- Reject GPL licence -
+ + + @if (this.isLoading) + { + + + + } + else if (!string.IsNullOrEmpty(this.licenseText)) + { +
@this.licenseText
+ } +
+
+
+ + + + 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.
+
+ Accept GPL and Install + +
+ + + If you prefer to install Pandoc yourself, please follow one of these two guides. Installers are only available for Windows and Mac. + + + + + + Accept the terms of the GPL license and download the latest installer with the download button below. + + pandoc-3.7.0-windows-x86_64.msi + pandoc-3.7.0.1-x86_64-macOS.pkg + pandoc-3.7.0.1-arm64-macOS.pkg + + + + Execute the installer and follow the instructions. + + + + + + + Accept the terms of the GPL license and download the latest archive with the download button below. + + + Extract the archive to a folder of your choice. + + C:\Users\%USERNAME%\pandoc + /usr/local/bin/pandoc + /usr/local/bin/pandoc + + + + Open the folder and copy the full path to the pandoc.exe file into you + clipboard. + + C:\Users\%USERNAME%\pandoc\pandoc-3.7.0-windows-x86_64\pandoc-3.7.0 + /usr/local/bin/pandoc/pandoc-3.7.0-x86_64-macOS/pandoc-3.7.0 + /usr/local/bin/pandoc/pandoc-3.7.0-linux-amd64/pandoc-3.7.0 + + + + Add the copied path to your systems environment variables and check the installation + by typing + pandoc --version + into your command line interface. + + > pandoc.exe --version
> pandoc.exe 3.7.0
+ > pandoc --version
> pandoc.exe 3.7.0
+ > pandoc --version
> pandoc.exe 3.7.0
+
+
+
+ + Pandoc is distributed under the + GNU General Public License v2 (GPL) + + . + By clicking "Accept GPL and Download", you agree to the terms of the GPL license. + + + Accept GPL and Download + +
+
+
+
+
+ Reject GPL licence +
} else { - - @if (showSkeleton) - { - - - } - else if (isPandocAvailable) - { - - - Pandoc ist auf Ihrem System verfügbar - - } - else - { - - - Pandoc ist auf Ihrem System nicht verfügbar - - Proceed - to installation - - } - + + @if (showSkeleton) + { + + + } + else if (isPandocAvailable) + { + + + Pandoc ist auf Ihrem System verfügbar + + } + else + { + + + Pandoc ist auf Ihrem System nicht verfügbar + + + Proceed + to installation + + } + }
diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs index cf599d80..66551338 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs @@ -4,14 +4,20 @@ namespace AIStudio.Dialogs; public partial class PandocDialog : ComponentBase { + [Inject] + private HttpClient HttpClient { get; set; } = null!; + [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; + + private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/master/COPYRIGHT"; private bool isPandocAvailable; private bool showSkeleton; private bool showInstallPage; + private string? licenseText; + private bool isLoading; - #region Overrides of ComponentBase protected override async Task OnInitializedAsync() @@ -33,4 +39,40 @@ public partial class PandocDialog : ComponentBase } private void ProceedToInstallation() => this.showInstallPage = true; + + private async Task OnExpandedChanged(bool newVal) + { + if (newVal) + { + this.isLoading = true; + try + { + await Task.Delay(600); + + this.licenseText = await this.LoadLicenseTextAsync(); + } + catch (Exception ex) + { + Console.WriteLine($"Fehler beim Laden des Lizenztexts: {ex.Message}"); + this.licenseText = "Fehler beim Laden des Lizenztexts."; + } + finally + { + this.isLoading = false; + } + } + else + { + await Task.Delay(350); + this.licenseText = string.Empty; + } + } + + private async Task LoadLicenseTextAsync() + { + var response = await this.HttpClient.GetAsync(LICENCE_URI); + response.EnsureSuccessStatusCode(); + var content = await response.Content.ReadAsStringAsync(); + return content; + } } \ No newline at end of file