ActivityFeed
TsgcHTMLComponent_ActivityFeed — renderizza un feed di attività live, con gli elementi più recenti in cima, timestamp relativi e push WebSocket out-of-band, in Delphi, C++ Builder e .NET.
TsgcHTMLComponent_ActivityFeed — renderizza un feed di attività live, con gli elementi più recenti in cima, timestamp relativi e push WebSocket out-of-band, in Delphi, C++ Builder e .NET.
Inserisci le attività con AddActivity, leggi HTML per il primo rendering, quindi invia i nuovi elementi in tempo reale con un frammento WebSocket.
TsgcHTMLComponent_ActivityFeed
Bootstrap 5 list + scoped CSS + live relative-time script
Delphi, C++ Builder, .NET
Chiama AddActivity per ogni voce, leggi HTML per la pagina iniziale, quindi invia un nuovo elemento come frammento out-of-band via WebSocket con GetLastItemFragmentHTML.
uses
sgcHTML_Enums, sgcHTML_Component_ActivityFeed;
var
oFeed: TsgcHTMLComponent_ActivityFeed;
begin
oFeed := TsgcHTMLComponent_ActivityFeed.Create(nil);
try
oFeed.FeedID := 'timeline';
oFeed.Title := 'Recent Activity';
oFeed.MaxItems := 30;
oFeed.AddActivity('Ana', 'closed', 'ticket #482', hcSuccess, 'bi bi-check-circle');
oFeed.AddActivity('Marc', 'commented on', 'invoice #1190', hcPrimary);
WebModule.Response := oFeed.HTML; // feed list + scoped CSS + live relative-time script
finally
oFeed.Free;
end;
end;
// Push a new item live to connected clients (out-of-band htmx fragment):
oFeed.AddActivity('Ana', 'approved', 'purchase order #77', hcSuccess);
Engine.BroadcastFragment(oFeed.GetLastItemFragmentHTML);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ActivityFeed.hpp
TsgcHTMLComponent_ActivityFeed *oFeed = new TsgcHTMLComponent_ActivityFeed(NULL);
try
{
oFeed->FeedID = "timeline";
oFeed->Title = "Recent Activity";
oFeed->MaxItems = 30;
oFeed->AddActivity("Ana", "closed", "ticket #482", hcSuccess, "bi bi-check-circle");
oFeed->AddActivity("Marc", "commented on", "invoice #1190", hcPrimary);
String html = oFeed->HTML; // feed list + scoped CSS + live relative-time script
}
__finally
{
delete oFeed;
}
using esegece.sgcWebSockets;
var feed = new TsgcHTMLComponent_ActivityFeed();
feed.FeedID = "timeline";
feed.Title = "Recent Activity";
feed.MaxItems = 30;
feed.AddActivity("Ana", "closed", "ticket #482", TsgcHTMLColor.hcSuccess, "bi bi-check-circle");
feed.AddActivity("Marc", "commented on", "invoice #1190", TsgcHTMLColor.hcPrimary);
string html = feed.HTML; // feed list + scoped CSS + live relative-time script
// Push a new item live to connected clients (out-of-band htmx fragment):
feed.AddActivity("Ana", "approved", "purchase order #77", TsgcHTMLColor.hcSuccess);
engine.BroadcastFragment(feed.GetLastItemFragmentHTML());
I membri che utilizzerai più spesso.
AddActivity(aActor, aAction, aTarget, aColor, aIcon, aActorAvatarURL) aggiunge una voce e restituisce il TsgcHTMLActivityItem.
MaxItems limita il numero di voci conservate; l’elemento più vecchio viene rimosso automaticamente al raggiungimento del limite.
ShowRelativeTime renderizza timestamp in stile “3 minuti fa” mantenuti live lato client; TimeFormat è il fallback quando è disattivato.
GetItemFragmentHTML / GetLastItemFragmentHTML costruiscono un frammento htmx out-of-band per PushFragment / BroadcastFragment, così una nuova attività appare senza ricaricare la pagina.
EmptyText è il segnaposto mostrato mentre Items è vuoto; GetEmptyFragmentHTML lo ri-renderizza come frammento push.
Title etichetta il feed, Compact riduce la spaziatura delle righe, e HTML restituisce il feed con il relativo CSS e script.
| Guida in lineaRiferimento API completo e guida all’uso per questo componente. | Apri | |
| Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 80 componenti. | Apri | |
| Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML. | Apri | |
| PrezziLicenze Single, Team e Site con codice sorgente completo. | Apri |