UserRole is benn van, de még nem tökéletes.

This commit is contained in:
2025-03-18 13:56:35 +01:00
parent 9297ff3970
commit 2fd147bb36
7 changed files with 302 additions and 10 deletions
@@ -1,4 +1,93 @@
@page
@model WorkFlowCheck.Web.Pages.UserAndRole.UserRolePageModel
@{
ViewData["Title"] = "Felhasználók - szabályok";
}
<h1>@ViewData["Title"]</h1>
<div class="card shadow p-4">
<div class="d-flex justify-content-end">
<button id="newUserRoleBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új kapcsolat">
<i class="bi bi-plus-square"></i>
</button>
</div>
<table id="tbUserRolesPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>User Name</th>
<th>Role Name</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>User Name</th>
<th>Role Name</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
const table = new DataTable('#tbUserRolesPage', {
ajax: {
url: "@Url.Page("./UserRolePage", "LoadUserRoles")",
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "userDTO.userName" },
{ data: "roleDTO.roleName" },
{ data: null, render: function (data, type, row) {
return renderActionButtons(row.id);
}}
],
columnDefs: [
{
"targets": 0,
"visible": false
},
{
"targets": 3,
"className": "text-center",
"width": "10%"
}
],
processing:true
});
$('#newUserRoleBtn').on('click', function ()
{
console.log('New button clicked!"');
window.location.href = `@Url.Page("./UserRoleEditPage")?id=0`;
});
$('#tbUserRolesPage').on('click', '.edit-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("./UserRoleEditPage")?id=${row.id}`;
});
$('#tbUserRolesPage').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>
}
@@ -1,12 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.UserAndRole
{
public class UserRolePageModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly IUserService _userService;
public UserRolePageModel(ILogger<IndexModel> logger, IUserService userService)
{
_logger = logger;
_userService = userService;
}
public void OnGet()
{
}
public async Task<JsonResult> OnGetLoadUserRoles()
{
var results = await _userService.GetAllUserRoles();
return new JsonResult(new { data = results });
}
}
}