UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

51 lines (50 loc) 1.82 kB
import ObjectFactory from '../../ObjectFactory'; import { EMPTY_STRING } from '../../Constants/GeneralConstants'; import { ALERT_DEFAULT_MESSAGE_TYPE } from '../../Constants/ObjectDefaultConstants'; import { createUuid } from '../../../AdaptableState/Uuid'; export function isScheduledAlertDefinition(alert) { return alert != null && 'Schedule' in alert; } export function isRuleBasedAlertDefinition(alert) { return alert != null && 'Rule' in alert; } export function getRuleAlertProperties(alert) { return isRuleBasedAlertDefinition(alert) ? alert.AlertProperties : undefined; } export function getActiveScheduledAlertDefinitions(alerts) { return alerts.filter((a) => !a.IsSuspended && isScheduledAlertDefinition(a)); } export function getScheduledAlertNotificationForm(includeSuspendButton) { const buttons = [ { Label: 'OK', ButtonStyle: { variant: 'raised' }, }, ]; if (includeSuspendButton) { buttons.push({ Label: 'Suspend', ButtonStyle: { variant: 'outlined' }, Command: 'suspend', }); } return { fields: [], Buttons: buttons }; } export function scheduledAlertIncludeSuspendButton(alert) { return alert.AlertProperties?.IncludeSuspendButton ?? false; } export function CreateEmptyScheduledAlertDefinition(name) { const displayName = name?.trim() || ''; return { Uuid: createUuid(), Name: displayName || EMPTY_STRING, MessageType: ALERT_DEFAULT_MESSAGE_TYPE, Schedule: ObjectFactory.CreateDefaultSchedule(), MessageHeader: displayName, MessageText: displayName ? `Reminder: ${displayName}` : '', AlertProperties: { DisplayNotification: true, DisplaySystemStatusMessage: false, }, }; }