adminizer

Notification System Documentation

System Overview

The notification system is a mechanism for sending and managing real-time notifications to users through a web interface. It operates on a publisher-subscriber principle, where various services can send notifications, and clients (users’ browsers) receive them in real time.

Key Components

AbstractNotificationService

A base class for all notification types that provides:

NotificationHandler

A central coordinator that:

How It Works

1. Client Connections

When a user opens the web interface, their browser establishes a connection with the notification server. The system remembers this connection and associates it with the specific user.

2. Sending Notifications

Any service can send a notification by specifying:

The system automatically:

3. Receiving Notifications

Clients receive notifications in real time through the established connection. If the user is offline, notifications are saved and will be shown upon next connection.

4. Notification Management

Users can:

Notification Types

The system supports various notification types through separate services. Each type can have:

System Advantages

The system provides seamless user interaction by delivering important information in real time while maintaining history for future reference.

System Initialization

The notification system is initialized when the application starts through the bindNotifications() function, which:

  1. Creates a handler - central coordinator for all notifications
  2. Registers services - connects various notification types:
    • GeneralNotificationService - general notifications
    • SystemNotificationService - system events and notifications

Integration with Adminizer

The system is tightly integrated with the main Adminizer framework:

Helper Methods for Developers

Adminizer provides convenient methods for sending notifications:

1. General Notification Sending

await adminizer.sendNotification({
    notificationClass: 'general',              // Notification type
    title: 'New Message',                      // Title
    message: 'You have a new message',         // Message text
    userId: 123,                               // User ID (optional)
    metadata: { important: true }              // Additional data
});

2. System Events

// General system event
await adminizer.logSystemEvent(
    'System Update', 
    'The system has been successfully updated',
    { version: '2.0.0' }
);

// CRUD operation events
await adminizer.logSystemCreatedEvent('New User', 'User John Doe created');
await adminizer.logSystemUpdatedEvent('Profile Update', 'User profile updated');
await adminizer.logSystemDeletedEvent('Record Deletion', 'Record deleted from database');

Default Notification Service Types

GeneralNotificationService

SystemNotificationService

Access Rights

The system automatically registers access rights for each notification type through AccessRightsHelper. Users can only receive notifications for which they have permissions.