diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDialog.razor index a5c5f1c3..928d0733 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor @@ -18,7 +18,7 @@ - + @if (this.isLoading) { @@ -43,7 +43,7 @@ - + If you prefer to install Pandoc yourself, please follow one of these two guides. Installers are only available for Windows and macOS. @@ -70,7 +70,7 @@ 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.
- + Accept GPL and download installer
@@ -116,7 +116,7 @@ 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.
- + Accept GPL and download archive
diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs index 6e9b71ff..a8fb2263 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs @@ -39,6 +39,8 @@ public partial class PandocDialog : ComponentBase private string? licenseText; private bool isLoading; private int selectedArchiveIndex = SelectArchiveIndex(); + private string downloadUrlArchive = string.Empty; + private string downloadUrlInstaller = string.Empty; #region Overrides of ComponentBase @@ -74,22 +76,6 @@ public partial class PandocDialog : ComponentBase 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.GenerateArchiveUriAsync(); - var filename = this.FilenameFromUri(uri); - - await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename); - } - 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)." + @@ -107,14 +93,17 @@ public partial class PandocDialog : ComponentBase 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) { diff --git a/app/MindWork AI Studio/wwwroot/app.js b/app/MindWork AI Studio/wwwroot/app.js index bf1eb31c..aa6b8e2b 100644 --- a/app/MindWork AI Studio/wwwroot/app.js +++ b/app/MindWork AI Studio/wwwroot/app.js @@ -25,14 +25,4 @@ window.clearDiv = function (divName) { window.scrollToBottom = function(element) { element.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' }); -} - -window.triggerDownload = function(url, filename) { - const a = document.createElement('a'); - a.href = url; - a.setAttribute('download', filename); - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); } \ No newline at end of file