RoleCheckPoint
This commit is contained in:
+3
-1
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
@@ -12,7 +13,7 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
|
||||
[BindProperty]
|
||||
public CheckListHeaderDTO CheckListHeaderDTO { get; set; }
|
||||
|
||||
public List<SelectListItem> CheckStatus { get; set; }
|
||||
|
||||
public CheckListHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService)
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
CheckListHeaderDTO = await _checkListService.GetCheckListHeader(id);
|
||||
CheckStatus = _checkListService.GetCheckStatus();
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadCheckListRows(int id)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@page
|
||||
@model WorkFlowCheck.Web.Pages.CheckList.CheckListHeader.CheckListHeaderPageModel
|
||||
@{
|
||||
ViewData["Title"] = "Ellenőrzési sablonok";
|
||||
ViewData["Title"] = "Ellenőrzések";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
@@ -8,6 +12,9 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly ICheckListService _checkListService;
|
||||
|
||||
public List<SelectListItem> CheckStatus { get; set; }
|
||||
|
||||
public CheckListHeaderPageModel(ILogger<IndexModel> logger, ICheckListService checkListService)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -15,7 +22,10 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
}
|
||||
public async Task OnGet()
|
||||
{
|
||||
CheckStatus = _checkListService.GetCheckStatus();
|
||||
}
|
||||
|
||||
|
||||
public async Task<JsonResult> OnGetLoadCheckListHeaders()
|
||||
{
|
||||
var results = await _checkListService.GetAllCheckListHeaderAsync();
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery-validation-unobtrusive@4.0.0/dist/jquery.validate.unobtrusive.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
@* <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> *@
|
||||
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
<partial name="_ValidationScriptsPartial" />
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
@page
|
||||
@model WorkFlowCheck.Web.Pages.UserAndRole.RoleCheckPointsPageModel
|
||||
@{
|
||||
ViewData["Title"] = "Szabályok - Ellenőrzési sablonok";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<div class="card shadow p-4">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button id="newRoleCheckPointsBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új felhasználó">
|
||||
<i class="bi bi-plus-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table id="tbRoleCheckPointsPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Role name</th>
|
||||
<th>Checkpoint name</th>
|
||||
<th>Enabled</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Role name</th>
|
||||
<th>Checkpoint name</th>
|
||||
<th>Enabled</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
const table = new DataTable('#tbRoleCheckPointsPage', {
|
||||
ajax: {
|
||||
url: "@Url.Page("./RoleCheckPointsPage", "LoadRoleCheckPoints")",
|
||||
type: "GET",
|
||||
dataSrc : "data"
|
||||
},
|
||||
columns: [
|
||||
{ data: "id" },
|
||||
{ data: "roleDTO.roleName" },
|
||||
{ data: "CheckPointDTO.description" },
|
||||
{
|
||||
data: "enabled",
|
||||
searchable: false,
|
||||
sortable: false,
|
||||
className: "text-center",
|
||||
render: function ( data, type, row ) {
|
||||
if (data === true) {
|
||||
return '<input type="checkbox" class="editor-active" disabled checked>';
|
||||
}
|
||||
if (data === false) {
|
||||
return '<input type="checkbox" class="editor-active" disabled>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
},
|
||||
{ data: null, render: function (data, type, row) {
|
||||
return renderActionButtons(row.id);
|
||||
}}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
"targets": 0,
|
||||
"visible": false
|
||||
},
|
||||
{
|
||||
"targets": 4,
|
||||
"className": "text-center",
|
||||
"width": "10%"
|
||||
}
|
||||
],
|
||||
|
||||
processing:true,
|
||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||
});
|
||||
|
||||
$('#newRoleCheckPointsBtn').on('click', function ()
|
||||
{
|
||||
console.log('New button clicked!"');
|
||||
window.location.href = `@Url.Page("./RoleCheckPointEditPage")?id=0`;
|
||||
});
|
||||
|
||||
$('#tbRoleCheckPointsPage').on('click', '.edit-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
window.location.href = `@Url.Page("./RoleCheckPointEditPage")?id=${row.id}`;
|
||||
});
|
||||
|
||||
$('#tbRoleCheckPointsPage').on('click', '.delete-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
console.log(row);
|
||||
showConfirmModal({
|
||||
title: 'Törlés megerősítése',
|
||||
message: 'Biztosan törölni szeretnéd ezt az elemet?',
|
||||
okText: 'Törlés',
|
||||
cancelText: 'Mégsem'
|
||||
}).then(function(result) {
|
||||
if(result === 'ok') {
|
||||
console.log('Törlés végrehajtva');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
{
|
||||
public class RoleCheckPointsPageModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IUserService _userService;
|
||||
public RoleCheckPointsPageModel(ILogger<IndexModel> logger, IUserService userService)
|
||||
{
|
||||
_logger = logger;
|
||||
_userService = userService;
|
||||
}
|
||||
public async Task OnGet()
|
||||
{
|
||||
}
|
||||
public async Task<JsonResult> OnGetLoadRoleCheckPoints()
|
||||
{
|
||||
var results = await _userService.GetAllRoleCheckListTemplates();
|
||||
return new JsonResult(new { data = results });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Services
|
||||
@@ -200,6 +204,24 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public List<SelectListItem> GetCheckStatus()
|
||||
{
|
||||
return Enum.GetValues(typeof(CheckStatus))
|
||||
.Cast<CheckStatus>()
|
||||
.Select(e => new SelectListItem
|
||||
{
|
||||
Value = ((int)e).ToString(),
|
||||
Text = GetEnumDisplayName(e)
|
||||
}).ToList();
|
||||
}
|
||||
private string GetEnumDisplayName(Enum enumValue)
|
||||
{
|
||||
return enumValue.GetType()
|
||||
.GetMember(enumValue.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DisplayAttribute>()?.Name ?? enumValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
{
|
||||
@@ -18,5 +19,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<CheckListRowDTO> GetCheckListRow(int id);
|
||||
Task<ApiResponseDTO<CheckListRowDTO>> UpdateCheckListRow(CheckListRowDTO checkListRowDTO);
|
||||
|
||||
List<SelectListItem> GetCheckStatus();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<RoleCheckListTemplateHeaderDTO> GetRoleCheckListTemplateHeader(int id);
|
||||
Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplates();
|
||||
Task<ApiResponseDTO<RoleCheckListTemplateHeaderDTO>> UpdateRoleCheckListTemplateHeader(RoleCheckListTemplateHeaderDTO roleCheckListTemplateHeaderDTO);
|
||||
|
||||
Task<RoleCheckPointDTO> GetRoleCheckPoint(int id);
|
||||
Task<List<RoleCheckPointDTO>> GetAllRoleCheckPoints();
|
||||
Task<ApiResponseDTO<RoleCheckPointDTO>> UpdateRoleCheckPoint(RoleCheckPointDTO roleCheckPointDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,5 +335,76 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<RoleCheckPointDTO> GetRoleCheckPoint(int id)
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/user/GetRoleCheckPoint/{id}";
|
||||
var retVal = new RoleCheckPointDTO();
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<RoleCheckPointDTO>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleCheckPointDTO>> GetAllRoleCheckPoints()
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/GetAllRoleCheckPoints";
|
||||
var retVal = new List<RoleCheckPointDTO>();
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<RoleCheckPointDTO>>>(endpoint);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
return response.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<ApiResponseDTO<RoleCheckPointDTO>> UpdateRoleCheckPoint(RoleCheckPointDTO roleCheckPointDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/user/UpdateRoleCheckPoint";
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, roleCheckPointDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<RoleCheckPointDTO>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<RoleCheckPointDTO>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<RoleCheckPointDTO>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user