File

global-context/services/state/global-context-store.service.ts

Description

GlobalContextConfigStoreService

Component-scoped store that manages widget-level Global Context configuration.

  • Holds separate Live/History modes
  • Tracks refreshOption (tab) and displayMode
  • Normalizes incoming configs (Live → aggregation=null; History → interval=CUSTOM)
  • Applies targeted patches to the current mode
  • Avoids redundant recomputation via shallow diffing

Provided in component scope (see providers of c8y-global-context-config).

Index

Properties
Methods

Methods

hydrate
hydrate(config: GlobalContextState)

Hydrates the store from an external config input. After the first call, preserves the user's tab selection.

Parameters :
Name Type Optional Description
config GlobalContextState No
  • Incoming widget-level global context configuration
Returns : void
patchCurrent
patchCurrent(changes: Partial)

Applies a partial update to the currently selected refresh mode. Enforces business rules (Live: aggregation=null; History: interval=CUSTOM) before commit.

Parameters :
Name Type Optional Description
changes Partial<GlobalContextState> No
  • Partial changes to apply to the current refresh mode
Returns : void
resetAllModesToDefaults
resetAllModesToDefaults()

Resets both Live and History modes to defaults, preserving the current selected tab and display mode.

Returns : void
resetModeToDefaults
resetModeToDefaults(target: RefreshOption)

Resets a single mode (live/history) to defaults, preserving the current display mode and selected tab.

Parameters :
Name Type Optional
target RefreshOption No
Returns : void
select
select(project: (s: GlobalContextState) => void)
Type parameters :
  • K

Selects a value from the active configuration using a projector function. Returns a signal that updates whenever the active configuration changes.

Parameters :
Name Type Optional
project function No
Returns : any
setDisplayMode
setDisplayMode(mode: GlobalContextDisplayMode)

Sets the display mode and syncs the mode to both modes. Does not change the selected tab.

Parameters :
Name Type Optional Description
mode GlobalContextDisplayMode No
  • Display mode to set (CONFIG or VIEW_AND_CONFIG)
Returns : void
setRefreshOption
setRefreshOption(option: RefreshOption)

Explicitly selects the tab (Live/History). Does not mutate stored values for either refresh mode; it only switches which mode is active.

Parameters :
Name Type Optional Description
option RefreshOption No
  • Target refresh option (LIVE or HISTORY)
Returns : void
setSnapshot
setSnapshot(option: RefreshOption, snapshot: GlobalContextState | null)

Hydrates the snapshot for a specific refresh mode without altering the current selection. Used by widget configuration to restore per-mode state across component lifecycles.

Parameters :
Name Type Optional
option RefreshOption No
snapshot GlobalContextState | null No
Returns : void
setWidgetControls
setWidgetControls(controls: WidgetControls)

Sets the widget controls template. Required for computing visibility via settings.

Parameters :
Name Type Optional
controls WidgetControls No
Returns : void

Properties

Readonly activeConfig
Type : unknown
Default value : computed(() => { return this.refreshOption() === REFRESH_OPTION.LIVE ? this.liveState() : this.historyState(); })

Effective configuration for the currently selected tab. Consumers should read this to render the UI.

Readonly displayMode
Type : WritableSignal<GlobalContextDisplayMode>
Default value : signal( GLOBAL_CONTEXT_DISPLAY_MODE.CONFIG )

Current display mode for the widget (config or view_and_config).

Readonly historyState
Type : WritableSignal<GlobalContextState | null>
Default value : signal(null)

History mode of the widget time context state. Null until the store is hydrated with the first input.

Readonly initialized
Type : WritableSignal<boolean>
Default value : signal(false)

Whether the store has processed the first hydrate() call.

Readonly inlineSettings
Type : unknown
Default value : computed(() => { const res = this.widgetControlService.resolveInlineControlSettings( this._widgetControls(), this.displayMode(), this.refreshOption() ); return res; // { settings, links, dashboardControls } })

Inline visibility and dashboard control settings derived for the Inline component. Uses default link states from the widget controls; dynamic link toggling remains handled by the Inline component.

Readonly liveState
Type : WritableSignal<GlobalContextState | null>
Default value : signal(null)

Live mode of the widget time context state. Null until the store is hydrated with the first input.

Readonly refreshOption
Type : WritableSignal<RefreshOption>
Default value : signal(REFRESH_OPTION.LIVE)

Currently selected tab (refresh option). Defaults to LIVE.

Readonly settings
Type : unknown
Default value : computed<Partial<GlobalContextSettings>>(() => { this.activeConfig(); const { settings } = this.widgetControlService.resolveConfigControlSettings( this._widgetControls(), this.displayMode(), this.refreshOption() ); return settings; })

Computed visibility settings for controls, based on the current widget controls, display mode, and selected refresh option. If widgetControls are not provided yet, defaults to showing all controls.

results matching ""

    No results matching ""