UserManagement
TsgcHTMLComponent_UserManagement — Delphi、C++ Builder、.NET で、アバター、ロール、ステータス、検索、行ごとのアクションドロップダウンを備えたユーザー管理テーブルです。
TsgcHTMLComponent_UserManagement — Delphi、C++ Builder、.NET で、アバター、ロール、ステータス、検索、行ごとのアクションドロップダウンを備えたユーザー管理テーブルです。
AddUser でユーザーを追加する(またはデータセットをバインドする)、公開する列と行アクションを選択してから、HTML プロパティを読み取ります。
TsgcHTMLComponent_UserManagement
ツールバー + Bootstrap 5 テーブル + アクションドロップダウン
Delphi, C++ Builder, .NET
各アカウントについて AddUser を呼び出し、テーブルには HTML を読み取ります。その後、WebSocket チャンネル経由で受信したアクションを、ProcessUserAction で認可・適用します。
uses
sgcHTML_Component_UserManagement;
var
oUsers: TsgcHTMLComponent_UserManagement;
oUser: TsgcHTMLUser;
begin
oUsers := TsgcHTMLComponent_UserManagement.Create(nil);
try
oUsers.TableID := 'users';
oUsers.AllowImpersonate := True;
oUsers.AllowDelete := True;
oUser := oUsers.AddUser('u1', 'ana.torres', 'ana@example.com');
oUser.DisplayName := 'Ana Torres';
oUser.Roles := 'admin,editor';
oUser.Status := usActive;
oUser.LastLogin := '2026-07-15 09:12';
oUsers.AddUser('u2', 'marc.bell', 'marc@example.com').Status := usInvited;
WebModule.Response := oUsers.HTML; // toolbar + table + inline script
finally
oUsers.Free;
end;
end;
// Server-side handler for an action received over WebSockets.
// ALWAYS verify the acting user is authorized before applying it:
oUsers.ProcessUserAction('userDisable', 'u2');
// includes: sgcHTML_Component_UserManagement.hpp
TsgcHTMLComponent_UserManagement *oUsers = new TsgcHTMLComponent_UserManagement(NULL);
try
{
oUsers->TableID = "users";
oUsers->AllowImpersonate = true;
oUsers->AllowDelete = true;
TsgcHTMLUser *oUser = oUsers->AddUser("u1", "ana.torres", "ana@example.com");
oUser->DisplayName = "Ana Torres";
oUser->Roles = "admin,editor";
oUser->Status = usActive;
oUser->LastLogin = "2026-07-15 09:12";
oUsers->AddUser("u2", "marc.bell", "marc@example.com")->Status = usInvited;
String html = oUsers->HTML; // toolbar + table + inline script
// Server-side handler for an action received over WebSockets:
oUsers->ProcessUserAction("userDisable", "u2");
}
__finally
{
delete oUsers;
}
using esegece.sgcWebSockets;
var users = new TsgcHTMLComponent_UserManagement();
users.TableID = "users";
users.AllowImpersonate = true;
users.AllowDelete = true;
var user = users.AddUser("u1", "ana.torres", "ana@example.com");
user.DisplayName = "Ana Torres";
user.Roles = "admin,editor";
user.Status = TsgcHTMLUserStatus.usActive;
user.LastLogin = "2026-07-15 09:12";
users.AddUser("u2", "marc.bell", "marc@example.com").Status = TsgcHTMLUserStatus.usInvited;
string html = users.HTML; // toolbar + table + inline script
// Server-side handler for an action received over WebSockets.
// ALWAYS verify the acting user is authorized before applying it:
users.ProcessUserAction("userDisable", "u2");
最もよく使うメンバーです。
AddUser(aId, aUserName, aEmail) は行を追加し、TsgcHTMLUser を返します。これにより DisplayName、Roles、Status、LastLogin、AvatarURL を設定できます。
LoadFromDataSet(aDataSet, aIdField, aUserNameField, aEmailField, aRolesField, aStatusField) はテーブルにデータを投入し、後で再読み込みするためにマッピングを記憶します。
TsgcHTMLUserStatus — usActive、usInvited、usSuspended、usDisabled — は色付きバッジとしてレンダリングされます。Roles はカンマ区切りのリストで、バッジとしてレンダリングされます。
各行のドロップダウンには、編集 / 無効化・有効化 / パスワードリセットが用意されています。AllowImpersonate と AllowDelete は、より機密性の高いアクションを追加します。
ShowSearch、ShowAddButton(AddCaption / SearchPlaceholder と併用)はツールバーを制御します。ShowRoles、ShowStatus、ShowLastLogin、ShowActions、PageSize はテーブルを制御します。
すべてのアクションはクライアントからサーバーへ JSON として送られ(sgcUserManagement:action を発火します)、ProcessUserAction は、ホスト側で操作するユーザーがそのアクションを許可されていることを検証した後にのみ実行する必要があります。