Browse Source

Combobox fill method changed

pull/13804/head
Salih 4 years ago
parent
commit
3f147bb047
  1. 11
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentInfoDto.cs
  2. 3
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentAdminAppService.cs
  3. 2
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs
  4. 9
      modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/ProjectWithoutDetailsDto.cs
  5. 2
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs
  6. 6
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs
  7. 6
      modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs
  8. 7
      modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/DocumentsAdminClientProxy.Generated.cs
  9. 6
      modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/ProjectsAdminClientProxy.Generated.cs
  10. 6
      modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentsAdminController.cs
  11. 8
      modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs
  12. 23
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml
  13. 21
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml.cs
  14. 144
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js
  15. 5
      modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/Filter/FilterLanguageCodeItem.cs
  16. 5
      modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/Filter/FilterVersionItem.cs
  17. 11
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentInfo.cs
  18. 2
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs
  19. 1
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/IProjectRepository.cs
  20. 9
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/ProjectWithoutDetails.cs
  21. 84
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs
  22. 11
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Projects/EfCoreProjectRepository.cs
  23. 67
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs
  24. 18
      modules/docs/test/Volo.Docs.Admin.Application.Tests/Volo/Docs/DocumentAdminAppService_Tests.cs
  25. 1
      modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestData.cs
  26. 46
      modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs

11
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentInfoDto.cs

@ -0,0 +1,11 @@
using System;
namespace Volo.Docs.Admin.Documents;
public class DocumentInfoDto
{
public string Version { get; set; }
public string Format { get; set; }
public string LanguageCode { get; set; }
public Guid ProjectId { get; set; }
}

3
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/IDocumentAdminAppService.cs

@ -21,6 +21,7 @@ namespace Volo.Docs.Admin.Documents
Task RemoveFromCacheAsync(Guid documentId);
Task ReindexAsync(Guid documentId);
Task<FilterItems> GetFilterItemsAsync();
Task<List<DocumentInfoDto>> GetUniqueListWithoutDetails();
}
}

2
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/IProjectAdminAppService.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@ -20,5 +21,6 @@ namespace Volo.Docs.Admin.Projects
Task ReindexAsync(ReindexInput input);
Task ReindexAllAsync();
Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync();
}
}

9
modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Projects/ProjectWithoutDetailsDto.cs

@ -0,0 +1,9 @@
using System;
namespace Volo.Docs.Admin.Projects;
public class ProjectWithoutDetailsDto
{
public Guid Id { get; set; }
public string Name { get; set; }
}

2
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs

@ -14,6 +14,8 @@ namespace Volo.Docs.Admin
CreateMap<Project, ProjectDto>();
CreateMap<Document, DocumentDto>().Ignore(x => x.ProjectName);
CreateMap<DocumentWithoutContent, DocumentDto>();
CreateMap<ProjectWithoutDetails, ProjectWithoutDetailsDto>();
CreateMap<DocumentInfo, DocumentInfoDto>();
}
}
}

6
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs

@ -218,11 +218,13 @@ namespace Volo.Docs.Admin.Documents
await _elasticSearchService.AddOrUpdateAsync(document);
}
public Task<FilterItems> GetFilterItemsAsync()
public async Task<List<DocumentInfoDto>> GetUniqueListWithoutDetails()
{
return _documentRepository.GetFilterItemsAsync();
var documents = await _documentRepository.GetUniqueListWithoutDetails();
return ObjectMapper.Map<List<DocumentInfo>, List<DocumentInfoDto>>(documents);
}
private async Task UpdateDocumentUpdateInfoCache(Document document)
{
var cacheKey = $"DocumentUpdateInfo{document.ProjectId}#{document.Name}#{document.LanguageCode}#{document.Version}";

6
modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Projects/ProjectAdminAppService.cs

@ -156,5 +156,11 @@ namespace Volo.Docs.Admin.Projects
await ReindexProjectAsync(project.Id);
}
}
public async Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync()
{
var projects = await _projectRepository.GetListWithoutDetailsAsync();
return ObjectMapper.Map<List<ProjectWithoutDetails>, List<ProjectWithoutDetailsDto>>(projects);
}
}
}

7
modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/DocumentsAdminClientProxy.Generated.cs

