docs module minor refactors

pull/5786/head
Yunus Emre Kalkan 5 years ago
parent 402f38ec68
commit 91b34466dd

@ -16,7 +16,6 @@ namespace Volo.Docs.Admin
projects.AddChild(DocsAdminPermissions.Projects.Create, L("Permission:Create"));
group.AddPermission(DocsAdminPermissions.Documents.Default, L("Permission:Documents"));
}
private static LocalizableString L(string name)

@ -19,7 +19,6 @@ namespace Volo.Docs.Admin
public const string Default = GroupName + ".Documents";
}
public static string[] GetAll()
{
return ReflectionHelper.GetPublicConstantsRecursively(typeof(DocsAdminPermissions));

@ -5,17 +5,9 @@ using Volo.Docs.Documents;
namespace Volo.Docs.Admin.Documents
{
public class PullDocumentInput
public class PullDocumentInput : PullAllDocumentInput
{
public Guid ProjectId { get; set; }
[DynamicStringLength(typeof(DocumentConsts), nameof(DocumentConsts.MaxNameLength))]
public string Name { get; set; }
[DynamicStringLength(typeof(DocumentConsts), nameof(DocumentConsts.MaxLanguageCodeNameLength))]
public string LanguageCode { get; set; }
[DynamicStringLength(typeof(DocumentConsts), nameof(DocumentConsts.MaxVersionNameLength))]
public string Version { get; set; }
}
}
}

@ -42,9 +42,10 @@ namespace Volo.Docs.Admin.Projects
var totalCount = await _projectRepository.GetCountAsync();
var dtos = ObjectMapper.Map<List<Project>, List<ProjectDto>>(projects);
return new PagedResultDto<ProjectDto>(totalCount, dtos);
return new PagedResultDto<ProjectDto>(
totalCount,
ObjectMapper.Map<List<Project>, List<ProjectDto>>(projects)
);
}
public async Task<ProjectDto> GetAsync(Guid id)

