Browse Source

waiting comments page was made

pull/19919/head
EmreKendirli 2 years ago
parent
commit
f3db34d5a5
  1. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs
  2. 37
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs
  3. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs
  4. 18
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/Index.cshtml
  5. 35
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/index.js
  6. 13
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  7. 9
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js

3
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs

@ -18,5 +18,8 @@ public interface ICommentAdminAppService : IApplicationService
Task<SettingsDto> GetSettings();
Task<int> GetPendingCommentCount();
Task<PagedResultDto<CommentWithAuthorDto>> GetWaitingCommentsWithRepliesAsync(CommentGetListInput input);
}

37
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs

@ -118,4 +118,41 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
return (int)(count == null ? 0 : count);
}
public async Task<PagedResultDto<CommentWithAuthorDto>> GetWaitingCommentsWithRepliesAsync(CommentGetListInput input)
{
var totalCount = await CommentRepository.GetCountAsync(
input.Text,
input.EntityType,
input.RepliedCommentId,
input.Author,
input.CreationStartDate,
input.CreationEndDate,
"null"
);
var comments = await CommentRepository.GetListAsync(
input.Text,
input.EntityType,
input.RepliedCommentId,
input.Author,
input.CreationStartDate,
input.CreationEndDate,
input.Sorting,
input.MaxResultCount,
input.SkipCount,
"null"
);
var dtos = comments.Select(queryResultItem =>
{
var dto = ObjectMapper.Map<Comment, CommentWithAuthorDto>(queryResultItem.Comment);
dto.Author = ObjectMapper.Map<CmsUser, CmsUserDto>(queryResultItem.Author);
return dto;
}).ToList();
return new PagedResultDto<CommentWithAuthorDto>(totalCount, dtos);
}
}

10
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs

@ -71,9 +71,17 @@ public class CommentAdminController : CmsKitAdminController, ICommentAdminAppSer
return CommentAdminAppService.GetSettings();
}
[HttpGet]
[Route("pending-count")]
[Route("waiting-count")]
public Task<int> GetPendingCommentCount()
{
return CommentAdminAppService.GetPendingCommentCount();
}
[HttpGet]
[Route("waiting")]
public Task<PagedResultDto<CommentWithAuthorDto>> GetWaitingCommentsWithRepliesAsync(CommentGetListInput input)
{
return CommentAdminAppService.GetWaitingCommentsWithRepliesAsync(input);
}
}

18
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/Index.cshtml

@ -27,12 +27,11 @@
<abp-script-bundle>
<abp-script src="/client-proxies/cms-kit-common-proxy.js" />
<abp-script src="/client-proxies/cms-kit-admin-proxy.js" />
<abp-script src="/Pages/CmsKit/Comments/index.js" />
<abp-script src="/Pages/CmsKit/Comments/Waiting/index.js" />
</abp-script-bundle>
}
<abp-alert id="commentsAlert" alert-type="Warning" style="display: none;">
</abp-alert>
<abp-card class="mb-4">
<abp-card-body>
@ -50,22 +49,15 @@
</abp-row>
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<abp-column size-lg="_3" size-md="_6">
<abp-input asp-for="@Model.Author" label="@L["Username"].Value" type="text" />
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<abp-column size-lg="_3" size-md="_6">
<abp-input asp-for="@Model.EntityType" label="@L["EntityType"].Value" type="text" />
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<select asp-for="@Model.IsApproved" label="@L["IsApproved"].Value">
<option value="">@L["All"].Value</option>
<option value="true">@L["Approved"].Value</option>
<option value="false">@L["Rejected"].Value</option>
<option value="null">@L["Pending"].Value</option>
</select>
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<abp-button class="w-100 mb-3" button-type="Primary" type="submit">

35
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Waiting/index.js

@ -57,7 +57,7 @@
scrollX: true,
searching: false,
scrollCollapse: true,
ajax: abp.libs.datatables.createAjax(commentsService.getList, getFilter),
ajax: abp.libs.datatables.createAjax(commentsService.getWaitingCommentsWithReplies, getFilter),
columnDefs: [
{
width: "10%",
@ -173,28 +173,6 @@
data: "creationTime",
orderable: true,
dataFormat: "datetime"
},
{
width: "5%",
title: l("Status"),
orderable: false,
data: "isApproved",
render: function (data, type, row) {
var icons = ''
if (data === null) {
icons = '<i class="fa-solid fa-hourglass-start"></i>';
} else if (typeof data === "boolean") {
if (data) {
icons = '<i class="fa-solid fa-check" style="color: #63E6BE;"></i>';
} else {
icons = '<i class="fa-solid fa-x" style="color: #e0102f;"></i>';
}
}
return icons;
}
}
]
}));
@ -216,15 +194,4 @@
e.preventDefault();
_dataTable.ajax.reloadEx();
});
// Get and display pending comment count
commentsService.getPendingCommentCount().then(function (count) {
console.log(count)
if (count > 0) {
var alertMessage = 'You have pending comments: ' + count;
var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>';
console.log(count)
$('#commentsAlert').html(alertElement);
$('#commentsAlert').show()
}
});
});

13
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js

@ -222,9 +222,20 @@ $(function (){
if (count > 0) {
var alertMessage = 'You have pending comments: ' + count;
var alertElement = '<abp-alert alert-type="Warning">' + alertMessage + '</abp-alert>';
console.log(count)
$('#commentsAlert').html(alertElement);
$('#commentsAlert').show()
$('#commentsAlert').click(function () {
window.location.href = '/Cms/Comments/Waiting'
});
}
});
//
commentsService.getSettings().then(function (data) {
if (data.requireApprovement) {
$('#CommentsTable').DataTable().column(6).visible(true);
} else {
$('#CommentsTable').DataTable().column(6).visible(false);
}
})
});

9
modules/cms-kit/src/Volo.CmsKit.Admin.Web/wwwroot/client-proxies/cms-kit-admin-proxy.js

@ -223,7 +223,14 @@
volo.cmsKit.admin.comments.commentAdmin.getPendingCommentCount = function(ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/pending-count',
url: abp.appPath + 'api/cms-kit-admin/comments/waiting-count',
type: 'GET'
}, ajaxParams));
};
volo.cmsKit.admin.comments.commentAdmin.getWaitingCommentsWithReplies = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/cms-kit-admin/comments/waiting' + abp.utils.buildQueryString([{ name: 'entityType', value: input.entityType }, { name: 'text', value: input.text }, { name: 'repliedCommentId', value: input.repliedCommentId }, { name: 'author', value: input.author }, { name: 'creationStartDate', value: input.creationStartDate }, { name: 'creationEndDate', value: input.creationEndDate }, { name: 'isApproved', value: input.isApproved }, { name: 'sorting', value: input.sorting }, { name: 'skipCount', value: input.skipCount }, { name: 'maxResultCount', value: input.maxResultCount }]) + '',
type: 'GET'
}, ajaxParams));
};

Loading…
Cancel
Save