RolesPermissions
TsgcHTMLComponent_RolesPermissions — una matriz de roles / permisos con una casilla por celda, agrupación por categorías y actualizaciones de concesión en vivo por WebSocket, en Delphi, C++ Builder y .NET.
TsgcHTMLComponent_RolesPermissions — una matriz de roles / permisos con una casilla por celda, agrupación por categorías y actualizaciones de concesión en vivo por WebSocket, en Delphi, C++ Builder y .NET.
Añade roles y permisos, define las concesiones iniciales, luego lee la propiedad HTML. Cada cambio de casilla se envía al servidor, que debe autorizarlo antes de aplicarlo.
TsgcHTMLComponent_RolesPermissions
Matriz de tabla Bootstrap 5 + script en línea
Delphi, C++ Builder, .NET
Llama a AddRole y AddPermission para construir los ejes de la matriz, SetGrant para las marcas iniciales, luego lee 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);
Los miembros que usarás con más frecuencia.
AddRole(aId, aName) y AddPermission(aId, aName, aCategory) construyen los ejes de la matriz; cada rol recibe una insignia coloreada, cada permiso una cabecera de categoría opcional.
SetGrant(aRoleId, aPermissionId, aGranted) / GetGrant leen y escriben las celdas marcadas, indexadas por id de rol + permiso.
LoadRolesFromDataSet, LoadPermissionsFromDataSet y LoadGrantsFromDataSet rellenan la matriz directamente desde un TDataSet.
Cada cambio de casilla envía un payload JSON por el canal WebSocket y dispara el evento DOM sgcRolesPermissions:grantChanged.
ShowDescriptions, ShowCategories, Striped, Bordered, Compact y StickyHeader (con MaxHeight) dan estilo a la tabla; ReadOnly deshabilita todas las casillas.
Este componente solo renderiza la interfaz. ProcessGrantChanged debe llamarse únicamente después de que el host verifique, en el servidor, que el usuario que actúa puede cambiar ese par rol/permiso.
| Ayuda en líneaReferencia completa de la API y guía de uso para este componente. | Abrir | |
| Todos los componentes de sgcHTMLExplora la matriz completa de más de 80 componentes. | Abrir | |
| Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos de demostración 60.HTML. | Abrir | |
| PreciosLicencias Single, Team y Site con código fuente completo. | Abrir |