From 729ec1ee03d7c418c21dcf1810b880ff019987b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SAL=C4=B0H=20=C3=96ZKARA?= Date: Thu, 15 May 2025 18:04:32 +0300 Subject: [PATCH] Improve pdf download --- modules/docs/Volo.Docs.abpmdl | 16 + .../Documents/IDocumentPdfAdminAppService.cs | 15 + .../Admin/Projects/IProjectAdminAppService.cs | 4 - .../BackgroundJobs/DocumentPdfGenerateJob.cs | 36 ++ .../DocumentPdfGenerateJobArgs.cs | 12 + .../Volo.Docs.Admin.Application.csproj | 1 + .../Docs/Admin/DocsAdminApplicationModule.cs | 4 +- .../Documents/DocumentPdfAdminAppService.cs | 67 +++ .../Admin/Projects/ProjectAdminAppService.cs | 20 - .../DocumentPdfAdminClientProxy.Generated.cs | 61 +++ .../Docs/Admin/DocumentPdfAdminClientProxy.cs | 7 + .../ProjectsAdminClientProxy.Generated.cs | 16 - .../Docs/Admin/docs-admin-generate-proxy.json | 460 ++++++++++++++++++ .../Docs/Admin/DocumentPdfAdminController.cs | 60 +++ .../Docs/Admin/ProjectsAdminController.cs | 14 - .../Docs/Admin/Projects/GeneratePdf.cshtml | 68 ++- .../Docs/Admin/Projects/GeneratePdf.cshtml.cs | 33 +- .../Pages/Docs/Admin/Projects/generatePdf.js | 54 -- .../Docs/Admin/Projects/managePdfFiles.js | 23 +- .../Volo.Docs.Admin.Web.abppkg | 2 +- .../client-proxies/docs-admin-proxy.js | 60 ++- ...o.Docs.Common.Application.Contracts.abppkg | 3 + .../Documents/IDocumentPdfAppService.cs | 12 + .../IDocumentPdfGeneratorAppService.cs | 10 - .../Volo.Docs.Common.Application.abppkg | 3 + .../Common/Documents/DocumentPdfAppService.cs | 54 ++ .../DocumentPdfGeneratorAppService.cs | 52 -- .../DocsDocumentPdfClientProxy.Generated.cs | 36 ++ .../DocsDocumentPdfClientProxy.cs | 7 + .../DocsProjectClientProxy.Generated.cs | 59 +++ .../ClientProxies/DocsProjectClientProxy.cs | 7 + ...> DocsDocumentPdfClientProxy.Generated.cs} | 4 +- ...Proxy.cs => DocsDocumentPdfClientProxy.cs} | 2 +- .../docs-common-generate-proxy.json | 102 +++- .../Volo.Docs.Common.HttpApi.Client.abppkg | 15 + .../Volo.Docs.Common.HttpApi.abppkg | 3 + .../Documents/DocsDocumentPdfController.cs | 37 ++ .../DocsDocumentPdfGeneratorController.cs | 32 -- .../Projects/Pdf/BlobProjectPdfFileStore.cs | 6 - .../Pdf/DocsProjectPdfGeneratorOptions.cs | 13 +- .../Docs/Projects/Pdf/IProjectPdfGenerator.cs | 3 +- .../Docs/Projects/Pdf/ProjectPdfGenerator.cs | 12 +- .../Volo/Docs/Projects/Project.cs | 31 ++ .../DocsDocumentClientProxy.Generated.cs | 80 +++ .../ClientProxies/DocsDocumentClientProxy.cs | 7 + .../Volo.Docs.HttpApi.Client.abppkg | 14 +- .../Pages/Documents/Project/Index.cshtml | 6 +- .../Pages/Documents/Project/Index.cshtml.cs | 16 +- .../Pages/Documents/Project/index.js | 7 + .../src/Volo.Docs.Web/Volo.Docs.Web.abppkg | 13 +- nupkg/common.ps1 | 4 + 51 files changed, 1367 insertions(+), 316 deletions(-) create mode 100644 modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentPdfAdminAppService.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJob.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJobArgs.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentPdfAdminAppService.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.Generated.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.cs create mode 100644 modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentPdfAdminController.cs create mode 100644 modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo.Docs.Common.Application.Contracts.abppkg create mode 100644 modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfAppService.cs delete mode 100644 modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfGeneratorAppService.cs create mode 100644 modules/docs/src/Volo.Docs.Common.Application/Volo.Docs.Common.Application.abppkg create mode 100644 modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfAppService.cs delete mode 100644 modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfGeneratorAppService.cs create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.Generated.cs create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.cs create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.Generated.cs create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.cs rename modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/{DocsDocumentPdfGeneratorClientProxy.Generated.cs => DocsDocumentPdfClientProxy.Generated.cs} (77%) rename modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/{DocsDocumentPdfGeneratorClientProxy.cs => DocsDocumentPdfClientProxy.cs} (74%) create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi.Client/Volo.Docs.Common.HttpApi.Client.abppkg create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi/Volo.Docs.Common.HttpApi.abppkg create mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfController.cs delete mode 100644 modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfGeneratorController.cs create mode 100644 modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.Generated.cs create mode 100644 modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.cs diff --git a/modules/docs/Volo.Docs.abpmdl b/modules/docs/Volo.Docs.abpmdl index 77c70bddf8..bb861a309d 100644 --- a/modules/docs/Volo.Docs.abpmdl +++ b/modules/docs/Volo.Docs.abpmdl @@ -86,6 +86,22 @@ "Volo.Docs.MongoDB.Tests": { "path": "test/Volo.Docs.MongoDB.Tests/Volo.Docs.MongoDB.Tests.abppkg", "folder": "test" + }, + "Volo.Docs.Common.Application": { + "path": "src/Volo.Docs.Common.Application/Volo.Docs.Common.Application.abppkg", + "folder": "src" + }, + "Volo.Docs.Common.Application.Contracts": { + "path": "src/Volo.Docs.Common.Application.Contracts/Volo.Docs.Common.Application.Contracts.abppkg", + "folder": "src" + }, + "Volo.Docs.Common.HttpApi": { + "path": "src/Volo.Docs.Common.HttpApi/Volo.Docs.Common.HttpApi.abppkg", + "folder": "src" + }, + "Volo.Docs.Common.HttpApi.Client": { + "path": "src/Volo.Docs.Common.HttpApi.Client/Volo.Docs.Common.HttpApi.Client.abppkg", + "folder": "src" } } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentPdfAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentPdfAdminAppService.cs new file mode 100644 index 0000000000..ad253cecef --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentPdfAdminAppService.cs @@ -0,0 +1,15 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Docs.Admin.Projects; +using Volo.Docs.Common.Documents; + +namespace Volo.Docs.Admin.Documents; + +public interface IDocumentPdfAdminAppService : IDocumentPdfAppService +{ + Task GeneratePdfAsync(DocumentPdfGeneratorInput input); + + Task> GetPdfFilesAsync(GetPdfFilesInput input); + + Task DeletePdfFileAsync(DeletePdfFileInput input); +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs index 41b309f308..6f3d503f44 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs @@ -22,9 +22,5 @@ namespace Volo.Docs.Admin.Projects Task ReindexAllAsync(); Task> GetListWithoutDetailsAsync(); - - Task> GetPdfFilesAsync(GetPdfFilesInput input); - - Task DeletePdfFileAsync(DeletePdfFileInput input); } } diff --git a/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJob.cs b/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJob.cs new file mode 100644 index 0000000000..7bfaa641c8 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJob.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Volo.Abp.BackgroundJobs; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; +using Volo.Docs.Projects; +using Volo.Docs.Projects.Pdf; + +namespace Volo.Docs.Admin.BackgroundJobs; + +public class DocumentPdfGenerateJob : AsyncBackgroundJob, ITransientDependency +{ + protected IProjectPdfGenerator ProjectPdfGenerator { get; } + protected IProjectRepository ProjectRepository { get; } + + public DocumentPdfGenerateJob(IProjectPdfGenerator projectPdfGenerator, IProjectRepository projectRepository) + { + ProjectPdfGenerator = projectPdfGenerator; + ProjectRepository = projectRepository; + } + + [UnitOfWork] + public async override Task ExecuteAsync(DocumentPdfGenerateJobArgs args) + { + try + { + var project = await ProjectRepository.GetAsync(args.ProjectId, includeDetails: true); + await ProjectPdfGenerator.GenerateAsync(project, args.Version, args.LanguageCode); + } + catch (Exception e) + { + Logger.LogError(e, "Error while generating PDF for project {ProjectId}, version {Version}, language {LanguageCode}", args.ProjectId, args.Version, args.LanguageCode); + } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJobArgs.cs b/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJobArgs.cs new file mode 100644 index 0000000000..be18746f17 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Application/BackgroundJobs/DocumentPdfGenerateJobArgs.cs @@ -0,0 +1,12 @@ +using System; + +namespace Volo.Docs.Admin.BackgroundJobs; + +public class DocumentPdfGenerateJobArgs +{ + public Guid ProjectId { get; set; } + + public string Version { get; set; } + + public string LanguageCode { get; set; } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo.Docs.Admin.Application.csproj b/modules/docs/src/Volo.Docs.Admin.Application/Volo.Docs.Admin.Application.csproj index 7279eeee67..2ecefbfd1a 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo.Docs.Admin.Application.csproj +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo.Docs.Admin.Application.csproj @@ -17,6 +17,7 @@ + diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationModule.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationModule.cs index 7e6983d65e..9358705f94 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationModule.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationModule.cs @@ -4,6 +4,7 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Caching; using Volo.Abp.Modularity; using Volo.Docs.Common; +using Volo.Abp.BackgroundJobs; namespace Volo.Docs.Admin { @@ -13,7 +14,8 @@ namespace Volo.Docs.Admin typeof(DocsCommonApplicationModule), typeof(AbpCachingModule), typeof(AbpAutoMapperModule), - typeof(AbpDddApplicationModule) + typeof(AbpDddApplicationModule), + typeof(AbpBackgroundJobsModule) )] public class DocsAdminApplicationModule : AbpModule { diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentPdfAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentPdfAdminAppService.cs new file mode 100644 index 0000000000..234f3ae2e3 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentPdfAdminAppService.cs @@ -0,0 +1,67 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Options; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.BackgroundJobs; +using Volo.Abp.DistributedLocking; +using Volo.Docs.Admin.BackgroundJobs; +using Volo.Docs.Admin.Projects; +using Volo.Docs.Common; +using Volo.Docs.Common.Documents; +using Volo.Docs.Projects; +using Volo.Docs.Projects.Pdf; + +namespace Volo.Docs.Admin.Documents; + +[Authorize(DocsCommonPermissions.Projects.PdfGeneration)] +public class DocumentPdfAdminAppService : DocumentPdfAppService, IDocumentPdfAdminAppService +{ + protected IBackgroundJobManager BackgroundJobManager { get; } + protected IAbpDistributedLock DistributedLock { get; } + + public DocumentPdfAdminAppService( + IProjectPdfGenerator projectPdfGenerator, + IProjectRepository projectRepository, + IProjectPdfFileStore projectPdfFileStore, + IOptions options, + IBackgroundJobManager backgroundJobManager, + IAbpDistributedLock distributedLock) : + base(projectPdfGenerator, projectRepository, projectPdfFileStore, options) + { + BackgroundJobManager = backgroundJobManager; + DistributedLock = distributedLock; + } + + public virtual async Task GeneratePdfAsync(DocumentPdfGeneratorInput input) + { + var project = await ProjectRepository.GetAsync(input.ProjectId, includeDetails: true); + await BackgroundJobManager.EnqueueAsync(new DocumentPdfGenerateJobArgs + { + Version = project.GetFullVersion(input.Version), + LanguageCode = input.LanguageCode, + ProjectId = input.ProjectId, + }); + } + + public virtual async Task> GetPdfFilesAsync(GetPdfFilesInput input) + { + var project = await ProjectRepository.GetAsync(input.ProjectId, includeDetails: true); + + var pdfFiles = project.PdfFiles.Skip(input.SkipCount).Take(input.MaxResultCount).ToList(); + + return new PagedResultDto( + project.PdfFiles.Count, + ObjectMapper.Map, List>(pdfFiles) + ); + } + + [Authorize(DocsAdminPermissions.Projects.ManagePdfFiles)] + public virtual async Task DeletePdfFileAsync(DeletePdfFileInput input) + { + var project = await ProjectRepository.GetAsync(input.ProjectId, includeDetails: true); + await ProjectPdfFileStore.DeleteAsync(project, input.Version, input.LanguageCode); + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs index abbb26abe5..af4ca2230b 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs @@ -181,25 +181,5 @@ namespace Volo.Docs.Admin.Projects var projects = await _projectRepository.GetListWithoutDetailsAsync(); return ObjectMapper.Map, List>(projects); } - - [Authorize(DocsAdminPermissions.Projects.ManagePdfFiles)] - public virtual async Task> GetPdfFilesAsync(GetPdfFilesInput input) - { - var project = await _projectRepository.GetAsync(input.ProjectId, includeDetails: true); - - var pdfFiles = project.PdfFiles.Skip(input.SkipCount).Take(input.MaxResultCount).ToList(); - - return new PagedResultDto( - project.PdfFiles.Count, - ObjectMapper.Map, List>(pdfFiles) - ); - } - - [Authorize(DocsAdminPermissions.Projects.ManagePdfFiles)] - public virtual async Task DeletePdfFileAsync(DeletePdfFileInput input) - { - var project = await _projectRepository.GetAsync(input.ProjectId, includeDetails: true); - await _projectPdfFileStore.DeleteAsync(project, input.Version, input.LanguageCode); - } } } diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.Generated.cs new file mode 100644 index 0000000000..8c14d65460 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.Generated.cs @@ -0,0 +1,61 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Docs.Admin.Projects; +using Volo.Docs.Common.Documents; + +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Admin; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IDocumentPdfAppService), typeof(DocumentPdfAdminClientProxy))] +public partial class DocumentPdfAdminClientProxy : ClientProxyBase, IDocumentPdfAppService +{ + public virtual async Task GeneratePdfAsync(DocumentPdfGeneratorInput input) + { + await RequestAsync(nameof(GeneratePdfAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentPdfGeneratorInput), input } + }); + } + + public virtual async Task> GetPdfFilesAsync(GetPdfFilesInput input) + { + return await RequestAsync>(nameof(GetPdfFilesAsync), new ClientProxyRequestTypeValue + { + { typeof(GetPdfFilesInput), input } + }); + } + + public virtual async Task DeletePdfFileAsync(DeletePdfFileInput input) + { + await RequestAsync(nameof(DeletePdfFileAsync), new ClientProxyRequestTypeValue + { + { typeof(DeletePdfFileInput), input } + }); + } + + public virtual async Task DownloadPdfAsync(DocumentPdfGeneratorInput input) + { + return await RequestAsync(nameof(DownloadPdfAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentPdfGeneratorInput), input } + }); + } + + public virtual async Task ExistsAsync(DocumentPdfGeneratorInput input) + { + return await RequestAsync(nameof(ExistsAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentPdfGeneratorInput), input } + }); + } +} diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.cs b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.cs new file mode 100644 index 0000000000..a8d5f82116 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/DocumentPdfAdminClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of DocumentPdfAdminClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Admin; + +public partial class DocumentPdfAdminClientProxy +{ +} diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/ProjectsAdminClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/ProjectsAdminClientProxy.Generated.cs index 9437ee487d..54f1ec22d5 100644 --- a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/ProjectsAdminClientProxy.Generated.cs +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/ProjectsAdminClientProxy.Generated.cs @@ -68,22 +68,6 @@ public partial class ProjectsAdminClientProxy : ClientProxyBase>(nameof(GetListWithoutDetailsAsync)); } - public virtual async Task> GetPdfFilesAsync(GetPdfFilesInput input) - { - return await RequestAsync>(nameof(GetPdfFilesAsync), new ClientProxyRequestTypeValue - { - { typeof(GetPdfFilesInput), input } - }); - } - - public virtual async Task DeletePdfFileAsync(DeletePdfFileInput input) - { - await RequestAsync(nameof(DeletePdfFileAsync), new ClientProxyRequestTypeValue - { - { typeof(DeletePdfFileInput), input } - }); - } - public virtual async Task ReindexAsync(ReindexInput input) { await RequestAsync(nameof(ReindexAsync), new ClientProxyRequestTypeValue diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/docs-admin-generate-proxy.json b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/docs-admin-generate-proxy.json index e433e06ef9..0b3e9f9445 100644 --- a/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/docs-admin-generate-proxy.json +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/Volo/Docs/Admin/docs-admin-generate-proxy.json @@ -4,6 +4,466 @@ "rootPath": "docs-admin", "remoteServiceName": "AbpDocsAdmin", "controllers": { + "Volo.Docs.Admin.DocumentPdfAdminController": { + "controllerName": "DocumentPdfAdmin", + "controllerGroupName": "DocumentsPdfAdmin", + "isRemoteService": true, + "isIntegrationService": false, + "apiVersion": null, + "type": "Volo.Docs.Admin.DocumentPdfAdminController", + "interfaces": [ + { + "type": "Volo.Docs.Admin.Documents.IDocumentPdfAdminAppService", + "name": "IDocumentPdfAdminAppService", + "methods": [ + { + "name": "GeneratePdfAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + } + }, + { + "name": "GetPdfFilesAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Admin.Projects.GetPdfFilesInput, Volo.Docs.Admin.Application.Contracts", + "type": "Volo.Docs.Admin.Projects.GetPdfFilesInput", + "typeSimple": "Volo.Docs.Admin.Projects.GetPdfFilesInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "Volo.Abp.Application.Dtos.PagedResultDto", + "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + } + }, + { + "name": "DeletePdfFileAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Admin.Projects.DeletePdfFileInput, Volo.Docs.Admin.Application.Contracts", + "type": "Volo.Docs.Admin.Projects.DeletePdfFileInput", + "typeSimple": "Volo.Docs.Admin.Projects.DeletePdfFileInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + } + }, + { + "name": "DownloadPdfAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "Volo.Abp.Content.IRemoteStreamContent", + "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" + } + }, + { + "name": "ExistsAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Boolean", + "typeSimple": "boolean" + } + } + ] + }, + { + "type": "Volo.Docs.Common.Documents.IDocumentPdfAppService", + "name": "IDocumentPdfAppService", + "methods": [ + { + "name": "DownloadPdfAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "Volo.Abp.Content.IRemoteStreamContent", + "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" + } + }, + { + "name": "ExistsAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Boolean", + "typeSimple": "boolean" + } + } + ] + } + ], + "actions": { + "GeneratePdfAsyncByInput": { + "uniqueName": "GeneratePdfAsyncByInput", + "name": "GeneratePdfAsync", + "httpMethod": "GET", + "url": "api/docs/admin/documents/pdf/generate", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Version", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "LanguageCode", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Admin.Documents.IDocumentPdfAdminAppService" + }, + "GetPdfFilesAsyncByInput": { + "uniqueName": "GetPdfFilesAsyncByInput", + "name": "GetPdfFilesAsync", + "httpMethod": "GET", + "url": "api/docs/admin/documents/pdf/files", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Admin.Projects.GetPdfFilesInput, Volo.Docs.Admin.Application.Contracts", + "type": "Volo.Docs.Admin.Projects.GetPdfFilesInput", + "typeSimple": "Volo.Docs.Admin.Projects.GetPdfFilesInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Sorting", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "SkipCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "MaxResultCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "Volo.Abp.Application.Dtos.PagedResultDto", + "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Admin.Documents.IDocumentPdfAdminAppService" + }, + "DeletePdfFileAsyncByInput": { + "uniqueName": "DeletePdfFileAsyncByInput", + "name": "DeletePdfFileAsync", + "httpMethod": "DELETE", + "url": "api/docs/admin/documents/pdf/delete-file", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Admin.Projects.DeletePdfFileInput, Volo.Docs.Admin.Application.Contracts", + "type": "Volo.Docs.Admin.Projects.DeletePdfFileInput", + "typeSimple": "Volo.Docs.Admin.Projects.DeletePdfFileInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Version", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "LanguageCode", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "System.Void", + "typeSimple": "System.Void" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Admin.Documents.IDocumentPdfAdminAppService" + }, + "DownloadPdfAsyncByInput": { + "uniqueName": "DownloadPdfAsyncByInput", + "name": "DownloadPdfAsync", + "httpMethod": "GET", + "url": "api/docs/admin/documents/pdf/download", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Version", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "LanguageCode", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "Volo.Abp.Content.IRemoteStreamContent", + "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Common.Documents.IDocumentPdfAppService" + }, + "ExistsAsyncByInput": { + "uniqueName": "ExistsAsyncByInput", + "name": "ExistsAsync", + "httpMethod": "GET", + "url": "api/docs/admin/documents/pdf/exists", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Version", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "LanguageCode", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "System.Boolean", + "typeSimple": "boolean" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Common.Documents.IDocumentPdfAppService" + } + } + }, "Volo.Docs.Admin.DocumentsAdminController": { "controllerName": "DocumentsAdmin", "controllerGroupName": "DocumentsAdmin", diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentPdfAdminController.cs b/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentPdfAdminController.cs new file mode 100644 index 0000000000..4cc49efc79 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentPdfAdminController.cs @@ -0,0 +1,60 @@ +using System.Threading.Tasks; +using Asp.Versioning; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Content; +using Volo.Docs.Admin.Documents; +using Volo.Docs.Admin.Projects; +using Volo.Docs.Common.Documents; + +namespace Volo.Docs.Admin; +[RemoteService(Name = DocsAdminRemoteServiceConsts.RemoteServiceName)] +[Area(DocsAdminRemoteServiceConsts.ModuleName)] +[ControllerName("DocumentsPdfAdmin")] +[Route("api/docs/admin/documents/pdf")] +public class DocumentPdfAdminController : AbpControllerBase, IDocumentPdfAdminAppService +{ + private readonly IDocumentPdfAdminAppService _documentPdfAdminAppService; + + public DocumentPdfAdminController(IDocumentPdfAdminAppService documentPdfAdminAppService) + { + _documentPdfAdminAppService = documentPdfAdminAppService; + } + + [HttpGet] + [Route("generate")] + public Task GeneratePdfAsync(DocumentPdfGeneratorInput input) + { + return _documentPdfAdminAppService.GeneratePdfAsync(input); + } + + [HttpGet] + [Route("files")] + public Task> GetPdfFilesAsync(GetPdfFilesInput input) + { + return _documentPdfAdminAppService.GetPdfFilesAsync(input); + } + + [HttpDelete] + [Route("delete-file")] + public Task DeletePdfFileAsync(DeletePdfFileInput input) + { + return _documentPdfAdminAppService.DeletePdfFileAsync(input); + } + + [HttpGet] + [Route("download")] + public Task DownloadPdfAsync(DocumentPdfGeneratorInput input) + { + return _documentPdfAdminAppService.DownloadPdfAsync(input); + } + + [HttpGet] + [Route("exists")] + public Task ExistsAsync(DocumentPdfGeneratorInput input) + { + return _documentPdfAdminAppService.ExistsAsync(input); + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs b/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs index e020486887..5b1cffeae1 100644 --- a/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs +++ b/modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs @@ -70,20 +70,6 @@ namespace Volo.Docs.Admin return _projectAppService.GetListWithoutDetailsAsync(); } - [HttpGet] - [Route("PdfFiles")] - public Task> GetPdfFilesAsync(GetPdfFilesInput input) - { - return _projectAppService.GetPdfFilesAsync(input); - } - - [HttpDelete] - [Route("DeletePdfFile")] - public Task DeletePdfFileAsync(DeletePdfFileInput input) - { - return _projectAppService.DeletePdfFileAsync(input); - } - [HttpPost] [Route("Reindex")] public Task ReindexAsync(ReindexInput input) diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml index b8ad9742d8..64cb3d3b01 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml @@ -8,40 +8,34 @@ @{ Layout = null; } - - - - - - -
- - -
-
- - -
-
- -
-
- - - - - -
\ No newline at end of file +
+ + + + + +
+ + +
+
+ + +
+
+ + + + +
+
\ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml.cs b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml.cs index 231f7c56eb..3396f3335c 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/GeneratePdf.cshtml.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; +using Volo.Docs.Admin.Documents; using Volo.Docs.Admin.Projects; using Volo.Docs.Common.Documents; using Volo.Docs.Common.Projects; @@ -15,20 +16,32 @@ public class GeneratePdfModal : DocsAdminPageModel { protected IProjectAppService ProjectAppService { get; } protected IProjectAdminAppService ProjectAdminAppService { get; } + protected IDocumentPdfAdminAppService DocumentPdfAdminAppService { get; } public GeneratePdfViewModel ViewModel { get; set; } + + [BindProperty(SupportsGet = true)] + public Guid ProjectId { get; set; } + + [BindProperty(SupportsGet = true)] + public string Version { get; set; } + + [BindProperty(SupportsGet = true)] + public string Language { get; set; } public GeneratePdfModal( IProjectAppService projectAppService, - IProjectAdminAppService projectAdminAppService) + IProjectAdminAppService projectAdminAppService, + IDocumentPdfAdminAppService documentPdfAdminAppService) { ProjectAppService = projectAppService; ProjectAdminAppService = projectAdminAppService; + DocumentPdfAdminAppService = documentPdfAdminAppService; } - public virtual async Task OnGetAsync(Guid id) + public virtual async Task OnGetAsync() { - var project = await ProjectAdminAppService.GetAsync(id); + var project = await ProjectAdminAppService.GetAsync(ProjectId); var versions = await ProjectAppService.GetVersionsAsync(project.ShortName); if(versions.Items.Count == 0) { @@ -40,7 +53,6 @@ public class GeneratePdfModal : DocsAdminPageModel var languages = await ProjectAppService.GetLanguageListAsync(project.ShortName, versions.Items.FirstOrDefault()?.Name); ViewModel = new GeneratePdfViewModel { - ProjectId = id, ShortName = project.ShortName, Versions = versions.Items.Select(x => new SelectListItem(x.DisplayName, x.Name)).ToList(), Languages = languages.Languages.Select(x => new SelectListItem(x.DisplayName, x.Code)).ToList() @@ -49,9 +61,20 @@ public class GeneratePdfModal : DocsAdminPageModel return Page(); } + public virtual async Task OnPostAsync() + { + await DocumentPdfAdminAppService.GeneratePdfAsync(new DocumentPdfGeneratorInput + { + ProjectId = ProjectId, + Version = Version, + LanguageCode = Language + }); + + return NoContent(); + } + public class GeneratePdfViewModel { - public Guid ProjectId { get; set; } public string ShortName { get; set; } public List Versions { get; set; } public List Languages { get; set; } diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/generatePdf.js b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/generatePdf.js index 91015b1584..42883088b8 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/generatePdf.js +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/generatePdf.js @@ -4,8 +4,6 @@ $(function () { var l = abp.localization.getResource('Docs'); var projectAppService = volo.docs.projects.docsProject; - var pdfGeneratorAppService = volo.docs.documents.docsDocumentPdfGenerator; - var projectAdminAppService = volo.docs.admin.projectsAdmin; var initModal = function (publicApi, args) { @@ -22,58 +20,6 @@ $(function () { }); }) - $("#GenerateBtn").click(function () { - var $btn = $(this); - $btn.buttonBusy(true); - $("#GenerateAndDownloadPdfBtn").buttonBusy(true); - var input = { - projectId: $("#ProjectId").val(), - version: $("#Version").val(), - languageCode: $("#Language").val(), - } - - function generatePdf(input) { - pdfGeneratorAppService.generatePdf(input, { - abpHandleError : false, - error: function (jqXHR) { - if (jqXHR.status === 200) { - abp.message.success(l('PdfFileGeneratedSuccessfully')); - $btn.buttonBusy(false); - $("#GenerateAndDownloadPdfBtn").buttonBusy(false); - } else { - abp.ajax.handleErrorStatusCode(jqXHR.status); - } - } - }); - } - if(shouldForceToGenerate(input)){ - projectAdminAppService.deletePdfFile(input).done(() =>{ - generatePdf(input); - }); - }else{ - generatePdf(input); - } - }) - - $("#GenerateAndDownloadPdfBtn").click(function () { - var input = { - projectId: $("#ProjectId").val(), - version: $("#Version").val(), - languageCode: $("#Language").val(), - } - if(shouldForceToGenerate(input)){ - projectAdminAppService.deletePdfFile(input).done(() =>{ - window.open(abp.appPath + 'api/docs/documents/pdf' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]), '_blank'); - }); - }else{ - window.open(abp.appPath + 'api/docs/documents/pdf' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]), '_blank'); - } - }) - - function shouldForceToGenerate(input) { - return $("#ForceToGenerate").is(":checked"); - } - return { initModal: initModal, }; diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/managePdfFiles.js b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/managePdfFiles.js index 8481867f46..50af57959d 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/managePdfFiles.js +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/managePdfFiles.js @@ -3,7 +3,7 @@ $(function () { abp.modals.projectManagePdfFiles = function () { var l = abp.localization.getResource('Docs'); - var projectAdminAppService = volo.docs.admin.projectsAdmin; + var documentPdfAdminAppService = volo.docs.admin.documentPdfAdmin; var _generatePdfModal = new abp.ModalManager({ viewUrl: abp.appPath + 'Docs/Admin/Projects/GeneratePdf', @@ -22,7 +22,7 @@ $(function () { scrollCollapse: true, order: [[2, 'desc']], ajax: abp.libs.datatables.createAjax( - volo.docs.admin.projectsAdmin.getPdfFiles, + documentPdfAdminAppService.getPdfFiles, { projectId : args.projectId } @@ -37,16 +37,23 @@ $(function () { return l('PdfFileDeletionWarningMessage', data.record.fileName); }, action: function (data) { - projectAdminAppService.deletePdfFile({ + documentPdfAdminAppService.deletePdfFile({ projectId: data.record.projectId, version: data.record.version, languageCode: data.record.languageCode }).then(() => { _dataTable.ajax.reloadEx(); - abp.notify.success(l('PdfGeneratedSuccessfully')); + abp.notify.success(l('PdfDeletedSuccessfully')); }) }, - } + }, + { + text: l('Download'), + action: function (data) { + var url = abp.appPath + 'api/docs/admin/documents/pdf?projectId=' + data.record.projectId + '&version=' + data.record.version + '&languageCode=' + data.record.languageCode; + window.open(url, '_blank'); + }, + }, ], }, }, @@ -78,13 +85,17 @@ $(function () { $('#GeneratePdfBtn').click(function () { _generatePdfModal.open({ - Id: args.projectId, + ProjectId: args.projectId, }); }); _generatePdfModal.onClose(function () { _dataTable.ajax.reloadEx(); }); + + _generatePdfModal.onResult(function (){ + abp.message.info(l('PdfGenerationStarted'), l('PdfGenerationStartedInfoMessage')); + }); }; return { diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.abppkg b/modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.abppkg index 4e12d28da1..1c2d273971 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.abppkg +++ b/modules/docs/src/Volo.Docs.Admin.Web/Volo.Docs.Admin.Web.abppkg @@ -6,7 +6,7 @@ "applicationName": "VoloDocs.Web", "module": "docs-admin", "url": "https://localhost:5001", - "output": "wwwroot/client-proxies", + "output": "wwwroot/client-proxies/", "serviceType": "application" } } diff --git a/modules/docs/src/Volo.Docs.Admin.Web/wwwroot/client-proxies/docs-admin-proxy.js b/modules/docs/src/Volo.Docs.Admin.Web/wwwroot/client-proxies/docs-admin-proxy.js index a1e2aafaca..2551021a80 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/wwwroot/client-proxies/docs-admin-proxy.js +++ b/modules/docs/src/Volo.Docs.Admin.Web/wwwroot/client-proxies/docs-admin-proxy.js @@ -5,6 +5,51 @@ (function(){ + // controller volo.docs.admin.documentPdfAdmin + + (function(){ + + abp.utils.createNamespace(window, 'volo.docs.admin.documentPdfAdmin'); + + volo.docs.admin.documentPdfAdmin.generatePdf = function(input, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/docs/admin/documents/pdf/generate' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]) + '', + type: 'GET', + dataType: null + }, ajaxParams)); + }; + + volo.docs.admin.documentPdfAdmin.getPdfFiles = function(input, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/docs/admin/documents/pdf/files' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '', + type: 'GET' + }, ajaxParams)); + }; + + volo.docs.admin.documentPdfAdmin.deletePdfFile = function(input, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/docs/admin/documents/pdf/delete-file' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]) + '', + type: 'DELETE', + dataType: null + }, ajaxParams)); + }; + + volo.docs.admin.documentPdfAdmin.downloadPdf = function(input, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/docs/admin/documents/pdf/download' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]) + '', + type: 'GET' + }, ajaxParams)); + }; + + volo.docs.admin.documentPdfAdmin.exists = function(input, ajaxParams) { + return abp.ajax($.extend(true, { + url: abp.appPath + 'api/docs/admin/documents/pdf/exists' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]) + '', + type: 'GET' + }, ajaxParams)); + }; + + })(); + // controller volo.docs.admin.documentsAdmin (function(){ @@ -136,21 +181,6 @@ }, ajaxParams)); }; - volo.docs.admin.projectsAdmin.getPdfFiles = function(input, ajaxParams) { - return abp.ajax($.extend(true, { - url: abp.appPath + 'api/docs/admin/projects/PdfFiles' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '', - type: 'GET' - }, ajaxParams)); - }; - - volo.docs.admin.projectsAdmin.deletePdfFile = function(input, ajaxParams) { - return abp.ajax($.extend(true, { - url: abp.appPath + 'api/docs/admin/projects/DeletePdfFile' + abp.utils.buildQueryString([{ name: 'projectId', value: input.projectId }, { name: 'version', value: input.version }, { name: 'languageCode', value: input.languageCode }]) + '', - type: 'DELETE', - dataType: null - }, ajaxParams)); - }; - volo.docs.admin.projectsAdmin.reindex = function(input, ajaxParams) { return abp.ajax($.extend(true, { url: abp.appPath + 'api/docs/admin/projects/Reindex', diff --git a/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo.Docs.Common.Application.Contracts.abppkg b/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo.Docs.Common.Application.Contracts.abppkg new file mode 100644 index 0000000000..5ae23d89fc --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo.Docs.Common.Application.Contracts.abppkg @@ -0,0 +1,3 @@ +{ + "role": "Volo.Docs.Application.Contracts" +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfAppService.cs b/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfAppService.cs new file mode 100644 index 0000000000..f5ab523b1f --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfAppService.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Content; + +namespace Volo.Docs.Common.Documents; + +public interface IDocumentPdfAppService : IApplicationService +{ + Task DownloadPdfAsync(DocumentPdfGeneratorInput input); + + Task ExistsAsync(DocumentPdfGeneratorInput input); +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfGeneratorAppService.cs b/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfGeneratorAppService.cs deleted file mode 100644 index dc8d87e820..0000000000 --- a/modules/docs/src/Volo.Docs.Common.Application.Contracts/Volo/Docs/Common/Documents/IDocumentPdfGeneratorAppService.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Application.Services; -using Volo.Abp.Content; - -namespace Volo.Docs.Common.Documents; - -public interface IDocumentPdfGeneratorAppService : IApplicationService -{ - Task GeneratePdfAsync(DocumentPdfGeneratorInput input); -} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.Application/Volo.Docs.Common.Application.abppkg b/modules/docs/src/Volo.Docs.Common.Application/Volo.Docs.Common.Application.abppkg new file mode 100644 index 0000000000..d8358a94f1 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.Application/Volo.Docs.Common.Application.abppkg @@ -0,0 +1,3 @@ +{ + "role": "Volo.Docs.Application" +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfAppService.cs b/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfAppService.cs new file mode 100644 index 0000000000..30a381a999 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfAppService.cs @@ -0,0 +1,54 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Options; +using Volo.Abp.Content; +using Volo.Docs.Projects; +using Volo.Docs.Projects.Pdf; + +namespace Volo.Docs.Common.Documents; + +[Authorize(DocsCommonPermissions.Projects.PdfGeneration)] +public class DocumentPdfAppService : DocsCommonAppServiceBase, IDocumentPdfAppService +{ + protected IProjectPdfGenerator ProjectPdfGenerator { get; } + protected IProjectRepository ProjectRepository { get; } + protected IProjectPdfFileStore ProjectPdfFileStore { get; } + protected IOptions Options { get; } + + public DocumentPdfAppService( + IProjectPdfGenerator projectPdfGenerator, + IProjectRepository projectRepository, + IProjectPdfFileStore projectPdfFileStore, + IOptions options) + { + ProjectPdfGenerator = projectPdfGenerator; + ProjectRepository = projectRepository; + ProjectPdfFileStore = projectPdfFileStore; + Options = options; + } + + public virtual async Task DownloadPdfAsync(DocumentPdfGeneratorInput input) + { + var project = await ProjectRepository.GetAsync(input.ProjectId); + var version = project.GetFullVersion(input.Version); + var languageCode = input.LanguageCode; + var fileName = Options.Value.CalculatePdfFileName(project, version, languageCode); + var fileStream = await ProjectPdfFileStore.GetOrNullAsync(project, version, languageCode); + + if (fileStream != null) + { + return new RemoteStreamContent(fileStream, fileName, "application/pdf"); + } + + return null; + } + + public virtual async Task ExistsAsync(DocumentPdfGeneratorInput input) + { + var project = await ProjectRepository.GetAsync(input.ProjectId); + var version = project.GetFullVersion(input.Version); + var languageCode = input.LanguageCode; + var fileName = Options.Value.CalculatePdfFileName(project, version, languageCode); + return project.FindPdfFile(fileName) != null; + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfGeneratorAppService.cs b/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfGeneratorAppService.cs deleted file mode 100644 index 3960a16179..0000000000 --- a/modules/docs/src/Volo.Docs.Common.Application/Volo/Docs/Common/Documents/DocumentPdfGeneratorAppService.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Volo.Abp.Application.Services; -using Volo.Abp.Content; -using Volo.Abp.Data; -using Volo.Docs.Projects; -using Volo.Docs.Projects.Pdf; - -namespace Volo.Docs.Common.Documents; - -[Authorize(DocsCommonPermissions.Projects.PdfGeneration)] -public class DocumentPdfGeneratorAppService : ApplicationService, IDocumentPdfGeneratorAppService -{ - protected IProjectPdfGenerator ProjectPdfGenerator { get; } - protected IProjectRepository ProjectRepository { get; } - - public DocumentPdfGeneratorAppService( - IProjectPdfGenerator projectPdfGenerator, - IProjectRepository projectRepository) - { - ProjectPdfGenerator = projectPdfGenerator; - ProjectRepository = projectRepository; - } - - public virtual async Task GeneratePdfAsync(DocumentPdfGeneratorInput input) - { - var project = await ProjectRepository.GetAsync(input.ProjectId, includeDetails: true); - - // https://github.com/abpframework/abp/blob/e96f601641ab8a4bb7d704d3b9df2c00517d96f6/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs#L73 - var inputVersionStringBuilder = new StringBuilder(); - input.Version = inputVersionStringBuilder.Append(GetProjectVersionPrefixIfExist(project)).Append(input.Version).ToString(); - return await ProjectPdfGenerator.GenerateAsync(project, input.Version, input.LanguageCode); - } - - private string GetProjectVersionPrefixIfExist(Project project) - { - if (GetGithubVersionProviderSource(project) != GithubVersionProviderSource.Branches) - { - return string.Empty; - } - - return project.GetProperty("VersionBranchPrefix"); - } - - private GithubVersionProviderSource GetGithubVersionProviderSource(Project project) - { - return project.HasProperty("GithubVersionProviderSource") - ? project.GetProperty("GithubVersionProviderSource") - : GithubVersionProviderSource.Releases; - } -} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.Generated.cs new file mode 100644 index 0000000000..e40ce0d1ec --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.Generated.cs @@ -0,0 +1,36 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Docs.Common.Documents; + +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Documents; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IDocumentPdfAppService), typeof(DocsDocumentPdfClientProxy))] +public partial class DocsDocumentPdfClientProxy : ClientProxyBase, IDocumentPdfAppService +{ + public virtual async Task DownloadPdfAsync(DocumentPdfGeneratorInput input) + { + return await RequestAsync(nameof(DownloadPdfAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentPdfGeneratorInput), input } + }); + } + + public virtual async Task ExistsAsync(DocumentPdfGeneratorInput input) + { + return await RequestAsync(nameof(ExistsAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentPdfGeneratorInput), input } + }); + } +} diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.cs new file mode 100644 index 0000000000..e692a1a0ee --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsDocumentPdfClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of DocsDocumentPdfClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Documents; + +public partial class DocsDocumentPdfClientProxy +{ +} diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.Generated.cs new file mode 100644 index 0000000000..19170e497e --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.Generated.cs @@ -0,0 +1,59 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Docs.Common.Projects; +using Volo.Docs.Documents; + +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Projects; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IProjectAppService), typeof(DocsProjectClientProxy))] +public partial class DocsProjectClientProxy : ClientProxyBase, IProjectAppService +{ + public virtual async Task> GetListAsync() + { + return await RequestAsync>(nameof(GetListAsync)); + } + + public virtual async Task GetAsync(string shortName) + { + return await RequestAsync(nameof(GetAsync), new ClientProxyRequestTypeValue + { + { typeof(string), shortName } + }); + } + + public virtual async Task GetDefaultLanguageCodeAsync(string shortName, string version) + { + return await RequestAsync(nameof(GetDefaultLanguageCodeAsync), new ClientProxyRequestTypeValue + { + { typeof(string), shortName }, + { typeof(string), version } + }); + } + + public virtual async Task> GetVersionsAsync(string shortName) + { + return await RequestAsync>(nameof(GetVersionsAsync), new ClientProxyRequestTypeValue + { + { typeof(string), shortName } + }); + } + + public virtual async Task GetLanguageListAsync(string shortName, string version) + { + return await RequestAsync(nameof(GetLanguageListAsync), new ClientProxyRequestTypeValue + { + { typeof(string), shortName }, + { typeof(string), version } + }); + } +} diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.cs new file mode 100644 index 0000000000..c908205174 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/DocsProjectClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of DocsProjectClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Projects; + +public partial class DocsProjectClientProxy +{ +} diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.Generated.cs similarity index 77% rename from modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.Generated.cs rename to modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.Generated.cs index 39608380c5..3419472890 100644 --- a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.Generated.cs +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.Generated.cs @@ -15,8 +15,8 @@ using Volo.Docs.Common.Documents; namespace Volo.Docs.Documents; [Dependency(ReplaceServices = true)] -[ExposeServices(typeof(IDocumentPdfGeneratorAppService), typeof(DocsDocumentPdfGeneratorClientProxy))] -public partial class DocsDocumentPdfGeneratorClientProxy : ClientProxyBase, IDocumentPdfGeneratorAppService +[ExposeServices(typeof(IDocumentPdfAppService), typeof(DocsDocumentPdfClientProxy))] +public partial class DocsDocumentPdfClientProxy : ClientProxyBase, IDocumentPdfAppService { public virtual async Task GeneratePdfAsync(DocumentPdfGeneratorInput input) { diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.cs b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.cs similarity index 74% rename from modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.cs rename to modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.cs index e14c1c25be..0ef8e84435 100644 --- a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfGeneratorClientProxy.cs +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/Volo/Docs/Documents/DocsDocumentPdfClientProxy.cs @@ -2,6 +2,6 @@ // ReSharper disable once CheckNamespace namespace Volo.Docs.Documents; -public partial class DocsDocumentPdfGeneratorClientProxy +public partial class DocsDocumentPdfClientProxy { } diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/docs-common-generate-proxy.json b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/docs-common-generate-proxy.json index db7303a427..16b7c6d4b0 100644 --- a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/docs-common-generate-proxy.json +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/ClientProxies/docs-common-generate-proxy.json @@ -4,20 +4,20 @@ "rootPath": "docs-common", "remoteServiceName": "AbpDocsCommon", "controllers": { - "Volo.Docs.Documents.DocsDocumentPdfGeneratorController": { - "controllerName": "DocsDocumentPdfGenerator", - "controllerGroupName": "Document", + "Volo.Docs.Documents.DocsDocumentPdfController": { + "controllerName": "DocsDocumentPdf", + "controllerGroupName": "DocumentPdf", "isRemoteService": true, "isIntegrationService": false, "apiVersion": null, - "type": "Volo.Docs.Documents.DocsDocumentPdfGeneratorController", + "type": "Volo.Docs.Documents.DocsDocumentPdfController", "interfaces": [ { - "type": "Volo.Docs.Common.Documents.IDocumentPdfGeneratorAppService", - "name": "IDocumentPdfGeneratorAppService", + "type": "Volo.Docs.Common.Documents.IDocumentPdfAppService", + "name": "IDocumentPdfAppService", "methods": [ { - "name": "GeneratePdfAsync", + "name": "DownloadPdfAsync", "parametersOnMethod": [ { "name": "input", @@ -32,16 +32,33 @@ "type": "Volo.Abp.Content.IRemoteStreamContent", "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" } + }, + { + "name": "ExistsAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.Boolean", + "typeSimple": "boolean" + } } ] } ], "actions": { - "GeneratePdfAsyncByInput": { - "uniqueName": "GeneratePdfAsyncByInput", - "name": "GeneratePdfAsync", + "DownloadPdfAsyncByInput": { + "uniqueName": "DownloadPdfAsyncByInput", + "name": "DownloadPdfAsync", "httpMethod": "GET", - "url": "api/docs/documents/pdf", + "url": "api/docs/documents/pdf/download", "supportedVersions": [], "parametersOnMethod": [ { @@ -96,7 +113,68 @@ "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" }, "allowAnonymous": null, - "implementFrom": "Volo.Docs.Common.Documents.IDocumentPdfGeneratorAppService" + "implementFrom": "Volo.Docs.Common.Documents.IDocumentPdfAppService" + }, + "ExistsAsyncByInput": { + "uniqueName": "ExistsAsyncByInput", + "name": "ExistsAsync", + "httpMethod": "GET", + "url": "api/docs/documents/pdf/exists", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput, Volo.Docs.Common.Application.Contracts", + "type": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "typeSimple": "Volo.Docs.Common.Documents.DocumentPdfGeneratorInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "ProjectId", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Version", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "LanguageCode", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "System.Boolean", + "typeSimple": "boolean" + }, + "allowAnonymous": null, + "implementFrom": "Volo.Docs.Common.Documents.IDocumentPdfAppService" } } }, diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi.Client/Volo.Docs.Common.HttpApi.Client.abppkg b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/Volo.Docs.Common.HttpApi.Client.abppkg new file mode 100644 index 0000000000..a4939ea991 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi.Client/Volo.Docs.Common.HttpApi.Client.abppkg @@ -0,0 +1,15 @@ +{ + "role": "Volo.Docs.HttpApi.Client", + "proxies": { + "csharp": { + "VoloDocs.Web-docs-common": { + "applicationName": "VoloDocs.Web", + "module": "docs-common", + "url": "https://localhost:5001", + "folder": "ClientProxies", + "serviceType": "all", + "withoutContracts": true + } + } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi/Volo.Docs.Common.HttpApi.abppkg b/modules/docs/src/Volo.Docs.Common.HttpApi/Volo.Docs.Common.HttpApi.abppkg new file mode 100644 index 0000000000..bbc082c681 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi/Volo.Docs.Common.HttpApi.abppkg @@ -0,0 +1,3 @@ +{ + "role": "Volo.Docs.HttpApi" +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfController.cs b/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfController.cs new file mode 100644 index 0000000000..06c20093aa --- /dev/null +++ b/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfController.cs @@ -0,0 +1,37 @@ +using System.Threading.Tasks; +using Asp.Versioning; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Content; +using Volo.Docs.Common; +using Volo.Docs.Common.Documents; + +namespace Volo.Docs.Documents; + +[RemoteService(Name = DocsCommonRemoteServiceConsts.RemoteServiceName)] +[Area(DocsCommonRemoteServiceConsts.ModuleName)] +[ControllerName("DocumentPdf")] +[Route("api/docs/documents/pdf")] +public class DocsDocumentPdfController : DocsControllerBase, IDocumentPdfAppService +{ + protected IDocumentPdfAppService DocumentPdfAppService { get; } + + public DocsDocumentPdfController(IDocumentPdfAppService documentPdfAppService) + { + DocumentPdfAppService = documentPdfAppService; + } + + [HttpGet] + [Route("download")] + public Task DownloadPdfAsync(DocumentPdfGeneratorInput input) + { + return DocumentPdfAppService.DownloadPdfAsync(input); + } + + [HttpGet] + [Route("exists")] + public Task ExistsAsync(DocumentPdfGeneratorInput input) + { + return DocumentPdfAppService.ExistsAsync(input); + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfGeneratorController.cs b/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfGeneratorController.cs deleted file mode 100644 index 31ae2a2f44..0000000000 --- a/modules/docs/src/Volo.Docs.Common.HttpApi/Volo/Docs/Documents/DocsDocumentPdfGeneratorController.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Threading.Tasks; -using Asp.Versioning; -using Microsoft.AspNetCore.Mvc; -using Volo.Abp; -using Volo.Abp.Content; -using Volo.Docs.Common; -using Volo.Docs.Common.Documents; - -namespace Volo.Docs.Documents; - -[RemoteService(Name = DocsCommonRemoteServiceConsts.RemoteServiceName)] -[Area(DocsCommonRemoteServiceConsts.ModuleName)] -[ControllerName("Document")] -[Route("api/docs/documents")] -public class DocsDocumentPdfGeneratorController : DocsControllerBase, IDocumentPdfGeneratorAppService -{ - protected IDocumentPdfGeneratorAppService DocumentPdfGeneratorAppService { get; } - - public DocsDocumentPdfGeneratorController(IDocumentPdfGeneratorAppService documentPdfGeneratorAppService) - { - DocumentPdfGeneratorAppService = documentPdfGeneratorAppService; - } - - [HttpGet] - [Route("pdf")] - public async Task GeneratePdfAsync(DocumentPdfGeneratorInput input) - { - var streamContent = await DocumentPdfGeneratorAppService.GeneratePdfAsync(input); - Response.Headers.ContentDisposition = $"inline; filename=\"{streamContent.FileName}\""; - return streamContent; - } -} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/BlobProjectPdfFileStore.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/BlobProjectPdfFileStore.cs index 315d89c49c..9d12923325 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/BlobProjectPdfFileStore.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/BlobProjectPdfFileStore.cs @@ -53,12 +53,6 @@ public class BlobProjectPdfFileStore : IProjectPdfFileStore, ITransientDependenc return null; } - var lastModificationTime = pdfFile.LastModificationTime ?? pdfFile.CreationTime; - if(lastModificationTime.Add(Options.Value.PdfFileCacheExpiration) <= Clock.Now) - { - return null; - } - return await BlobContainer.GetOrNullAsync(Options.Value.CalculatePdfFileName(project, version, languageCode)); } diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/DocsProjectPdfGeneratorOptions.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/DocsProjectPdfGeneratorOptions.cs index ef24e6ffd7..92c07ed1af 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/DocsProjectPdfGeneratorOptions.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/DocsProjectPdfGeneratorOptions.cs @@ -1,5 +1,4 @@ using System; -using Scriban.Syntax; namespace Volo.Docs.Projects.Pdf; @@ -29,12 +28,6 @@ public class DocsProjectPdfGeneratorOptions /// public string IndexPagePath { get; set; } - /// - /// PDF file cache expiration time. - /// Default value is 24 hours. - /// - public TimeSpan PdfFileCacheExpiration { get; set; } = TimeSpan.FromHours(24); - /// /// The function to calculate the PDF file name. /// Default is "{project.ShortName}-{version}-{languageCode}.pdf". @@ -50,6 +43,12 @@ public class DocsProjectPdfGeneratorOptions public Func DocumentContentNormalizer { get; set; } + /// + /// The maximum number of last versions to cache. + /// If null, all versions will be cached. + /// + public int? CacheLastVersionsCount { get; set; } + public DocsProjectPdfGeneratorOptions() { HtmlLayout = $@" diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/IProjectPdfGenerator.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/IProjectPdfGenerator.cs index af685659fa..dad173bc19 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/IProjectPdfGenerator.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/IProjectPdfGenerator.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -using Volo.Abp.Content; namespace Volo.Docs.Projects.Pdf; public interface IProjectPdfGenerator { - Task GenerateAsync(Project project, string version, string languageCode); + Task GenerateAsync(Project project, string version, string languageCode); } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs index c00973b3e8..5abb380199 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs @@ -52,16 +52,8 @@ public class ProjectPdfGenerator : IProjectPdfGenerator, ITransientDependency Logger = NullLogger.Instance; } - public virtual async Task GenerateAsync(Project project, string version, string languageCode) + public virtual async Task GenerateAsync(Project project, string version, string languageCode) { - var fileName = Options.Value.CalculatePdfFileName(project, version, languageCode); - var fileStream = await ProjectPdfFileStore.GetOrNullAsync(project, version, languageCode); - - if (fileStream != null) - { - return new RemoteStreamContent(fileStream, fileName, "application/pdf"); - } - Project = project; DocumentSource = DocumentStoreFactory.Create(project.DocumentStoreType); DocumentParams = await GetDocumentParamsAsync(project, version, languageCode); @@ -74,8 +66,6 @@ public class ProjectPdfGenerator : IProjectPdfGenerator, ITransientDependency var pdfStream = await HtmlToPdfRenderer.RenderAsync(title, html, AllPdfDocuments); await ProjectPdfFileStore.SetAsync(project, version, languageCode, pdfStream); - - return new RemoteStreamContent(pdfStream, fileName, "application/pdf"); } protected virtual async Task BuildHtmlAsync() diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs index 69fa3a7056..03020494d8 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Text; using JetBrains.Annotations; using Volo.Abp; +using Volo.Abp.Data; using Volo.Abp.Domain.Entities; namespace Volo.Docs.Projects @@ -126,5 +128,34 @@ namespace Volo.Docs.Projects PdfFiles.Remove(pdfFile); } } + + public virtual string GetFullVersion(string version) + { + var prefix = GetProjectVersionPrefixIfExist(this); + if (string.IsNullOrWhiteSpace(prefix) || version.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + { + return version; + } + + var inputVersionStringBuilder = new StringBuilder(); + return inputVersionStringBuilder.Append(prefix).Append(version).ToString(); + } + + protected virtual string GetProjectVersionPrefixIfExist(Project project) + { + if (GetGithubVersionProviderSource(project) != GithubVersionProviderSource.Branches) + { + return string.Empty; + } + + return project.GetProperty("VersionBranchPrefix"); + } + + protected virtual GithubVersionProviderSource GetGithubVersionProviderSource(Project project) + { + return project.HasProperty("GithubVersionProviderSource") + ? project.GetProperty("GithubVersionProviderSource") + : GithubVersionProviderSource.Releases; + } } } diff --git a/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.Generated.cs b/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.Generated.cs new file mode 100644 index 0000000000..418e46f6f8 --- /dev/null +++ b/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.Generated.cs @@ -0,0 +1,80 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.Abp.Http.Modeling; +using Volo.Docs.Documents; + +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Documents; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IDocumentAppService), typeof(DocsDocumentClientProxy))] +public partial class DocsDocumentClientProxy : ClientProxyBase, IDocumentAppService +{ + public virtual async Task GetAsync(GetDocumentInput input) + { + return await RequestAsync(nameof(GetAsync), new ClientProxyRequestTypeValue + { + { typeof(GetDocumentInput), input } + }); + } + + public virtual async Task GetDefaultAsync(GetDefaultDocumentInput input) + { + return await RequestAsync(nameof(GetDefaultAsync), new ClientProxyRequestTypeValue + { + { typeof(GetDefaultDocumentInput), input } + }); + } + + public virtual async Task GetNavigationAsync(GetNavigationDocumentInput input) + { + return await RequestAsync(nameof(GetNavigationAsync), new ClientProxyRequestTypeValue + { + { typeof(GetNavigationDocumentInput), input } + }); + } + + public virtual async Task GetResourceAsync(GetDocumentResourceInput input) + { + return await RequestAsync(nameof(GetResourceAsync), new ClientProxyRequestTypeValue + { + { typeof(GetDocumentResourceInput), input } + }); + } + + public virtual async Task> SearchAsync(DocumentSearchInput input) + { + return await RequestAsync>(nameof(SearchAsync), new ClientProxyRequestTypeValue + { + { typeof(DocumentSearchInput), input } + }); + } + + public virtual async Task FullSearchEnabledAsync() + { + return await RequestAsync(nameof(FullSearchEnabledAsync)); + } + + public virtual async Task> GetUrlsAsync(string prefix) + { + return await RequestAsync>(nameof(GetUrlsAsync), new ClientProxyRequestTypeValue + { + { typeof(string), prefix } + }); + } + + public virtual async Task GetParametersAsync(GetParametersDocumentInput input) + { + return await RequestAsync(nameof(GetParametersAsync), new ClientProxyRequestTypeValue + { + { typeof(GetParametersDocumentInput), input } + }); + } +} diff --git a/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.cs b/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.cs new file mode 100644 index 0000000000..7671995758 --- /dev/null +++ b/modules/docs/src/Volo.Docs.HttpApi.Client/ClientProxies/DocsDocumentClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of DocsDocumentClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.Docs.Documents; + +public partial class DocsDocumentClientProxy +{ +} diff --git a/modules/docs/src/Volo.Docs.HttpApi.Client/Volo.Docs.HttpApi.Client.abppkg b/modules/docs/src/Volo.Docs.HttpApi.Client/Volo.Docs.HttpApi.Client.abppkg index 7deef5e383..f32651686a 100644 --- a/modules/docs/src/Volo.Docs.HttpApi.Client/Volo.Docs.HttpApi.Client.abppkg +++ b/modules/docs/src/Volo.Docs.HttpApi.Client/Volo.Docs.HttpApi.Client.abppkg @@ -1,3 +1,15 @@ { - "role": "lib.http-api-client" + "role": "lib.http-api-client", + "proxies": { + "csharp": { + "VoloDocs.Web-docs": { + "applicationName": "VoloDocs.Web", + "module": "docs", + "url": "https://localhost:5001", + "folder": "ClientProxies", + "serviceType": "all", + "withoutContracts": true + } + } + } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml index e6a6f8470a..21d4aab5ac 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml @@ -291,12 +291,12 @@ id="sidebar-scroll" class="nav nav-list"> - @if (Model.HasDownloadPdfPermission) + @if (Model.HasDownloadPdf) { } } diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 471747fac1..ddac6c3f65 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -18,6 +18,7 @@ using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.EventBus.Local; using Volo.Docs.Common; +using Volo.Docs.Common.Documents; using Volo.Docs.Common.Projects; using Volo.Docs.Documents; using Volo.Docs.Documents.Rendering; @@ -92,7 +93,7 @@ namespace Volo.Docs.Pages.Documents.Project public bool IsLatestVersion { get; private set; } - public bool HasDownloadPdfPermission { get; set; } + public bool HasDownloadPdf { get; set; } public DocumentNavigationsDto DocumentNavigationsDto { get; private set; } @@ -103,6 +104,7 @@ namespace Volo.Docs.Pages.Documents.Project private readonly IWebDocumentSectionRenderer _webDocumentSectionRenderer; private readonly DocsUiOptions _uiOptions; private readonly IPermissionChecker _permissionChecker; + private readonly IDocumentPdfAppService _documentPdfAppService; protected IDocsLinkGenerator DocsLinkGenerator => LazyServiceProvider.LazyGetRequiredService(); @@ -114,7 +116,8 @@ namespace Volo.Docs.Pages.Documents.Project IProjectAppService projectAppService, IOptions options, IWebDocumentSectionRenderer webDocumentSectionRenderer, - IPermissionChecker permissionChecker) + IPermissionChecker permissionChecker, + IDocumentPdfAppService documentPdfAppService) { ObjectMapperContext = typeof(DocsWebModule); @@ -123,6 +126,7 @@ namespace Volo.Docs.Pages.Documents.Project _projectAppService = projectAppService; _webDocumentSectionRenderer = webDocumentSectionRenderer; _permissionChecker = permissionChecker; + _documentPdfAppService = documentPdfAppService; _uiOptions = options.Value; LocalizationResourceType = typeof(DocsResource); @@ -152,7 +156,7 @@ namespace Volo.Docs.Pages.Documents.Project ShowProjectsCombobox = _uiOptions.ShowProjectsCombobox && !_uiOptions.SingleProjectMode.Enable; ShowProjectsComboboxLabel = ShowProjectsCombobox && _uiOptions.ShowProjectsComboboxLabel; FullSearchEnabled = await _documentAppService.FullSearchEnabledAsync(); - HasDownloadPdfPermission = await _permissionChecker.IsGrantedAsync(DocsCommonPermissions.Projects.PdfGeneration); + try { await SetProjectAsync(); @@ -210,6 +214,12 @@ namespace Volo.Docs.Pages.Documents.Project await SetNavigationAsync(); SetLanguageSelectListItems(); + HasDownloadPdf = await _permissionChecker.IsGrantedAsync(DocsCommonPermissions.Projects.PdfGeneration) + && await _documentPdfAppService.ExistsAsync(new() + { + ProjectId = Project.Id, Version = LatestVersionInfo.IsSelected ? LatestVersionInfo.Version : Version, LanguageCode = DocumentLanguageCode + }); + return Page(); } diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js index 23eca169b5..d55d9f2ef9 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js @@ -421,5 +421,12 @@ var doc = doc || {}; return originalSet.call(this, key, value); }; + $('#DownloadPdfBtn').click(function () { + var url = $(this).data('url'); + if (url) { + window.open(url, '_blank'); + } + }); + }); })(jQuery); diff --git a/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.abppkg b/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.abppkg index 8f16736603..f25f6f3d3e 100644 --- a/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.abppkg +++ b/modules/docs/src/Volo.Docs.Web/Volo.Docs.Web.abppkg @@ -2,7 +2,18 @@ "role": "lib.mvc", "npmDependencies": { "@abp/docs": { - "version": "" + "version": "" + } + }, + "proxies": { + "Javascript": { + "VoloDocs.Web-docs": { + "applicationName": "VoloDocs.Web", + "module": "docs", + "url": "https://localhost:5001", + "output": "wwwroot/client-proxies/", + "serviceType": "application" + } } } } \ No newline at end of file diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index e2d65a631c..e916a379d2 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -323,6 +323,10 @@ $projects = ( "modules/docs/src/Volo.Docs.Admin.Web", "modules/docs/src/Volo.Docs.Application.Contracts", "modules/docs/src/Volo.Docs.Application", + "modules/docs/src/Volo.Docs.Common.Application.Contracts", + "modules/docs/src/Volo.Docs.Common.Application", + "modules/docs/src/Volo.Docs.Common.HttpApi", + "modules/docs/src/Volo.Docs.Common.HttpApi.Client", "modules/docs/src/Volo.Docs.Domain", "modules/docs/src/Volo.Docs.Domain.Shared", "modules/docs/src/Volo.Docs.EntityFrameworkCore",