File

global-context/services/domain/widget-config-migration.service.ts

Index

Methods

Constructor

constructor(dateTimeContextPickerService: DateTimeContextPickerService)
Parameters :
Name Type Optional
dateTimeContextPickerService DateTimeContextPickerService No

Methods

hasNoTimeContextFields
hasNoTimeContextFields(config: object)

True when a config carries neither the new dateTimeContext nor any legacy time field (dateFrom, dateTo, dateFilter, date, interval). Use to decide whether widget-specific legacy defaults should be applied.

Parameters :
Name Type Optional
config object No
Returns : boolean
migrateWidgetConfig
migrateWidgetConfig(config: T, options?: MigrateWidgetConfigOptions)
Type parameters :
  • T

Transforms legacy widget configurations into the standardized GlobalContextState format.

This migration handles the transition from various legacy configuration formats to the new unified global context system. It detects which properties need updating and preserves configurations that are already in the correct format.

What is migrated:

  • displayMode: Derived from widgetInstanceGlobalTimeContext/AutoRefreshContext flags
  • dateTimeContext: Normalized from dateFilter, date, dateFrom/dateTo, or interval fields
  • refreshOption: Converted from legacy 'interval'/'global-interval'/'none' values to LIVE/HISTORY
  • isAutoRefreshEnabled + refreshInterval: Determined from realtime flags and legacy settings
  • aggregation: Normalized from legacy 'NONE' string to null

Use case: Call this on every widget configuration before rendering to ensure compatibility with the global context system, regardless of when the widget was created or last saved.

Can be any object type, but should contain widget configuration fields. legacy format or preserved if already valid. Returns input unchanged if null/undefined.

Example :
// Legacy config with old format
const legacyConfig = {
  widgetInstanceGlobalTimeContext: true,
  dateFrom: '2024-01-01',
  dateTo: '2024-01-02',
  refreshOption: 'interval'
};


// After migration
const migrated = migrationService.migrateWidgetConfig(legacyConfig);
// {
//   displayMode: 'dashboard',
//   dateTimeContext: { dateFrom: '2024-01-01T00:00:00.000Z', dateTo: '2024-01-02T00:00:00.000Z', interval: 'custom' },
//   refreshOption: 'live',
//   isAutoRefreshEnabled: true,
//   refreshInterval: 60000,
//   aggregation: null
// }
Parameters :
Name Type Optional Description
config T No
  • Widget configuration object that may contain legacy or new format properties. Can be any object type, but should contain widget configuration fields.
options MigrateWidgetConfigOptions Yes
Returns : Partial<GlobalContextState>

Configuration with all required GlobalContextState properties, either migrated from legacy format or preserved if already valid. Returns input unchanged if null/undefined.

results matching ""

    No results matching ""