RolesPermissions
TsgcHTMLComponent_RolesPermissions — matryca ról / uprawnień z polem wyboru dla każdej komórki, grupowaniem według kategorii i aktualizacjami nadań na żywo przez WebSocket, w Delphi, C++ Builder i .NET.
TsgcHTMLComponent_RolesPermissions — matryca ról / uprawnień z polem wyboru dla każdej komórki, grupowaniem według kategorii i aktualizacjami nadań na żywo przez WebSocket, w Delphi, C++ Builder i .NET.
Dodaj role i uprawnienia, ustaw początkowe nadania, a następnie odczytaj właściwość HTML. Każde przełączenie pola wyboru jest wysyłane do serwera, który musi je autoryzować przed zastosowaniem.
TsgcHTMLComponent_RolesPermissions
Matryca tabelaryczna Bootstrap 5 + wbudowany skrypt
Delphi, C++ Builder, .NET
Wywołaj AddRole i AddPermission, aby zbudować osie matrycy, SetGrant dla początkowych zaznaczeń, a następnie odczytaj HTML.
uses
sgcHTML_Enums, sgcHTML_Component_RolesPermissions;
var
oMatrix: TsgcHTMLComponent_RolesPermissions;
begin
oMatrix := TsgcHTMLComponent_RolesPermissions.Create(nil);
try
oMatrix.MatrixID := 'acl';
oMatrix.StickyHeader := True;
oMatrix.AddRole('admin', 'Administrator').Color := hcDanger;
oMatrix.AddRole('editor', 'Editor');
oMatrix.AddRole('viewer', 'Viewer');
oMatrix.AddPermission('users.edit', 'Edit users', 'Users');
oMatrix.AddPermission('users.delete', 'Delete users', 'Users');
oMatrix.AddPermission('billing.view', 'View invoices', 'Billing');
oMatrix.SetGrant('admin', 'users.edit', True);
oMatrix.SetGrant('admin', 'users.delete', True);
oMatrix.SetGrant('editor', 'users.edit', True);
WebModule.Response := oMatrix.HTML; // matrix table + inline script
finally
oMatrix.Free;
end;
end;
// Server-side handler for a checkbox toggle received over WebSockets.
// ALWAYS verify the acting user is authorized before applying the change:
oMatrix.ProcessGrantChanged('editor', 'users.delete', True);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_RolesPermissions.hpp
TsgcHTMLComponent_RolesPermissions *oMatrix = new TsgcHTMLComponent_RolesPermissions(NULL);
try
{
oMatrix->MatrixID = "acl";
oMatrix->StickyHeader = true;
oMatrix->AddRole("admin", "Administrator")->Color = hcDanger;
oMatrix->AddRole("editor", "Editor");
oMatrix->AddRole("viewer", "Viewer");
oMatrix->AddPermission("users.edit", "Edit users", "Users");
oMatrix->AddPermission("users.delete", "Delete users", "Users");
oMatrix->AddPermission("billing.view", "View invoices", "Billing");
oMatrix->SetGrant("admin", "users.edit", true);
oMatrix->SetGrant("admin", "users.delete", true);
oMatrix->SetGrant("editor", "users.edit", true);
String html = oMatrix->HTML; // matrix table + inline script
// Server-side handler for a checkbox toggle (verify authorization first):
oMatrix->ProcessGrantChanged("editor", "users.delete", true);
}
__finally
{
delete oMatrix;
}
using esegece.sgcWebSockets;
var matrix = new TsgcHTMLComponent_RolesPermissions();
matrix.MatrixID = "acl";
matrix.StickyHeader = true;
matrix.AddRole("admin", "Administrator").Color = TsgcHTMLColor.hcDanger;
matrix.AddRole("editor", "Editor");
matrix.AddRole("viewer", "Viewer");
matrix.AddPermission("users.edit", "Edit users", "Users");
matrix.AddPermission("users.delete", "Delete users", "Users");
matrix.AddPermission("billing.view", "View invoices", "Billing");
matrix.SetGrant("admin", "users.edit", true);
matrix.SetGrant("admin", "users.delete", true);
matrix.SetGrant("editor", "users.edit", true);
string html = matrix.HTML; // matrix table + inline script
// Server-side handler for a checkbox toggle (verify authorization first):
matrix.ProcessGrantChanged("editor", "users.delete", true);
Składniki, po które sięgasz najczęściej.
AddRole(aId, aName) i AddPermission(aId, aName, aCategory) budują osie matrycy; każda rola otrzymuje kolorową plakietkę, każde uprawnienie opcjonalny nagłówek kategorii.
SetGrant(aRoleId, aPermissionId, aGranted) / GetGrant odczytują i zapisują zaznaczone komórki, indeksowane po id roli i uprawnienia.
LoadRolesFromDataSet, LoadPermissionsFromDataSet i LoadGrantsFromDataSet wypełniają matrycę bezpośrednio z TDataSet.
Każde przełączenie pola wyboru wysyła ładunek JSON kanałem WebSocket i wyzwala zdarzenie DOM sgcRolesPermissions:grantChanged.
ShowDescriptions, ShowCategories, Striped, Bordered, Compact i StickyHeader (z MaxHeight) stylizują tabelę; ReadOnly wyłącza wszystkie pola wyboru.
Ten komponent renderuje wyłącznie interfejs. ProcessGrantChanged można wywołać dopiero po zweryfikowaniu po stronie serwera, że działający użytkownik może zmienić tę parę rola/uprawnienie.
| Pomoc onlinePełna dokumentacja API i przewodnik użytkowania tego komponentu. | Otwórz | |
| Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 80+ komponentów. | Otwórz | |
| Pobierz bezpłatną wersję próbną30-dniowa wersja próbna zawiera projekty demonstracyjne 60.HTML. | Otwórz | |
| CennikLicencje Single, Team i Site z pełnym kodem źródłowym. | Otwórz |