@ -10,9 +10,11 @@ namespace Volo.Docs.Admin
{
public DocsAdminWebAutoMapperProfile()
{
CreateMap<CreateModel.CreateGithubProjectViewModel, CreateProjectDto>().Ignore(x => x.ExtraProperties);
CreateMap<CreateModel.CreateGithubProjectViewModel, CreateProjectDto>()
.Ignore(x => x.ExtraProperties);
CreateMap<EditModel.EditGithubProjectViewModel, UpdateProjectDto>().Ignore(x => x.ExtraProperties);
CreateMap<EditModel.EditGithubProjectViewModel, UpdateProjectDto>()
.Ignore(x => x.ExtraProperties);
CreateMap<ProjectDto, EditModel.EditGithubProjectViewModel > ()
.Ignore(x => x.GitHubAccessToken)

@ -31,7 +31,6 @@ namespace Volo.Docs.Admin
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new DocsMenuContributor());

@ -98,7 +98,7 @@
</div>
</div>
<div class="col-auto">
<div class="input-group mb-2">
<div class="input-group-prepend">
@ -110,12 +110,12 @@
id="CreationTimeMin"
name="CreationTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
placeholder="@L["StartDate"].Value">
<span>-</span>
<input type="date"
id="CreationTimeMax"
name="CreationTimeMax"
placeholder="@L["EndDate"]"
placeholder="@L["EndDate"].Value"
class="form-control datepicker">
</span>
</div>
@ -132,12 +132,12 @@
id="LastUpdatedTimeMin"
name="LastUpdatedTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
placeholder="@L["StartDate"].Value">
<span>-</span>
<input type="date"
id="LastUpdatedTimeMax"
name="LastUpdatedTimeMax"
placeholder="@L["EndDate"]"
placeholder="@L["EndDate"].Value"
class="form-control datepicker">
</span>
</div>
@ -154,12 +154,12 @@
id="LastSignificantUpdateTimeMin"
name="LastSignificantUpdateTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
placeholder="@L["StartDate"].Value">
<span>-</span>
<input type="date"
id="LastSignificantUpdateTimeMax"
name="LastSignificantUpdateTimeMax"
placeholder="@L["EndDate"]"
placeholder="@L["EndDate"].Value"
class="form-control datepicker">
</span>
</div>
@ -176,12 +176,12 @@
id="LastCachedTimeMin"
name="LastCachedTimeMin"
class="form-control datepicker"
placeholder="@L["StartDate"]">
placeholder="@L["StartDate"].Value">
<span>-</span>
<input type="date"
id="LastCachedTimeMax"
name="LastCachedTimeMax"
placeholder="@L["EndDate"]"
placeholder="@L["EndDate"].Value"
class="form-control datepicker">
</span>
</div>
@ -212,4 +212,4 @@
</abp-table>
</abp-card-body>
</abp-card>
</div>
</div>

@ -18,17 +18,20 @@
creationTimeMax: getFormattedDate($('#CreationTimeMax')),
lastUpdatedTimeMin: getFormattedDate($('#LastUpdatedTimeMin')),
lastUpdatedTimeMax: getFormattedDate($('#LastUpdatedTimeMax')),
lastSignificantUpdateTimeMin: getFormattedDate(
$('#LastSignificantUpdateTimeMin')
),
lastSignificantUpdateTimeMax: getFormattedDate(
$('#LastSignificantUpdateTimeMax')
),
lastSignificantUpdateTimeMin: getFormattedDate($('#LastSignificantUpdateTimeMin')),
lastSignificantUpdateTimeMax: getFormattedDate($('#LastSignificantUpdateTimeMax')),
lastCachedTimeMin: getFormattedDate($('#LastCachedTimeMin')),
lastCachedTimeMax: getFormattedDate($('#LastCachedTimeMax')),
};
};
var parseDateToLocaleDateString = function (date) {
var parsedDate = Date.parse(date);
return new Date(parsedDate).toLocaleDateString(
abp.localization.currentCulture.name
);
};
var dataTable = $('#DocumentsTable').DataTable(
abp.libs.datatables.normalizeConfiguration({
processing: true,
@ -55,9 +58,7 @@
service
.removeFromCache(data.record.id)
.then(function () {
abp.message.success(
l('RemovedFromCache')
);
abp.message.success(l('RemovedFromCache'));
dataTable.ajax.reload();
});
},
@ -74,9 +75,7 @@
service
.reindex(data.record.id)
.then(function () {
abp.message.success(
l('ReindexCompleted')
);
abp.message.success(l('ReindexCompleted'));
dataTable.ajax.reload();
});
},
@ -112,10 +111,7 @@
return '';
}
var date = Date.parse(creationTime);
return new Date(date).toLocaleDateString(
abp.localization.currentCulture.name
);
return parseDateToLocaleDateString(creationTime);
},
},
{
@ -126,10 +122,7 @@
return '';
}
var date = Date.parse(lastUpdatedTime);
return new Date(date).toLocaleDateString(
abp.localization.currentCulture.name
);
return parseDateToLocaleDateString(lastUpdatedTime);
},
},
{
@ -140,10 +133,7 @@
return '';
}
var date = Date.parse(lastSignificantUpdateTime);
return new Date(date).toLocaleDateString(
abp.localization.currentCulture.name
);
return parseDateToLocaleDateString(lastSignificantUpdateTime);
},
},
{
@ -154,10 +144,7 @@
return '';
}
var date = Date.parse(lastCachedTime);
return new Date(date).toLocaleDateString(
abp.localization.currentCulture.name
);
return parseDateToLocaleDateString(lastCachedTime);
},
},
],