@ -1,5 +1,6 @@
// 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.Application.Dtos;
using Volo.Abp.Http.Client;
@ -63,9 +64,9 @@ public partial class DocumentsAdminClientProxy : ClientProxyBase<IDocumentAdminA
{ typeof(Guid), documentId }
});
}
public async Task<FilterItems> GetFilterItemsAsync()
public Task<List<DocumentInfoDto>> GetUniqueListWithoutDetails()
{
return await RequestAsync<FilterItems>(nameof(GetFilterItemsAsync));
return RequestAsync<List<DocumentInfoDto>>(nameof(GetUniqueListWithoutDetails));
}
}

6
modules/docs/src/Volo.Docs.Admin.HttpApi.Client/ClientProxies/ProjectsAdminClientProxy.Generated.cs

@ -1,5 +1,6 @@
// 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.Application.Dtos;
using Volo.Abp.Http.Client;
@ -61,6 +62,11 @@ public partial class ProjectsAdminClientProxy : ClientProxyBase<IProjectAdminApp
await RequestAsync(nameof(ReindexAllAsync));
}
public Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync()
{
return RequestAsync<List<ProjectWithoutDetailsDto>>(nameof(GetListWithoutDetailsAsync));
}
public virtual async Task ReindexAsync(ReindexInput input)
{
await RequestAsync(nameof(ReindexAsync), new ClientProxyRequestTypeValue

6
modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/DocumentsAdminController.cs

@ -66,10 +66,10 @@ namespace Volo.Docs.Admin
}
[HttpGet]
[Route("GetFilterItems")]
public Task<FilterItems> GetFilterItemsAsync()
[Route("GetUniqueListDocumentWithoutDetails")]
public Task<List<DocumentInfoDto>> GetUniqueListWithoutDetails()
{
return _documentAdminAppService.GetFilterItemsAsync();
return _documentAdminAppService.GetUniqueListWithoutDetails();
}
}
}

8
modules/docs/src/Volo.Docs.Admin.HttpApi/Volo/Docs/Admin/ProjectsAdminController.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
@ -61,6 +62,13 @@ namespace Volo.Docs.Admin
return _projectAppService.ReindexAllAsync();
}
[HttpGet]
[Route("GetListProjectWithoutDetailsAsync")]
public Task<List<ProjectWithoutDetailsDto>> GetListWithoutDetailsAsync()
{
return _projectAppService.GetListWithoutDetailsAsync();
}
[HttpPost]
[Route("Reindex")]
public Task ReindexAsync(ReindexInput input)

23
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml

@ -43,7 +43,7 @@
name="ProjectId"
class="form-select">
<option></option>
@foreach (var project in Model.FilterItems.Projects)
@foreach (var project in Model.Projects)
{
<option value="@project.Id">@project.Name</option>
}
@ -60,10 +60,10 @@
name="Version"
class="form-select">
<option></option>
@foreach (var version in Model.FilterItems.Versions)
{
<option value="@version.Version" data-version="@Model.ToJson(version)">@version.Version</option>
}
@* @foreach (var version in Model.FilterItems.Versions) *@
@* { *@
@* <option value="@version.Version" style="display: none;" data-project-id="@version.ProjectId" data-language-code="@version.LanguageCode">@version.Version</option> *@
@* } *@
</select>
</div>
</abp-column>
@ -88,10 +88,10 @@
name="LanguageCode"
class="form-select">
<option></option>
@foreach (var language in Model.FilterItems.Languages)
{
<option value="@language.Code" data-language="@Model.ToJson(language)">@language.Code</option>
}
@* @foreach (var language in Model.FilterItems.Versions) *@
@* { *@
@* <option value="@language.LanguageCode" style="display: none;" data-project-id="@language.ProjectId" d>@language.LanguageCode</option> *@
@* } *@
</select>
</div>
</abp-column>
@ -165,11 +165,6 @@
id="Format"
name="Format"
class="form-select">
<option></option>
@foreach (var format in Model.FilterItems.Formats)
{
<option value="@format">@format</option>
}
</select>
</div>
</abp-column>

21
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml.cs

