NotificationInbox
TsgcHTMLComponent_NotificationInbox: okunmamış rozetli bir zil ve tek bir kullanıcının bildirimlerinin açılır listesi, Delphi, C++ Builder ve .NET'te. Satırları uygulamanız tutar, bileşen onları işler.
TsgcHTMLComponent_NotificationInbox: okunmamış rozetli bir zil ve tek bir kullanıcının bildirimlerinin açılır listesi, Delphi, C++ Builder ve .NET'te. Satırları uygulamanız tutar, bileşen onları işler.
Kitaplık hiçbir şey saklamaz. Uygulamanız OnLoadNotifications olayını tuttuğu satırlarla yanıtlar ve kullanıcının ne yaptığını OnMarkRead ve OnMarkAllRead aracılığıyla öğrenir, böylece bunu kalıcı hale getirebilir. Bileşen arayüzü işler ve hiçbir yetkilendirme uygulamaz. Her sürümde, WebSocket ya da sunucu tarafından gönderilen olaylar üzerinden çalışır.
TsgcHTMLComponent_NotificationInbox (sgcHTML_Component_NotificationInbox birimi)
Bootstrap açılır menü işaretlemesi: bir zil, bir okunmamış rozeti ve bir liste
Delphi, C++ Builder, .NET
Gelen kutusuna bir InboxID verin, onu OnLoadNotifications içinde kendi depolamanızdan doldurun, kullanıcının yaptıklarını OnMarkRead ve OnMarkAllRead içinde kalıcı hale getirin ve gönderilen eylemleri, kullanıcıyı oturumdan alarak ProcessAction yöntemine yönlendirin.
uses
sgcHTML_Session, sgcHTML_Component_NotificationInbox;
var
oInbox: TsgcHTMLComponent_NotificationInbox;
begin
oInbox := TsgcHTMLComponent_NotificationInbox.Create(nil);
try
oInbox.InboxID := 'inbox';
oInbox.Title := 'Notifications';
oInbox.MaxItems := 10;
oInbox.OnLoadNotifications := InboxLoad;
oInbox.OnMarkRead := InboxMarkRead;
oInbox.OnMarkAllRead := InboxMarkAllRead;
// the user comes from the session, never from the form
oInbox.LoadNotifications(sgcHTMLRequestSession.UserID);
Response := oInbox.HTML; // bell, unread badge and dropdown
finally
oInbox.Free;
end;
end;
// the application owns the rows: fill the list, newest first
procedure TMain.InboxLoad(Sender: TObject; const aUserID: string;
aList: TsgcHTMLInboxItems);
begin
with aList.Add do
begin
Id := '1042';
Title := 'New order';
Text := 'Order #1042 was placed.';
Timestamp := '2 min ago';
Read := False;
end;
end;
procedure TMain.InboxMarkRead(Sender: TObject; const aUserID,
aNotificationID: string);
begin
// persist it, after checking that aUserID owns aNotificationID
end;
// in the message handler that receives the actions the inbox posts
if oInbox.ProcessAction(vUser, vAction, vNotificationID) then
oHTMX.PushFragment(vGuid, oInbox.GetListFragmentHTML +
oInbox.GetBadgeFragmentHTML);
// includes: sgcHTML_Session.hpp, sgcHTML_Component_NotificationInbox.hpp
TsgcHTMLComponent_NotificationInbox *oInbox = new TsgcHTMLComponent_NotificationInbox(NULL);
try
{
oInbox->InboxID = "inbox";
oInbox->Title = "Notifications";
oInbox->MaxItems = 10;
oInbox->OnLoadNotifications = InboxLoad;
oInbox->OnMarkRead = InboxMarkRead;
oInbox->OnMarkAllRead = InboxMarkAllRead;
// the user comes from the session, never from the form
oInbox->LoadNotifications(sgcHTMLRequestSession()->UserID);
String html = oInbox->HTML; // bell, unread badge and dropdown
}
__finally
{
delete oInbox;
}
// the application owns the rows: fill the list, newest first
void __fastcall TMain::InboxLoad(TObject *Sender, const String aUserID,
TsgcHTMLInboxItems *aList)
{
TsgcHTMLInboxItem *item = aList->Add();
item->Id = "1042";
item->Title = "New order";
item->Text = "Order #1042 was placed.";
item->Timestamp = "2 min ago";
item->Read = false;
}
void __fastcall TMain::InboxMarkRead(TObject *Sender, const String aUserID,
const String aNotificationID)
{
// persist it, after checking that aUserID owns aNotificationID
}
// in the message handler that receives the actions the inbox posts
if (oInbox->ProcessAction(vUser, vAction, vNotificationID))
oHTMX->PushFragment(vGuid, oInbox->GetListFragmentHTML() +
oInbox->GetBadgeFragmentHTML());
using esegece.sgcWebSockets;
var inbox = new TsgcHTMLComponent_NotificationInbox();
inbox.InboxID = "inbox";
inbox.Title = "Notifications";
inbox.MaxItems = 10;
inbox.OnLoadNotifications += InboxLoad;
inbox.OnMarkRead += InboxMarkRead;
inbox.OnMarkAllRead += InboxMarkAllRead;
// the user comes from the session, never from the form
string user = sgcHTMLSessionHelpers.sgcHTMLRequestSession()?.UserID ?? "";
inbox.LoadNotifications(user);
string html = inbox.HTML; // bell, unread badge and dropdown
// the application owns the rows: fill the list, newest first
void InboxLoad(object sender, string userID, TsgcHTMLInboxItems list)
{
var item = list.Add();
item.Id = "1042";
item.Title = "New order";
item.Text = "Order #1042 was placed.";
item.Timestamp = "2 min ago";
item.Read = false;
}
void InboxMarkRead(object sender, string userID, string notificationID)
{
// persist it, after checking that userID owns notificationID
}
// in the message handler that receives the actions the inbox posts
if (inbox.ProcessAction(user, action, notificationId))
htmx.PushFragment(guid, inbox.GetListFragmentHTML() + inbox.GetBadgeFragmentHTML());
En sık başvurduğunuz üyeler.
Items, bir TsgcHTMLInboxItems koleksiyonudur; her TsgcHTMLInboxItem öğesinin Id, Title, Text, Timestamp, Url, Icon ve Read özellikleri vardır. Bir satırdaki her şey veridir ve işlenirken kaçışlanır, Icon da buna dahildir: gerçek bir glif geçirin, hiçbir zaman bir HTML entity'si ya da işaretleme geçirmeyin. Url temizlenir ve javascript: ile data: bağlantıları reddedilir.
Bileşen yalnızca işlediği şeyi tutar. OnLoadNotifications(aUserID, aList), aList zaten temizlenmiş olarak tetiklenir: onu kullanıcının bildirimleriyle, en yenisi başta olacak şekilde doldurun. OnMarkRead(aUserID, aNotificationID) öğe okundu olarak işaretlendikten sonra, OnMarkAllRead(aUserID) ise her öğe işaretlendikten sonra tetiklenir.
İşi LoadNotifications(aUserID), MarkRead(aUserID, aNotificationID) ve MarkAllRead(aUserID) yapar. ProcessAction(aUserID, aAction, aNotificationID) gönderilen bir eylemi doğru olana yönlendirir ve eylem bir gelen kutusu eylemi değilse False döndürür, böylece sahibini aramaya devam edebilirsiniz.
Açılır menü, inboxMarkRead (action, inbox, id alanları), inboxMarkAllRead ve inboxRefresh (action, inbox alanları) eylemlerini data-sgc-ws-send formları olarak gönderir. inbox alanı, formu işleyen gelen kutusunun öğe kimliğini taşır; bu, ayarladıysanız InboxID değeridir ve birden çok gelen kutusu olan bir sayfa eylemi doğru bileşene bu sayede yönlendirir.
Bileşen arayüzü işler ve hiçbir yetkilendirme uygulamaz. Her eylem istemcinin gönderdiği veri olarak taşınır, bu yüzden kötü niyetli bir istemci herhangi bir eylemin ve herhangi bir bildirim kimliğinin sahtesini oluşturabilir. İşaretlemeye hiçbir kullanıcı kimliği yazılmaz: eylemi yapan kullanıcıyı istek oturumundan (sgcHTMLRequestSession) alın, hiçbir zaman formdan almayın ve herhangi bir şeyi kalıcı hale getirmeden önce kullanıcının gelen bildirim kimliğine sahip olduğunu denetleyin.
Title açılır menü başlığıdır, EmptyText gösterilecek bir şey olmadığında görünen yer tutucudur, BellIcon ise tetikleyici glifidir; varsayılan olarak bir HTML entity'si içeren güvenilir işaretlemedir. MaxItems görünen satırları sınırlar (varsayılan 10, 0 hepsini gösterir), ShowMarkAllRead ve ShowBadge varsayılan olarak açıktır ve AddNotification(aId, aTitle, aText, aTimestamp, aUrl, aIcon) bir satır ekler ya da aynı kimliğe sahip olanı günceller.
Her bildirim, rozet ve liste sabit bir öğe kimliği taşır. Bir değişiklikten sonra sayfayı yeniden işlemek yerine yalnızca etkilenen işaretlemeyi GetItemFragmentHTML(aId), GetBadgeFragmentHTML ya da GetListFragmentHTML ile işleyin ve TsgcHTMX_Engine_Server.PushFragment ya da BroadcastFragment ile gönderin. UnreadCount, Read değeri False olan öğeleri sayar.
Birim, SGC_HTML tanımlı olduğunda derlenir; sgcVer.inc bunu Android ve iOS için tanımlamaz. Her sürümde, WebSocket ya da sunucu tarafından gönderilen olaylar üzerinden çalışır. sgcHTML tek başına bir pakettir ve sgcWebSockets'ten bağımsız olarak satılır.
Gelen kutusu sayfa ile push arasında kendisi seçim yapmaz: bunu TsgcHTMLComponent_Notification yapar, bkz. Notification ve WebPush. Her kullanıcının hangi kanalları istediği NotificationPreferences içinde ayarlanır.
| Çevrimiçi yardımBu bileşen için tam API referansı ve kullanım kılavuzu. | Aç | |
| Tüm sgcHTML Bileşenleri80'den fazla bileşenin tam özellik matrisine göz atın. | Aç | |
| Ücretsiz Deneme Sürümünü İndirin30 günlük deneme sürümü, gelen kutusunu kullanan 17.FieldService dahil olmak üzere 60.HTML demo projelerini içerir. | Aç | |
| FiyatlandırmaTam kaynak kodlu Single, Team ve Site lisansları. | Aç |