@ -156,8 +156,7 @@
.confirm(l('ReIndexAllProjectConfirmationMessage'))
.done(function (accepted) {
if (accepted) {
volo.docs.admin.projectsAdmin
.reindexAll()
volo.docs.admin.projectsAdmin.reindexAll()
.then(function () {
abp.message.success(
l('SuccessfullyReIndexAllProject')

@ -11,10 +11,9 @@ namespace Volo.Docs
{
CreateMap<Project, ProjectDto>();
CreateMap<VersionInfo, VersionInfoDto>();
CreateMap<Document, DocumentWithDetailsDto>()
.Ignore(x => x.Project).Ignore(x => x.Contributors);
CreateMap<Document, DocumentWithDetailsDto>().Ignore(x => x.Project).Ignore(x => x.Contributors);
CreateMap<DocumentContributor, DocumentContributorDto>();
CreateMap<DocumentResource, DocumentResourceDto>();
}
}
}
}

@ -213,8 +213,7 @@ namespace Volo.Docs.Documents
input.Version
);
if (!JsonConvertExtensions.TryDeserializeObject<DocumentParametersDto>(document.Content,
out var documentParameters))
if (!JsonConvertExtensions.TryDeserializeObject<DocumentParametersDto>(document.Content,out var documentParameters))
{
throw new UserFriendlyException(
$"Cannot validate document parameters file '{project.ParametersDocumentName}' for the project {project.Name}.");
@ -257,10 +256,10 @@ namespace Volo.Docs.Documents
}
var cacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey(
project: project,
documentName: document.Name,
languageCode: document.LanguageCode,
version: document.Version
project,
document.Name,
document.LanguageCode,
document.Version
);
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
@ -277,9 +276,10 @@ namespace Volo.Docs.Documents
protected virtual DocumentWithDetailsDto CreateDocumentWithDetailsDto(Project project, Document document)
{
var documentDto = ObjectMapper.Map<Document, DocumentWithDetailsDto>(document);
documentDto.Project = ObjectMapper.Map<Project, ProjectDto>(project);
documentDto.Contributors =
ObjectMapper.Map<List<DocumentContributor>, List<DocumentContributorDto>>(document.Contributors);
documentDto.Contributors = ObjectMapper.Map<List<DocumentContributor>, List<DocumentContributorDto>>(document.Contributors);
return documentDto;
}
@ -289,8 +289,7 @@ namespace Volo.Docs.Documents
Logger.LogInformation($"Not found in the cache. Requesting {documentName} from the source...");
var source = _documentStoreFactory.Create(project.DocumentStoreType);
var sourceDocument = await source.GetDocumentAsync(project, documentName, languageCode, version,
oldDocument?.LastSignificantUpdateTime);
var sourceDocument = await source.GetDocumentAsync(project, documentName, languageCode, version, oldDocument?.LastSignificantUpdateTime);
await _documentRepository.DeleteAsync(project.Id, sourceDocument.Name, sourceDocument.LanguageCode,
sourceDocument.Version);
@ -299,10 +298,10 @@ namespace Volo.Docs.Documents
Logger.LogInformation($"Document retrieved: {documentName}");
var cacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey(
project: project,
documentName: sourceDocument.Name,
languageCode: sourceDocument.LanguageCode,
version: sourceDocument.Version
project,
sourceDocument.Name,
sourceDocument.LanguageCode,
sourceDocument.Version
);
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
@ -351,12 +350,13 @@ namespace Volo.Docs.Documents
private string GetProjectVersionPrefixIfExist(Project project)
{
if (GetGithubVersionProviderSource(project) == GithubVersionProviderSource.Branches)
if (GetGithubVersionProviderSource(project) != GithubVersionProviderSource.Branches)
{
return project.ExtraProperties["VersionBranchPrefix"].ToString();
return string.Empty;
}
return "";
return project.ExtraProperties["VersionBranchPrefix"].ToString();
}
private GithubVersionProviderSource GetGithubVersionProviderSource(Project project)

@ -125,12 +125,13 @@ namespace Volo.Docs.Projects
private string GetProjectVersionPrefixIfExist(Project project)
{
if (GetGithubVersionProviderSource(project) == GithubVersionProviderSource.Branches)
if (GetGithubVersionProviderSource(project) != GithubVersionProviderSource.Branches)
{
return project.ExtraProperties["VersionBranchPrefix"].ToString();
return string.Empty;
}
return "";
return project.ExtraProperties["VersionBranchPrefix"].ToString();
}
private GithubVersionProviderSource GetGithubVersionProviderSource(Project project)

Loading…
Cancel
Save