@ -1,35 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Volo.Docs.Admin.Documents;
using Volo.Docs.Admin.Projects;
using Volo.Docs.Documents.Filter;
namespace Volo.Docs.Admin.Pages.Docs.Admin.Documents;
[Authorize(DocsAdminPermissions.Projects.Default)]
public class IndexModel : DocsAdminPageModel
{
private readonly IDocumentAdminAppService _documentAdminAppService;
public FilterItems FilterItems { get; set; }
private readonly IProjectAdminAppService _projectAdminAppService;
public List<ProjectWithoutDetailsDto> Projects { get; set; }
public IndexModel(IDocumentAdminAppService documentAdminAppService)
public IndexModel(IProjectAdminAppService projectAdminAppService)
{
_documentAdminAppService = documentAdminAppService;
}
public string ToJson(object obj)
{
return JsonConvert.SerializeObject(obj);
_projectAdminAppService = projectAdminAppService;
}
public virtual async Task<IActionResult> OnGet()
{
FilterItems = await _documentAdminAppService.GetFilterItemsAsync();
Projects = await _projectAdminAppService.GetListWithoutDetailsAsync();
return Page();
}
}

144
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js

@ -6,70 +6,120 @@ $(function () {
return $datePicker.data().datepicker.getFormattedDate('yyyy-mm-dd');
};
var comboboxItems = [];
abp.ajax({
url: abp.appPath + 'api/docs/admin/documents/GetUniqueListDocumentWithoutDetails',
type: 'GET',
dataType: 'json',
success: function (data) {
comboboxItems = data;
fillOptions();
}
});
var $projectId = $('#ProjectId');
var $version = $('#Version');
var $languageCode = $('#LanguageCode');
var $format = $('#Format');
function fillOptions() {
var selectedVersion = $version.val();
var selectedLanguageCode = $languageCode.val();
var selectedFormat = $format.val();
var selectedProjectId = $projectId.val();
function $getOptions($select){
var select = $select.get(0);
return $(select.options)
}
$version.empty();
$languageCode.empty();
$format.empty();
$version.append($('<option/>').val(''));
$languageCode.append($('<option/>').val(''));
$format.append($('<option/>').val(''));
function showLanguages(){
var selectedProjectId = $projectId.val();
var selectedVersion = $version.val();
var languages = $getOptions($languageCode);
languages.each(function(){
var language = $(this);
var languageCodeDto = language.attr('data-language');
if(!languageCodeDto) return;
languageCodeDto = JSON.parse(languageCodeDto);
if((!selectedVersion || languageCodeDto.Versions.includes(selectedVersion))
&& (!selectedProjectId || languageCodeDto.ProjectIds.includes(selectedProjectId)))
{
language.show();
}
else{
language.hide();
if(language.is(':selected')){
$languageCode.val('');
}
comboboxItems.forEach(function (item) {
if (!selectedProjectId || item.projectId === selectedProjectId) {
appendVersion(item,selectedVersion,selectedLanguageCode,selectedFormat);
appendLanguageCode(item,selectedLanguageCode,selectedVersion,selectedFormat);
appendFormat(item,selectedFormat,selectedVersion,selectedLanguageCode);
}
});
}
function showVersions(){
var selectedProjectId = $projectId.val();
var selectedLanguageCode = $languageCode.val();
var versions = $getOptions($version);
versions.each(function(){
var version = $(this);
var verisonDto = version.attr('data-version');
if(!verisonDto) return;
verisonDto = JSON.parse(verisonDto);
if((!selectedLanguageCode || verisonDto.Languages.includes(selectedLanguageCode))
&& (!selectedProjectId || verisonDto.ProjectIds.includes(selectedProjectId)))
{
version.show();
function appendFormat(item,selectedFormat,selectedVersion,selectedLanguageCode) {
if(selectedVersion && selectedVersion !== item.version) {
return;
}
if(selectedLanguageCode && selectedLanguageCode !== item.languageCode) {
return;
}
if($format.find('option[value="' + item.format + '"]').length === 0) {
var formatOption = $('<option>',{
value: item.format,
text: item.format
});
if(selectedFormat === item.format) {
formatOption.attr('selected', 'selected');
}
else{
version.hide();
if(version.is(':selected')){
$version.val('');
}
$format.append(formatOption);
}
}
function appendLanguageCode(item,selectedLanguageCode,selectedVersion,selectedFormat) {
if(selectedVersion && selectedVersion !== item.version) {
return;
}
if(selectedFormat && selectedFormat !== item.format) {
return;
}
if($languageCode.find('option[value="' + item.languageCode + '"]').length === 0) {
var languageCodeOption = $('<option>',{
value: item.languageCode,
text: item.languageCode
});
if(selectedLanguageCode === item.languageCode) {
languageCodeOption.attr('selected', 'selected');
}
});
$languageCode.append(languageCodeOption);
}
}
function appendVersion(item,selectedVersion,selectedLanguageCode,selectedFormat) {
if(selectedLanguageCode && item.languageCode !== selectedLanguageCode) {
return;
}
if(selectedFormat && selectedFormat !== item.format) {
return;
}
if($version.find('option[value="' + item.version + '"]').length === 0) {
var versionOption = $('<option>', {
value: item.version,
text: item.version
})
if(selectedVersion === item.version) {
versionOption.attr('selected', 'selected');
}
$version.append(versionOption);
}
}
$projectId.on('change', function () {
showVersions();
showLanguages();
fillOptions();
});
$version.on('change', function () {
showLanguages();
fillOptions();
});
$languageCode.on('change', function () {
showVersions();
fillOptions();
});
$format.on('change', function () {
fillOptions();
});
var getFilter = function () {

5
modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/Filter/FilterLanguageCodeItem.cs

@ -5,7 +5,6 @@ namespace Volo.Docs.Documents.Filter;
public class FilterLanguageCodeItem
{
public string Code { get; set; }
public IEnumerable<Guid> ProjectIds { get; set; }
public IEnumerable<string> Versions { get; set; }
public string LanguageCode { get; set; }
public Guid ProjectId { get; set; }
}

5
modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/Filter/FilterVersionItem.cs

@ -6,6 +6,7 @@ namespace Volo.Docs.Documents.Filter;
public class FilterVersionItem
{
public string Version { get; set; }
public IEnumerable<Guid> ProjectIds { get; set; }
public IEnumerable<string> Languages { get; set; }
public string Format { get; set; }
public string LanguageCode { get; set; }
public Guid ProjectId { get; set; }
}

11
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentInfo.cs

@ -0,0 +1,11 @@
using System;
namespace Volo.Docs.Documents;
public class DocumentInfo
{
public string Version { get; set; }
public string Format { get; set; }
public string LanguageCode { get; set; }
public Guid ProjectId { get; set; }
}

2
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs

@ -11,6 +11,7 @@ namespace Volo.Docs.Documents
public interface IDocumentRepository : IBasicRepository<Document>
{
Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default);
Task<List<DocumentInfo>> GetUniqueListWithoutDetails(CancellationToken cancellationToken = default);
Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default);
@ -75,6 +76,5 @@ namespace Volo.Docs.Documents
CancellationToken cancellationToken = default);
Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default);
Task<FilterItems> GetFilterItemsAsync(CancellationToken cancellationToken = default);
}
}

1
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/IProjectRepository.cs

@ -9,6 +9,7 @@ namespace Volo.Docs.Projects
public interface IProjectRepository : IBasicRepository<Project, Guid>
{
Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default);
Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default);
Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default);

9
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/ProjectWithoutDetails.cs

@ -0,0 +1,9 @@
using System;
namespace Volo.Docs.Projects;
public class ProjectWithoutDetails
{
public Guid Id { get; set; }
public string Name { get; set; }
}

84
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs

@ -33,6 +33,23 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<DocumentInfo>> GetUniqueListWithoutDetails(CancellationToken cancellationToken = default)
{
// Todo : add project id to query
return await (await GetDbSetAsync())
.Select(x=> new DocumentInfo
{
ProjectId = x.ProjectId,
Version = x.Version,
LanguageCode = x.LanguageCode,
Format = x.Format,
})
.Distinct()
.OrderByDescending(x=>x.Version)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<Document>> GetListByProjectId(Guid projectId,
CancellationToken cancellationToken = default)
{
@ -217,65 +234,14 @@ namespace Volo.Docs.Documents
LastCachedTime = x.d.LastCachedTime
});
}
public async Task<FilterItems> GetFilterItemsAsync(CancellationToken cancellationToken = default)
{
var filterItems = new FilterItems();
filterItems.Formats = await GetFormats(cancellationToken);
filterItems.Projects = await GetFilterProjectItems(cancellationToken);
filterItems.Versions = await GetFilterVersionItems(cancellationToken);
filterItems.Languages = await GetFilterLanguageCodeItems(cancellationToken);
return filterItems;
}
private async Task<List<string>> GetFormats(CancellationToken cancellationToken)
{
return await (await GetDbSetAsync()).Select(x => x.Format).Distinct().ToListAsync(cancellationToken);
}
private async Task<List<FilterProjectItem>> GetFilterProjectItems(CancellationToken cancellationToken)
{
return await (await GetDbContextAsync())
.Projects
.Select(x=>new FilterProjectItem
{
Id = x.Id,
Name = x.Name
})
.OrderBy(x=>x.Name)
.ToListAsync(GetCancellationToken(cancellationToken));
}
private async Task<List<FilterLanguageCodeItem>> GetFilterLanguageCodeItems(CancellationToken cancellationToken)
{
return await (await GetDbSetAsync())
.GroupBy(x => x.LanguageCode)
.Select(x => new FilterLanguageCodeItem
{
ProjectIds = x.Select(x2 => x2.ProjectId).Distinct(),
Code = x.Key,
Versions = x.Select(x2 => x2.Version).Distinct()
})
.OrderBy(x=>x.Code)
.ToListAsync(GetCancellationToken(cancellationToken));
}
private async Task<List<FilterVersionItem>> GetFilterVersionItems(CancellationToken cancellationToken)
{
return await (await GetDbSetAsync())
.GroupBy(x => x.Version)
.Select(x => new FilterVersionItem
{
ProjectIds = x.Select(x2 => x2.ProjectId).Distinct(),
Version = x.Key,
Languages = x.Select(x2 => x2.LanguageCode).Distinct()
})
.OrderByDescending(x => x.Version)
.ToListAsync(GetCancellationToken(cancellationToken));
}
// private async Task<List<FilterVersionItem>> GetFilterVersionItems(CancellationToken cancellationToken)
// {
// var q = (await GetDbSetAsync());
// return await q.Select(x => new FilterVersionItem { Version = x.Version, ProjectId = x.ProjectId, LanguageCode = x.LanguageCode , Format = x.Format })
// .Distinct()
// .OrderByDescending(x=>x.Version)
// .ToListAsync(GetCancellationToken(cancellationToken));
// }
}
}

