Skip to content

Commit

Permalink
CMS template update (#139)
Browse files Browse the repository at this point in the history
* Features/upgrate to dotnet 6 (#108)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Features/fix email bugs (#110)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Features/fix email bugs (#112)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Feature/fix email send issues (#114)

* Removed development files

* Updated .gitignore

* Added MailKit library

* Implemented e-mail sender with MailKit

* Feature/minor changes (#116)

* Updated nuget packages

* Improved HtmlHelperExtensions logic and added possibility to use with slugs

* Added "About me" menu item

* Feature/code improvements (#117)

* Add possibility to use global.json

* Add global.json file with targeting SDK 6.0.403

* Removed warnings

* Add exclusion of generated code

* Exclude Identity pages from null check

* Update packages; Add ardalis.GuardClauses

* Remove warnings

* Remove null warnings; Minor code improvements

* Fixed post not being saved

* Fixed post not being saved

* Add filter to prevent articles to appear before publishing time

* Add filter to prevent articles to appear before publishing time

* Add about me and subscribe; Reorder menu

* Add Author partial view

* Change DateTime format

* Add SASS package

* Reduce padding; Add max-height of 100%

* Minor improvements (#118)

* Develop (#113)

* Features/upgrate to dotnet 6 (#108)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Features/fix email bugs (#110)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Features/fix email bugs (#112)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Bugfix for e-mail sending (#115)

* Features/upgrate to dotnet 6 (#108)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Features/fix email bugs (#110)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Features/fix email bugs (#112)

* Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere

* Removed old project folders/files

* Removed temporary old solution

* Refactored code; Set some members to nullable

* Changed usage on TryUpdateModelAsync

* Fixed e-mail issues

* Feature/fix email send issues (#114)

* Removed development files

* Updated .gitignore

* Added MailKit library

* Implemented e-mail sender with MailKit

* Feature/remove contact form (#120)

* Add empty connection strings

* Removed Contact form and references

* Redirected contact route to index

* Feature/fix merge issues (#121)

* Remove duplicate subscribe link

* Feature/optimizations (#123)

* Remove dotnet-tools

* Remove .config folder

* Set CmsEngine.Ui to run out of process

* Upgrade to .NET 7

* Code refactor

* Code refactor

* Make repository and services disposable

* Feature/upgrade to dotnet 8 (#124)

* .NET upgrade

* Code refactor

* Feature/GitHub actions (#126)

* Add github action

* Add develop branch to push/pull request; Remove tests

* Feature/GitHub actions (#127)

* Add github action

* Add develop branch to push/pull request; Remove tests

* Set SDK to 8.0.302

* Github actions configuration (#128)

* Add github action

* Add develop branch to push/pull request; Remove tests

* Set SDK to 8.0.302

* Change action trigger to feature/**

* Library update

* Add build status to readme.md

* Update readme.md (#131)

* Upgrade libraries (#134)

* Dev certificate password; Layout changes (#136)

* CMS theme update (#137)

* Migration of layout files

* Add _DataTableCardHeader

* Replaced some icons; Fixed paths

* Add new assets; Moved old assets around

* Add custom CSS

* Update packages

* Update JS for updated packages

* Update Views / Helpers to match new theme

* Moving admin.css

* Feature/minor changes (#138)

* Minor style changes

* Add Count method in the Repository and Services

* Add counter in the dashboard

* Removed menu items; Add "not implemented" message

* Fix for image paths and files not being copied on build
  • Loading branch information
davidsonsousa authored Aug 15, 2024
1 parent c03fd21 commit 1ba8ebc
Show file tree
Hide file tree
Showing 1,400 changed files with 24,602 additions and 4,311 deletions.
4 changes: 2 additions & 2 deletions src/CmsEngine.Application/Helpers/DataTableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ private static string PrepareProperty(IViewModel item, PropertyInfo property)
break;
}

return $"<span class=\"badge badge-{generalStatus.ToString().ToLowerInvariant()}\">{documentStatus.ToEnum<DocumentStatus>().GetName()}</status-label>";
return $"<span class=\"badge text-bg-{generalStatus.ToString().ToLowerInvariant()}\">{documentStatus.ToEnum<DocumentStatus>().GetName()}</status-label>";
case "UserViewModel":
var author = (UserViewModel)value;
return HtmlEncoder.Default.Encode(author?.FullName ?? string.Empty);
case "Boolean":
generalStatus = (bool)value ? GeneralStatus.Success : GeneralStatus.Danger;
return $"<span class=\"badge badge-{generalStatus.ToString().ToLowerInvariant()}\">{((bool)value).ToYesNo().ToUpper()}</status-label>";
return $"<span class=\"badge text-bg-{generalStatus.ToString().ToLowerInvariant()}\">{((bool)value).ToYesNo().ToUpper()}</status-label>";
default:
return HtmlEncoder.Default.Encode(value?.ToString() ?? string.Empty);
}
Expand Down
12 changes: 12 additions & 0 deletions src/CmsEngine.Application/Models/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CmsEngine.Application.Models.ViewModels;

public class HomeViewModel
{
public int PostCount { get; set; }

public int PageCount { get; set; }

public int CategoryCount { get; set; }

public int TagCount { get; set; }
}
8 changes: 8 additions & 0 deletions src/CmsEngine.Application/Services/CategoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public IEnumerable<Category> FilterForDataTable(string searchValue, IEnumerable<
return items;
}

public async Task<int> GetCategoryCount()
{
logger.LogDebug("CategoryService > GetCategoryCount()");
var items = await unitOfWork.Categories.CountAsync();
logger.LogDebug("Category count: {0}", items);
return items;
}

public async Task<IEnumerable<CategoryViewModel>> GetCategoriesWithPost()
{
logger.LogDebug("CategoryService > GetCategoriesWithPost()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface ICategoryService : IDataTableService<Category>, IDisposable
Task<ReturnValue> DeleteRange(Guid[] ids);
Task<(IEnumerable<CategoryTableViewModel> Data, int RecordsTotal, int RecordsFiltered)> GetForDataTable(DataParameters parameters);
Task<ReturnValue> Save(CategoryEditModel categoryEditModel);
Task<int> GetCategoryCount();
Task<IEnumerable<CategoryViewModel>> GetCategoriesWithPostCount();
Task<IEnumerable<CategoryViewModel>> GetCategoriesWithPost();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public interface IPageService : IDataTableService<Page>, IDisposable
Task<(IEnumerable<PageTableViewModel> Data, int RecordsTotal, int RecordsFiltered)> GetForDataTable(DataParameters parameters);
Task<ReturnValue> Save(PageEditModel pageEditModel);
Task<PageViewModel> GetBySlug(string slug);
Task<int> GetPageCount();
Task<IEnumerable<PageViewModel>> GetAllPublished();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IPostService : IDataTableService<Post>, IDisposable
Task<ReturnValue> Save(PostEditModel postEditModel);
Task<IEnumerable<PostEditModel>> GetPublishedOrderedByDate(int count = 0);
Task<PostViewModel> GetBySlug(string slug);
Task<int> GetPostCount();
Task<PaginatedList<PostViewModel>> GetPublishedByCategoryForPagination(string categorySlug, int page = 1);
Task<PaginatedList<PostViewModel>> GetPublishedByTagForPagination(string tagSlug, int page = 1);
Task<PaginatedList<PostViewModel>> GetPublishedForPagination(int page = 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public interface ITagService : IDataTableService<Tag>, IDisposable
Task<ReturnValue> DeleteRange(Guid[] ids);
Task<(IEnumerable<TagTableViewModel> Data, int RecordsTotal, int RecordsFiltered)> GetForDataTable(DataParameters parameters);
Task<ReturnValue> Save(TagEditModel tagEditModel);
Task<int> GetTagCount();
Task<IEnumerable<TagViewModel>> GetAllTags();
}
8 changes: 8 additions & 0 deletions src/CmsEngine.Application/Services/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public IEnumerable<Page> FilterForDataTable(string searchValue, IEnumerable<Page
return items;
}

public async Task<int> GetPageCount()
{
logger.LogDebug("PageService > GetPageCount()");
var items = await unitOfWork.Pages.CountAsync();
logger.LogDebug("Page count: {0}", items);
return items;
}

public async Task<IEnumerable<PageViewModel>> GetAllPublished()
{
logger.LogDebug("PageService > GetPagesByStatusReadOnly()");
Expand Down
8 changes: 8 additions & 0 deletions src/CmsEngine.Application/Services/PostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public IEnumerable<Post> FilterForDataTable(string searchValue, IEnumerable<Post
return items;
}

public async Task<int> GetPostCount()
{
logger.LogDebug("PostService > GetPostCount()");
var items = await unitOfWork.Posts.CountAsync();
logger.LogDebug("Post count: {0}", items);
return items;
}

public async Task<PostViewModel> GetBySlug(string slug)
{
logger.LogDebug("PostService > GetBySlug({slug})", slug);
Expand Down
8 changes: 8 additions & 0 deletions src/CmsEngine.Application/Services/TagService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public IEnumerable<Tag> FilterForDataTable(string searchValue, IEnumerable<Tag>
return (items.MapToTableViewModel(), recordsTotal, items.Count());
}

public async Task<int> GetTagCount()
{
logger.LogDebug("TagService > GetTagCount()");
var items = await unitOfWork.Tags.CountAsync();
logger.LogDebug("Tag count: {0}", items);
return items;
}

public async Task<IEnumerable<TagViewModel>> GetAllTags()
{
logger.LogDebug("TagService > GetAllTags()");
Expand Down
6 changes: 6 additions & 0 deletions src/CmsEngine.Data/Repositories/Interfaces/IReadRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ namespace CmsEngine.Data.Repositories.Interfaces;

public interface IReadRepository<TEntity> where TEntity : class
{
/// <summary>
/// Count valid items
/// </summary>
/// <returns></returns>
public Task<int> CountAsync();

/// <summary>
/// Get all records which were not marked as deleted (IsDeleted == false)
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/CmsEngine.Data/Repositories/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public Repository(CmsEngineContext context)
dbContext = context;
}

public async Task<int> CountAsync()
{
return await Get().CountAsync();
}

public async Task<IEnumerable<TEntity>> GetAllAsync()
{
return await GetValidRecords().ToListAsync();
Expand Down
25 changes: 21 additions & 4 deletions src/CmsEngine.Ui/Areas/Cms/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@ namespace CmsEngine.Ui.Areas.Cms.Controllers;
[Area("Cms")]
public class HomeController : BaseController
{
private readonly IEmailService _emailService;
private readonly ICategoryService _categoryService;
private readonly IPageService _pageService;
private readonly IPostService _postService;
private readonly ITagService _tagService;

public HomeController(ILoggerFactory loggerFactory, IService service, IEmailService emailService)
public HomeController(ILoggerFactory loggerFactory, IService service, ICategoryService categoryService,
IPageService pageService, IPostService postService, ITagService tagService)
: base(loggerFactory, service)
{
_emailService = emailService;
_categoryService = categoryService;
_pageService = pageService;
_postService = postService;
_tagService = tagService;

}

public async Task<IActionResult> IndexAsync()
{
SetupMessages("Dashboard");
return View(await _emailService.GetOrderedByDate());

var homeViewModel = new HomeViewModel
{
CategoryCount = await _categoryService.GetCategoryCount(),
PageCount = await _pageService.GetPageCount(),
PostCount = await _postService.GetPostCount(),
TagCount = await _tagService.GetTagCount()
};

return View(homeViewModel);
}
}
10 changes: 5 additions & 5 deletions src/CmsEngine.Ui/Areas/Cms/Views/Category/CreateEdit.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@model CategoryEditModel

@section Breadcrumb {
<ol class="breadcrumb">
<ol class="breadcrumb my-0">
<li class="breadcrumb-item"><a href="~/cms">Dashboard</a></li>
<li class="breadcrumb-item"><a href="~/cms/category">@ViewBag.PageTitle</a></li>
<li class="breadcrumb-item active">@ViewBag.PageType</li>
Expand All @@ -21,22 +21,22 @@
<input asp-for="Id" type="hidden" />
}

<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Name"></label>
<input asp-for="Name" class="form-control slugify" />
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Slug"></label>
<input asp-for="Slug" class="form-control slug" />
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Description"></label>
<textarea asp-for="Description" class="form-control"></textarea>
</div>
<div asp-validation-summary="All" class="text-danger"></div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary"><i class="far fa-dot-circle"></i> Save</button>
<button type="submit" class="btn btn-primary"><i class="cil-save"></i> Save</button>
</div>
</form>
</div>
Expand Down
19 changes: 4 additions & 15 deletions src/CmsEngine.Ui/Areas/Cms/Views/Category/List.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,16 @@
}

@section Breadcrumb {
<ol class="breadcrumb">
<ol class="breadcrumb my-0">
<li class="breadcrumb-item"><a href="~/cms">Dashboard</a></li>
<li class="breadcrumb-item active">@ViewBag.PageTitle</li>
</ol>
}

<div class="card">
<div class="card-header">
<i class="fa fa-align-justify"></i>
@ViewBag.PanelTitle
<div class="btn-toolbar float-right" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group" role="group" aria-label="Actions">
<a asp-action="create" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Create a new item">
<span class="fas fa-plus"></span>
</a>
<a asp-action="bulkdelete" class="btn btn-danger" id="bulk-delete" data-toggle="tooltip" data-placement="top" title="Select the items you want to delete" disabled="disabled">
<span class="far fa-trash-alt"></span>
</a>
</div>
</div>
</div>
@{
await Html.RenderPartialAsync("_DataTableCardHeader");
}
<div class="card-body">
<table id="table-list" class="table table-striped table-bordered">
<thead>
Expand Down
41 changes: 18 additions & 23 deletions src/CmsEngine.Ui/Areas/Cms/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@model IEnumerable<CmsEngine.Application.Helpers.Email.ContactForm>
@model HomeViewModel
@section Breadcrumb {
<ol class="breadcrumb">
<ol class="breadcrumb my-0">
<li class="breadcrumb-item active">@ViewBag.PageTitle</li>
</ol>
}
Expand All @@ -9,32 +9,27 @@
<div class="col-sm-4 col-md-3">
<div class="card">
<div class="card-header">
<i class="fa fa-info"></i> Information
<i class="cil-info"></i> Information
</div>
<div class="card-body">
<ul>
<li>
.NET version: @Environment.Version.ToString()
<ul class="list-group list-group-flush">
<li class="list-group-item">
<strong>.NET version: </strong>@Environment.Version.ToString()
</li>
<li class="list-group-item">
<strong>Posts: </strong> @Model.PostCount
</li>
<li class="list-group-item">
<strong>Pages: </strong> @Model.PageCount
</li>
<li class="list-group-item">
<strong>Categories: </strong> @Model.CategoryCount
</li>
<li class="list-group-item">
<strong>Tags: </strong> @Model.TagCount
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-8 col-md-9">
<div class="card">
<div class="card-header">
<i class="icon-envelope-letter"></i> E-mails
</div>
<div class="card-body">
@foreach (var item in Model)
{
<ul>
<li>From: @item.From</li>
<li>Subject: @item.Subject</li>
<li>Message: @item.Message</li>
</ul>
}
</div>
</div>
</div>
</div>
26 changes: 13 additions & 13 deletions src/CmsEngine.Ui/Areas/Cms/Views/Page/CreateEdit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}

@section Breadcrumb {
<ol class="breadcrumb">
<ol class="breadcrumb my-0">
<li class="breadcrumb-item"><a href="~/cms">Dashboard</a></li>
<li class="breadcrumb-item"><a href="~/cms/page">@ViewBag.PageTitle</a></li>
<li class="breadcrumb-item active">@ViewBag.PageType</li>
Expand All @@ -29,36 +29,36 @@

<div class="row">
<div class="col">
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Title"></label>
<input asp-for="Title" class="form-control slugify" />
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Slug"></label>
<input asp-for="Slug" class="form-control slug" />
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Description"></label>
<input asp-for="Description" class="form-control" />
</div>
<div class="form-group">
<div class="form-group mb-3">
<textarea asp-for="DocumentContent" class="form-control"></textarea>
<div class="upload-bar float-right">
<span class="btn btn-success fileinput-button">
<i class="fas fa-upload"></i>
<i class="cil-data-transfer-up"></i>
<span>Upload images</span>
<input id="uploadEditorImages" type="file" name="editorImage" multiple>
</span>
<span class="btn btn-success fileinput-button">
<i class="fas fa-upload"></i>
<i class="cil-data-transfer-up"></i>
<span>Upload files</span>
<input id="uploadEditorFiles" type="file" name="editorFile" multiple>
</span>
</div>
</div>
</div>
<div class="col-xl-2">
<div class="form-group">
<div class="form-group mb-3">
<h5>Header preview</h5>
<div class="header-preview">
@if (!string.IsNullOrWhiteSpace(Model.HeaderImage))
Expand All @@ -70,20 +70,20 @@

<div class="upload-bar">
<span class="btn btn-success fileinput-button">
<i class="fas fa-upload"></i> Upload
<i class="cil-data-transfer-up"></i> Upload
<input id="uploadHeadImage" type="file" name="files">
</span>
<button class="btn btn-outline-danger" id="removeHeadImage"><i class="fas fa-trash-alt"></i> Remove</button>
<button class="btn btn-outline-danger" id="removeHeadImage"><i class="cil-trash"></i> Remove</button>
<div id="progress">
<div class="progress-bar" style="width: 0%;"></div>
</div>
</div>
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="Status"></label>
<select asp-for="Status" asp-items="Html.GetEnumSelectList<DocumentStatus>()" class="form-control"></select>
</div>
<div class="form-group">
<div class="form-group mb-3">
<label asp-for="PublishedOn"></label>
@Html.EditorFor(m => m.PublishedOn, new { htmlAttributes = new { @class = "form-control", containerId = "published-on" } })
</div>
Expand All @@ -92,7 +92,7 @@
<div asp-validation-summary="All" class="text-danger"></div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary"><i class="far fa-dot-circle"></i> Save</button>
<button type="submit" class="btn btn-primary"><i class="cil-save"></i> Save</button>
</div>
</form>
</div>
Expand Down
Loading

0 comments on commit 1ba8ebc

Please sign in to comment.