NFC azonosítás is kész
This commit is contained in:
@@ -15,11 +15,39 @@
|
||||
<form method="post" id="RoleForm">
|
||||
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
||||
<input type="hidden" asp-for="RoleDTO.Id" />
|
||||
<div class="col-md-3">
|
||||
<label asp-for="RoleDTO.ParentId"></label>
|
||||
<select asp-for="RoleDTO.ParentId" class="form-control" asp-items="Model.Parents"></select>
|
||||
<span asp-validation-for="RoleDTO.ParentId" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label asp-for="RoleDTO.RoleName"></label>
|
||||
<input asp-for="RoleDTO.RoleName" class="form-control" />
|
||||
<span asp-validation-for="RoleDTO.RoleName" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="mb-3">
|
||||
<label asp-for="RoleDTO.IsAdmin"></label>
|
||||
<input type="checkbox" asp-for="RoleDTO.IsAdmin" class="form-check-input" />
|
||||
<span asp-validation-for="RoleDTO.IsAdmin" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="mb-3">
|
||||
<label asp-for="RoleDTO.CanDownloadAPK"></label>
|
||||
<input type="checkbox" asp-for="RoleDTO.CanDownloadAPK" class="form-check-input" />
|
||||
<span asp-validation-for="RoleDTO.CanDownloadAPK" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="mb-3">
|
||||
<label asp-for="RoleDTO.CanEnableBlocked"></label>
|
||||
<input type="checkbox" asp-for="RoleDTO.CanEnableBlocked" class="form-check-input" />
|
||||
<span asp-validation-for="RoleDTO.CanEnableBlocked" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 d-flex justify-content-between">
|
||||
<button type="button" id="saveRole" class="btn btn-primary">Mentés</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button>
|
||||
@@ -34,47 +62,13 @@
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
var formData = getFormAsNestedObject('#RoleForm');
|
||||
const $form = $('#RoleForm');
|
||||
|
||||
|
||||
formData.RoleDTO.IsAdmin = $('#RoleForm input[name="RoleDTO.IsAdmin"]').is(':checked');
|
||||
formData.RoleDTO.CanDownloadAPK = $('#RoleForm input[name="RoleDTO.CanDownloadAPK"]').is(':checked');
|
||||
formData.RoleDTO.CanEnableBlocked = $('#RoleForm input[name="RoleDTO.CanEnableBlocked"]').is(':checked');
|
||||
|
||||
if ($form.valid())
|
||||
{
|
||||
$.ajax({
|
||||
url: $('#RoleEditPostUrl').val(),
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(formData.RoleDTO),
|
||||
success: function (response) {
|
||||
if (response.success)
|
||||
{
|
||||
showMessageModal({
|
||||
title: 'Figyelmem!',
|
||||
message: 'Sikeres mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
showMessageModal({
|
||||
title: 'Figyelmem, HIBA!',
|
||||
message: 'Sikertelen mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
// Hiba esetén
|
||||
console.error("Hiba: ", error);
|
||||
showMessageModal({
|
||||
title: 'Hiba!',
|
||||
message: 'A mentés NEM sikerült!',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
});
|
||||
saveEntity(csrfToken, formData.RoleDTO, $('#RoleEditPostUrl').val());
|
||||
} else
|
||||
{
|
||||
$form[0].reportValidity();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Serilog;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
@@ -13,6 +15,9 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
|
||||
[BindProperty]
|
||||
public RoleDTO RoleDTO { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public List<SelectListItem> Parents { get; set; }
|
||||
|
||||
public RoleEditPageModel(ILogger<IndexModel> logger, IUserService userService)
|
||||
{
|
||||
@@ -22,6 +27,7 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
|
||||
public async Task OnGet(int id)
|
||||
{
|
||||
await InitSelectItems();
|
||||
RoleDTO = await _userService.GetRole(id);
|
||||
}
|
||||
public async Task<IActionResult> OnPostSave([FromBody] RoleDTO roleDTO)
|
||||
@@ -45,5 +51,15 @@ namespace WorkFlowCheck.Web.Pages.UserAndRole
|
||||
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
private async Task InitSelectItems()
|
||||
{
|
||||
var roles = await _userService.GetAllRoles();
|
||||
this.Parents = new List<SelectListItem>();
|
||||
Parents.Add(new SelectListItem() { Value = "-1", Text = "NINCS" });
|
||||
foreach (var role in roles)
|
||||
{
|
||||
Parents.Add(new SelectListItem() { Value = role.Id.ToString(), Text = role.RoleName });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,22 @@
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName("RoleName", typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.RoleName), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.ParentRoleName), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.IsAdmin), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanEnableBlocked), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanDownloadAPK), typeof(RoleDTO))</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName("RoleName", typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.RoleName), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.ParentRoleName), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.IsAdmin), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanEnableBlocked), typeof(RoleDTO))</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(RoleDTO.CanDownloadAPK), typeof(RoleDTO))</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@@ -43,6 +51,37 @@
|
||||
columns: [
|
||||
{ data: "id" },
|
||||
{ data: "roleName" },
|
||||
{ data: "parentRoleName" },
|
||||
{
|
||||
data: "isAdmin",
|
||||
searchable: false,
|
||||
sortable: false,
|
||||
className: "text-center",
|
||||
render: function ( data, type, row ) {
|
||||
return renderCheckBox(data);
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
data: "canEnableBlocked",
|
||||
searchable: false,
|
||||
sortable: false,
|
||||
className: "text-center",
|
||||
render: function ( data, type, row ) {
|
||||
return renderCheckBox(data);
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
data: "canDownloadAPK",
|
||||
searchable: false,
|
||||
sortable: false,
|
||||
className: "text-center",
|
||||
render: function ( data, type, row ) {
|
||||
return renderCheckBox(data);
|
||||
}
|
||||
|
||||
},
|
||||
{ data: null, render: function (data, type, row) {
|
||||
return renderActionButtons(row.id);
|
||||
}}
|
||||
@@ -53,7 +92,7 @@
|
||||
"visible": false
|
||||
},
|
||||
{
|
||||
"targets": 2,
|
||||
"targets": 6,
|
||||
"className": "text-center",
|
||||
"width": "10%"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user