11
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Projects/EfCoreProjectRepository.cs

@ -28,6 +28,17 @@ namespace Volo.Docs.Projects
return projects;
}
public async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Select(x=> new ProjectWithoutDetails() {
Id = x.Id,
Name = x.Name,
})
.OrderBy(x=>x.Name)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<Project> GetByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{
var normalizeShortName = NormalizeShortName(shortName);

67
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -36,6 +36,11 @@ namespace Volo.Docs.Documents
.ToListAsync(GetCancellationToken(cancellationToken));
}
public Task<List<DocumentWithoutDetails>> GetUniqueListWithoutDetails(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
public async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
@ -157,67 +162,7 @@ namespace Volo.Docs.Documents
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken));
}
public async Task<FilterItems> GetFilterItemsAsync(CancellationToken cancellationToken = default)
{
var filterItems = new FilterItems();
filterItems.Formats = await GetFormats(cancellationToken);
filterItems.Projects = await GetFilterProjectItems(cancellationToken);
filterItems.Versions = await GetFilterVersionItems(cancellationToken);
filterItems.Languages = await GetFilterLanguageCodeItems(cancellationToken);
return filterItems;
}
private async Task<List<string>> GetFormats(CancellationToken cancellationToken)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Select(x => x.Format).Distinct().ToListAsync(cancellationToken);
}
private async Task<List<FilterProjectItem>> GetFilterProjectItems(CancellationToken cancellationToken)
{
return await (await GetMongoQueryableAsync<Project>(cancellationToken))
.Select(x=>new FilterProjectItem
{
Id = x.Id,
Name = x.Name
})
.OrderBy(x=>x.Name)
.ToListAsync(GetCancellationToken(cancellationToken));
}
private async Task<List<FilterLanguageCodeItem>> GetFilterLanguageCodeItems(CancellationToken cancellationToken)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.GroupBy(x => x.LanguageCode)
.Select(x => new FilterLanguageCodeItem
{
ProjectIds = x.Select(x2 => x2.ProjectId).Distinct(),
Code = x.Key,
Versions = x.Select(x2 => x2.Version).Distinct()
})
.OrderBy(x=>x.Code)
.ToListAsync(GetCancellationToken(cancellationToken));
}
private async Task<List<FilterVersionItem>> GetFilterVersionItems(CancellationToken cancellationToken)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.GroupBy(x => x.Version)
.Select(x => new FilterVersionItem
{
ProjectIds = x.Select(x2 => x2.ProjectId).Distinct(),
Version = x.Key,
Languages = x.Select(x2 => x2.LanguageCode).Distinct()
})
.OrderByDescending(x => x.Version)
.ToListAsync(GetCancellationToken(cancellationToken));
}
protected virtual async Task<IMongoQueryable<DocumentWithoutContent>> ApplyFilterForGetAll(
IMongoQueryable<Document> query,
Guid? projectId,

18
modules/docs/test/Volo.Docs.Admin.Application.Tests/Volo/Docs/DocumentAdminAppService_Tests.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;
using Volo.Docs.Admin.Documents;
using Volo.Docs.Documents;
@ -51,5 +52,20 @@ namespace Volo.Docs
(await _documentRepository.FindAsync(_testData.PorjectId, "Part-I.md", "en", "1.0.0")).ShouldNotBeNull();
(await _documentRepository.FindAsync(_testData.PorjectId, "Part-II.md", "en", "1.0.0")).ShouldNotBeNull();
}
[Fact]
public async Task GetFilterItemsAsync()
{
var filterItems = await _documentAdminAppService.GetFilterItemsAsync();
filterItems.Projects.ShouldNotBeEmpty();
filterItems.Languages.ShouldNotBeEmpty();
filterItems.Versions.ShouldNotBeEmpty();
filterItems.Projects.ShouldContain(p => p.Id == _testData.PorjectId);
filterItems.Versions.ShouldContain(p => p.Version == "2.0.0" && p.ProjectId == _testData.PorjectId);
filterItems.Languages.ShouldContain(p => p.LanguageCode == "en" && p.ProjectId == _testData.PorjectId);
filterItems.Formats.ShouldContain(p => p == "md");
}
}
}

