src/app/features/notification/model/notification-config.ts
This represents one specific notification config for one specific user,
No results matching.
Properties |
|
Methods |
|
Accessors |
constructor(id: string)
|
||||||
|
The "id" must be the user account ID to which this config relates.
Parameters :
|
| Static isInternalEntity |
Type : unknown
|
Default value : true
|
|
Inherited from
Entity
|
| notificationRules |
Type : NotificationRule[]
|
Decorators :
@DatabaseField()
|
|
Specific rules to trigger notifications. |
| Static Readonly TEMPLATE_ENTITY_ID |
Type : string
|
Default value : "Config:NotificationConfigTemplate"
|
|
The entityId under which the database may contain a template file to use as default config for new users. The template entity has type |
| Static Optional _isCustomizedType |
| todo: This property is no longer used and will be removed in future versions. |
Type : boolean
|
|
Inherited from
Entity
|
|
True if this type's schema has been customized dynamically from the config. |
| _rev |
Type : string
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
|
internal database doc revision, used to detect conflicts by PouchDB/CouchDB |
| anonymized |
Type : boolean
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
|
Whether this entity has been anonymized and therefore cannot be re-activated. |
| Static color |
Type : string | ColorMapping[]
|
|
Inherited from
Entity
|
|
color used for to highlight this entity type across the app. Can be either:
|
| created |
Type : UpdateMetadata
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| Static DATABASE |
Type : string
|
Default value : "app"
|
|
Inherited from
Entity
|
|
The database where these entities are stored. |
| Static Optional enableUserAccounts |
Type : boolean
|
|
Inherited from
Entity
|
|
Whether to enable user account creation for this entity type. When true, the UI will allow management of user accounts associated with this entity. |
| Static ENTITY_TYPE |
Type : string
|
Default value : "Entity"
|
|
Inherited from
Entity
|
|
The entity's type.
In classes extending Entity this is usually overridden by the class annotation |
| Static hasPII |
Type : boolean
|
Default value : false
|
|
Inherited from
Entity
|
|
whether this entity type can contain "personally identifiable information" (PII) and therefore should follow strict data protection requirements and offer a function to anonymize records. |
| Static icon |
Type : IconName
|
|
Inherited from
Entity
|
|
icon id used for this entity |
| inactive |
Type : boolean
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| Static label |
Type : string
|
|
Inherited from
Entity
|
|
human-readable name/label of the entity in the UI |
| Static schema |
Type : EntitySchema
|
|
Inherited from
Entity
|
|
EntitySchema defining property transformations from/to the database.
This is auto-generated from the property annotations see /additional-documentation/how-to-guides/create-a-new-entity-type.html |
| Static Optional toBlockDetailsAttributes |
Type : EntityBlockConfig
|
|
Inherited from
Entity
|
|
Defining which attributes will be displayed in a tooltip on hover when the record is displayed as an entity-block. |
| Static toStringAttributes |
Type : []
|
Default value : ["entityId"]
|
|
Inherited from
Entity
|
|
Defining which attribute values of an entity should be shown in the The default is the ID of the entity ( |
| updated |
Type : UpdateMetadata
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| assertValid |
assertValid()
|
|
Inherited from
Entity
|
|
Checks if the entity is valid and if the check fails, throws an error explaining the failed check.
Returns :
void
|
| Public copy | ||||||||||
copy(newId: string | boolean)
|
||||||||||
|
Inherited from
Entity
|
||||||||||
|
Deep copy of the entity. The resulting entity will be of the same type as this (taking into account subclassing). All schema field values that are objects or arrays are deep-cloned to avoid shared mutable state between original and copy.
Parameters :
Returns :
unknown
|
| Static createPrefixedId | ||||||||||||
createPrefixedId(type: string, id: string)
|
||||||||||||
|
Inherited from
Entity
|
||||||||||||
|
Create a prefixed id by adding the type prefix if it isn't already part of the given id.
Parameters :
Returns :
string
|
| Static extractEntityIdFromId | ||||||||
extractEntityIdFromId(id: string)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Extract entityId without prefix.
Parameters :
Returns :
string
|
| Static extractTypeFromId | ||||||||
extractTypeFromId(id: string)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Extract the ENTITY_TYPE from an id.
Parameters :
Returns :
string
|
| Public getColor |
getColor()
|
|
Inherited from
Entity
|
|
Used by some generic UI components to set the color for the entity instance. Override this method as needed.
Returns :
string
|
| Static getColorWithConditions | ||||||
getColorWithConditions(entity: Entity)
|
||||||
|
Inherited from
Entity
|
||||||
|
Static method to evaluate conditional colors for an entity based on ColorMapping configuration.
Parameters :
Returns :
string
|
| getConstructor |
getConstructor()
|
|
Inherited from
Entity
|
|
Get the class (Entity or the actual subclass of the instance) to call static methods on the correct class considering inheritance
Returns :
EntityConstructor<unknown>
|
| Public getId | ||||||||
getId(withoutPrefix: unknown)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Returns the id of this entity. Note that an id is final and can't be changed after the object has been instantiated, hence there is no
Parameters :
Returns :
string
the unique id of this entity |
| getSchema |
getSchema()
|
|
Inherited from
Entity
|
|
Get the entity schema of this class
Returns :
EntitySchema
|
| Public getType |
getType()
|
|
Inherited from
Entity
|
|
Returns the type which is used to categorize this entity in the database. Important: Do not overwrite this method! Types are handled internally.
Returns :
string
the entity's type (which is the class name). |
| Public getWarningLevel |
getWarningLevel()
|
|
Inherited from
Entity
|
|
Override getWarningLevel() to define when the entity is in a critical condition and should be color-coded and highlighted in generic components of the UI.
Returns :
WarningLevel
|
| userId | ||||||
getuserId()
|
||||||
|
Helper method to access the user ID for whom this config is. Persisted to the database as to make permission checks easier.
Returns :
string
|
||||||
setuserId(value: string)
|
||||||
|
Parameters :
Returns :
void
|
import { Entity } from "../../../core/entity/model/entity";
import { DatabaseField } from "../../../core/entity/database-field.decorator";
import { DatabaseEntity } from "../../../core/entity/database-entity.decorator";
import { DataFilter } from "app/core/filter/filters/filters";
/**
* This represents one specific notification config for one specific user,
*/
@DatabaseEntity("NotificationConfig")
export class NotificationConfig extends Entity {
static override isInternalEntity = true;
/**
* The entityId under which the database may contain a template file
* to use as default config for new users.
*
* The template entity has type `Config<{ notificationRules: NotificationRule[] }>`
* i.e. it should contain a "data" property within which "notificationRules" can provide an array of default rules
*/
static readonly TEMPLATE_ENTITY_ID = "Config:NotificationConfigTemplate";
/**
* The default mode(s) through which all notifications are sent to the user.
*
* Can be overwritten for each notificationType to disable a channel for certain notifications.
* If the channel is not activated globally here, the individual override has no effect, however.
*/
@DatabaseField() channels: { [key in NotificationChannel]?: boolean };
/**
* Specific rules to trigger notifications.
*/
@DatabaseField() notificationRules: NotificationRule[];
/**
* The "id" must be the user account ID to which this config relates.
*/
constructor(id: string) {
super(id);
}
/**
* Helper method to access the user ID for whom this config is.
*
* Persisted to the database as to make permission checks easier.
*/
@DatabaseField() get userId(): string {
return this.getId(true);
}
set userId(value: string) {
// do not set manually, this is inferred from _id only
}
}
/**
* Defines allowed notification channels.
*
* Note: "push" is handled via individual device registrations and not part of this config currently.
*/
export type NotificationChannel = "email";
/**
* Represents a specific notification type configuration.
*/
export class NotificationRule {
/** human-readable title for this notification rule */
@DatabaseField() label?: string;
/** The general type of notification (e.g. changes to entities, etc.) */
@DatabaseField() notificationType: NotificationType;
/** whether this notification is enabled or currently "paused" */
@DatabaseField() enabled: boolean;
/**
* override for the global notification channel(s).
* e.g. define here if this specific notification rule should not show as email/push notification
*
* (optional) If not set, the global channels are used.
*/
@DatabaseField() channels?: { [key in NotificationChannel]?: boolean };
/** (for "entity_change" notifications only): type of entities that can trigger notification */
@DatabaseField() entityType?: string;
/** (for "entity_change" notifications only): type of document change that can trigger notification */
@DatabaseField() changeType?: ("created" | "updated")[];
/** (for "entity_change" notifications only): conditions which changes cause notifications */
@DatabaseField() conditions: DataFilter<any>;
}
/**
* Base type of notification rule.
*/
export type NotificationType = "entity_change";