ActivityFeed Component — sgcHTML | eSeGeCe

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

Inserisci le attività con AddActivity, leggi HTML per il primo rendering, quindi invia i nuovi elementi in tempo reale con un frammento WebSocket.

Classe del componente

TsgcHTMLComponent_ActivityFeed

Renderizza

Bootstrap 5 list + scoped CSS + live relative-time script

Famiglia

Dati e Tabelle

Linguaggi

Delphi, C++ Builder, .NET

Aggiungi le attività, renderizzalo, invia le nuove in tempo reale

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());

Proprietà e metodi principali

I membri che utilizzerai più spesso.

Items / AddActivity

AddActivity(aActor, aAction, aTarget, aColor, aIcon, aActorAvatarURL) aggiunge una voce e restituisce il TsgcHTMLActivityItem.

Buffer circolare

MaxItems limita il numero di voci conservate; l’elemento più vecchio viene rimosso automaticamente al raggiungimento del limite.

Tempo relativo

ShowRelativeTime renderizza timestamp in stile “3 minuti fa” mantenuti live lato client; TimeFormat è il fallback quando è disattivato.

Push live

GetItemFragmentHTML / GetLastItemFragmentHTML costruiscono un frammento htmx out-of-band per PushFragment / BroadcastFragment, così una nuova attività appare senza ricaricare la pagina.

Stato vuoto

EmptyText è il segnaposto mostrato mentre Items è vuoto; GetEmptyFragmentHTML lo ri-renderizza come frammento push.

Layout

Title etichetta il feed, Compact riduce la spaziatura delle righe, e HTML restituisce il feed con il relativo CSS e script.

Continua a esplorare

Guida in lineaRiferimento API completo e guida all’uso per questo componente.
Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 80 componenti.
Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML.
PrezziLicenze Single, Team e Site con codice sorgente completo.

Pronto a Iniziare?

Scarica la versione di prova gratuita e inizia a creare interfacce web in Delphi, C++ Builder e .NET.