1
modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestData.cs

@ -6,5 +6,6 @@ namespace Volo.Docs
public class DocsTestData : ISingletonDependency
{
public Guid PorjectId { get; } = Guid.NewGuid();
public Guid PorjectId2 { get; set; } = Guid.NewGuid();
}
}

46
modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocsTestDataBuilder.cs

@ -49,6 +49,52 @@ namespace Volo.Docs
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
var project2 = new Project(
_testData.PorjectId2,
"ABP vNext2",
"ABP2",
GithubDocumentSource.Type,
"md",
"index2",
"docs-nav.json",
"docs-params.json"
);
project2
.SetProperty("GitHubRootUrl", "https://github.com/abpframework/abp/tree/{version}/docs/en/")
.SetProperty("GitHubAccessToken", "123456")
.SetProperty("GitHubUserAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
await _projectRepository.InsertAsync(project2);
await _documentRepository.InsertAsync(new Document(Guid.NewGuid(), project2.Id, "CLI.md", "4.0.0", "en", "CLI.md",
"this is abp cli", "md", "https://github.com/abpframework/abp/blob/2.0.0/docs/en/CLI.md",
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
await _documentRepository.InsertAsync(new Document(Guid.NewGuid(), project2.Id, "CLI.md", "4.0.0", "tr", "CLI.md",
"this is abp cli", "md", "https://github.com/abpframework/abp/blob/2.0.0/docs/en/CLI.md",
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
await _documentRepository.InsertAsync(new Document(Guid.NewGuid(), project2.Id, "CLI.md", "4.0.0", "en", "CLI2.md",
"this is abp cli", "md", "https://github.com/abpframework/abp/blob/2.0.0/docs/en/CLI.md",
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
await _documentRepository.InsertAsync(new Document(Guid.NewGuid(), project2.Id, "CLI.md", "4.1.0", "en", "CLI.md",
"this is abp cli", "md", "https://github.com/abpframework/abp/blob/2.0.0/docs/en/CLI.md",
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
}
}
}
Loading…
Cancel
Save