@c8y/ngx-components 1023.14.145 → 1023.14.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11024,9 +11024,18 @@ class ConfigModeControls {
11024
11024
  const mode = cfg.displayMode ?? GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD;
11025
11025
  const context = mode === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD
11026
11026
  ? this.getGlobalContextState(mode)
11027
- : { ...cfg, isGlobalContextReady: true };
11028
- this.lastEmittedContext.set(context);
11029
- this.configChange.emit({ context, diff: context });
11027
+ : this.buildNonDashboardContext(cfg);
11028
+ this.emit(context);
11029
+ }
11030
+ buildNonDashboardContext(cfg) {
11031
+ const isLive = cfg.refreshOption !== REFRESH_OPTION.HISTORY && !!cfg.dateTimeContext;
11032
+ return {
11033
+ ...cfg,
11034
+ isGlobalContextReady: true,
11035
+ dateTimeContext: isLive
11036
+ ? DateTimeContextUtil.normalizeForLive(cfg.dateTimeContext)
11037
+ : cfg.dateTimeContext
11038
+ };
11030
11039
  }
11031
11040
  emitForDisplayMode(mode) {
11032
11041
  if (mode === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD) {
@@ -11037,9 +11046,12 @@ class ConfigModeControls {
11037
11046
  this.emit({ ...(snapshot ?? this.config()), displayMode: mode, isGlobalContextReady: true });
11038
11047
  }
11039
11048
  }
11049
+ /** Emits configChange if the diff contains changes beyond transient flags. */
11040
11050
  emit(context) {
11041
11051
  const diff = this.globalContextUtils.getChangedFields(this.lastEmittedContext(), context);
11042
- if (Object.keys(diff).length === 0)
11052
+ const substantiveDiff = { ...diff };
11053
+ delete substantiveDiff.isGlobalContextReady;
11054
+ if (Object.keys(substantiveDiff).length === 0)
11043
11055
  return;
11044
11056
  this.lastEmittedContext.set(context);
11045
11057
  this.configChange.emit({ context, diff });
@@ -11209,17 +11221,22 @@ class ContextControlsComponent {
11209
11221
  this.syncConfigToForm();
11210
11222
  this.subscribeToFormChanges();
11211
11223
  }
11224
+ ngOnInit() {
11225
+ this.emitInitialNonDashboardState();
11226
+ }
11212
11227
  onRefresh() {
11213
- const { dateTimeContext } = this.config();
11214
- if (!dateTimeContext) {
11228
+ const cfg = this.config();
11229
+ if (!cfg.dateTimeContext) {
11215
11230
  this.refresh.emit();
11216
11231
  return;
11217
11232
  }
11218
- const context = {
11219
- ...this.config(),
11220
- dateTimeContext: DateTimeContextUtil.normalizeForLive(dateTimeContext)
11233
+ // Normalize dates to "now" and emit as a config change.
11234
+ // If dates haven't changed (same second), fall back to a plain refresh.
11235
+ const normalized = {
11236
+ ...cfg,
11237
+ dateTimeContext: DateTimeContextUtil.normalizeForLive(cfg.dateTimeContext)
11221
11238
  };
11222
- if (!this.emitIfChanged(context)) {
11239
+ if (!this.emitIfChanged(normalized)) {
11223
11240
  this.refresh.emit();
11224
11241
  }
11225
11242
  }
@@ -11236,9 +11253,20 @@ class ContextControlsComponent {
11236
11253
  effect(() => {
11237
11254
  const cfg = this.config();
11238
11255
  this.form.patchValue(cfg, { emitEvent: false });
11239
- this.lastEmittedState.set(this.form.value);
11240
11256
  });
11241
11257
  }
11258
+ /** On first render for non-dashboard mode, normalize stale live dates and emit. */
11259
+ emitInitialNonDashboardState() {
11260
+ if (this.displayMode() === GLOBAL_CONTEXT_DISPLAY_MODE.DASHBOARD)
11261
+ return;
11262
+ const cfg = this.config();
11263
+ const isLive = cfg.refreshOption !== REFRESH_OPTION.HISTORY && !!cfg.dateTimeContext;
11264
+ const normalized = isLive
11265
+ ? { ...cfg, dateTimeContext: DateTimeContextUtil.normalizeForLive(cfg.dateTimeContext) }
11266
+ : cfg;
11267
+ this.form.patchValue(normalized, { emitEvent: false });
11268
+ this.emitIfChanged(normalized);
11269
+ }
11242
11270
  subscribeToFormChanges() {
11243
11271
  this.form.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => {
11244
11272
  const context = this.clearInvalidAggregation(value);
@@ -11804,5 +11832,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
11804
11832
  * Generated bundle index. Do not edit.
11805
11833
  */
11806
11834
 
11807
- export { AGGREGATIONS, AGGREGATION_ICONS, AGGREGATION_ICON_TYPE, AGGREGATION_LABELS, AGGREGATION_LIMITS, AGGREGATION_TEXTS, AGGREGATION_VALUES, AGGREGATION_VALUES_ARR, AggregationDisplayComponent, AggregationPickerComponent, AggregationPickerService, AggregationValidationService, AutoRefreshControlComponent, CONTEXT_FEATURE, CONTROL_PRESETS, ConfigContextSelectorComponent, ConfigModeControls, ConfigModeControls as ConfigModeControlsComponent, ConfigurationCollapseComponent, ConfigurationControlsComponent, ContextControlsComponent$1 as ContextControlsComponent, DEFAULT_WIDGET_TEMPLATE, DateContextQueryParamNames, DateTimeContextPickerComponent, DateTimeContextPickerService, GLOBAL_CONTEXT_DEFAULTS, GLOBAL_CONTEXT_DISPLAY_MODE, GLOBAL_CONTEXT_EVENTS, GLOBAL_CONTEXT_SOURCE, GlobalContextComponent, GlobalContextConfigComponent, GlobalContextConnectorComponent, GlobalContextEventService, GlobalContextFormService, GlobalContextInlineComponent, GlobalContextLinkControlsComponent, GlobalContextModule, GlobalContextNavigationService, GlobalContextQueryService, GlobalContextService, GlobalContextUtilsService, GlobalContextValidationService, GlobalContextWidgetConfigComponent, GlobalContextWidgetWrapperComponent, HistoryModeConfigurationControlsComponent, INTERVALS, INTERVAL_TITLES, IntervalPickerComponent, LINK_BTNS_CONFIG, LinkButtonsComponent, LiveModeConfigurationControlsComponent, LocalControlsComponent, PRESET_NAME, PreviewControlsComponent, REFRESH_OPTION, ROUTE_PATHS, RealtimeControlComponent, TIME_DURATION, TIME_INTERVAL, TIME_SPAN_MS, TIMING, TimeRangeDisplayComponent, UI_PRIORITIES, WIDGET_DISPLAY_MODE, WIDGET_FEATURE_MAP, WidgetConfigMigrationService, WidgetControlService, applyModeConstraints, buildAggregationExtensions, buildBaselineControls, buildWidgetControlsFromPresets, controlsToSettings, createAutoRefreshHandlers, createResult, defineWidgetControls, getSupportedModes, guards, isAggregationLinked, isAggregationUnlinked, isAutoRefreshDisabled, isAutoRefreshEnabled, isConfig, isDashboard, isDateTimeContextLinked, isDateTimeContextUnlinked, isHistory, isLive, isViewAndConfig, mergePartialControls, resolveWidgetControlsInput, setAutoRefreshControlsVisibility, setAutoRefreshLinks, updateBothSettings };
11835
+ export { AGGREGATIONS, AGGREGATION_ICONS, AGGREGATION_ICON_TYPE, AGGREGATION_LABELS, AGGREGATION_LIMITS, AGGREGATION_TEXTS, AGGREGATION_VALUES, AGGREGATION_VALUES_ARR, AggregationDisplayComponent, AggregationPickerComponent, AggregationPickerService, AggregationValidationService, AutoRefreshControlComponent, CONTEXT_FEATURE, CONTROL_PRESETS, ConfigContextSelectorComponent, ConfigModeControls, ConfigModeControls as ConfigModeControlsComponent, ConfigurationCollapseComponent, ConfigurationControlsComponent, ContextControlsComponent$1 as ContextControlsComponent, DEFAULT_WIDGET_TEMPLATE, DateContextQueryParamNames, DateTimeContextPickerComponent, DateTimeContextPickerService, DateTimeContextUtil, GLOBAL_CONTEXT_DEFAULTS, GLOBAL_CONTEXT_DISPLAY_MODE, GLOBAL_CONTEXT_EVENTS, GLOBAL_CONTEXT_SOURCE, GlobalContextComponent, GlobalContextConfigComponent, GlobalContextConnectorComponent, GlobalContextEventService, GlobalContextFormService, GlobalContextInlineComponent, GlobalContextLinkControlsComponent, GlobalContextModule, GlobalContextNavigationService, GlobalContextQueryService, GlobalContextService, GlobalContextUtilsService, GlobalContextValidationService, GlobalContextWidgetConfigComponent, GlobalContextWidgetWrapperComponent, HistoryModeConfigurationControlsComponent, INTERVALS, INTERVAL_TITLES, IntervalPickerComponent, LINK_BTNS_CONFIG, LinkButtonsComponent, LiveModeConfigurationControlsComponent, LocalControlsComponent, PRESET_NAME, PreviewControlsComponent, REFRESH_OPTION, ROUTE_PATHS, RealtimeControlComponent, TIME_DURATION, TIME_INTERVAL, TIME_SPAN_MS, TIMING, TimeRangeDisplayComponent, UI_PRIORITIES, WIDGET_DISPLAY_MODE, WIDGET_FEATURE_MAP, WidgetConfigMigrationService, WidgetControlService, applyModeConstraints, buildAggregationExtensions, buildBaselineControls, buildWidgetControlsFromPresets, controlsToSettings, createAutoRefreshHandlers, createResult, defineWidgetControls, getSupportedModes, guards, isAggregationLinked, isAggregationUnlinked, isAutoRefreshDisabled, isAutoRefreshEnabled, isConfig, isDashboard, isDateTimeContextLinked, isDateTimeContextUnlinked, isHistory, isLive, isViewAndConfig, mergePartialControls, resolveWidgetControlsInput, setAutoRefreshControlsVisibility, setAutoRefreshLinks, updateBothSettings };
11808
11836
  //# sourceMappingURL=c8y-ngx-components-global-context.mjs.map