UNPKG

@nova-ui/dashboards

Version:

Nova Dashboards is a framework designed to provide feature developers with a common solution for presenting data coming from various sources within a single view, as well as a set of predefined widget visualizations that are 100% configuration-driven and

837 lines (820 loc) 1.74 MB
import * as i4 from '@angular/common'; import { CommonModule, DecimalPipe, DOCUMENT } from '@angular/common'; import * as i0 from '@angular/core'; import { Component, HostBinding, Input, Pipe, NgModule, InjectionToken, Host, Self, Directive, Injectable, Inject, Optional, NgZone, Injector, EventEmitter, SimpleChange, Output, ViewChildren, ViewChild, ViewEncapsulation, SecurityContext, ChangeDetectionStrategy, HostListener, ElementRef, forwardRef, ViewContainerRef, ContentChildren } from '@angular/core'; import * as i2 from '@nova-ui/bits'; import { unitConversionBases, NuiImageModule, EventDefinition, immutableSet, EventBus, VirtualViewportManager, uuid, LoggerService, TimeframeService, ResizeObserverDirective, nameof, TableSelectionMode, DEFAULT_INTERACTIVE_ELEMENTS, SorterDirection, TableRowComponent, HistoryStorage, UnitBase, OverlayUtilitiesService, getOverlayPositions, SelectV2Component, NuiFormFieldControl, OVERLAY_CONTAINER, SpinnerSize, removeErrors, NuiBusyModule, NuiIconModule, NuiMenuModule, NuiPopupModule, NuiDialogModule, NuiSpinnerModule, NuiTextboxModule, NuiFormFieldModule, NuiButtonModule, NuiOverlayAdditionsModule, NuiSelectV2Module, NuiRadioModule, NuiCheckboxModule, NuiValidationMessageModule, NuiExpanderModule, NuiPanelModule, NuiDividerModule, NuiSwitchModule, NuiMessageModule, NuiWizardModule, NuiSorterModule, NuiSearchModule, NuiRepeatModule, NuiProgressModule, NuiTableModule, NuiTimeFrameBarModule, NuiTimeFramePickerModule, NuiTooltipModule, NuiCommonModule, NuiRiskScoreModule, NuiSelectModule, NuiPopoverModule, NuiPaginatorModule } from '@nova-ui/bits'; import * as i11 from '@angular/cdk/scrolling'; import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling'; import * as i1$2 from '@angular/forms'; import { Validators, NG_VALUE_ACCESSOR, FormGroupDirective, ControlContainer, FormGroup, FormArray, NG_VALIDATORS, FormControl, ReactiveFormsModule } from '@angular/forms'; import * as i1 from 'angular-gridster2'; import { CompactType, GridType, DisplayGrid, GridsterComponent, GridsterItemComponent, GridsterModule } from 'angular-gridster2'; import * as i4$1 from '@nova-ui/charts'; import { RadialAccessors, barAccessors, barScales, BarRenderer, BarSeriesHighlightStrategy, barGrid, radialScales, PieRenderer, radialGrid, radial, RadialRenderer, ChartPalette, defaultColorProvider, ChartAssist, Chart, ChartDonutContentPlugin, SELECT_DATA_POINT_EVENT, MappedValueProvider, SequentialColorProvider, TimeIntervalScale, LinearScale, TimeScale, SparkChartAssist, statusAccessors, BarHighlightStrategyOutline, BarHighlightStrategy, BandScale, StatusAccessors, TimeseriesZoomPlugin, ZoomPlugin, SET_DOMAIN_EVENT, DESTROY_EVENT, XYRenderer, XYAccessors, INTERACTION_DATA_POINTS_EVENT, InteractionType, INTERACTION_VALUES_EVENT, LineRenderer, LineAccessors, XYGridConfig, XYGrid, AreaRenderer, stackedAreaAccessors, areaGrid, stackedArea, InteractionLinePlugin, InteractionLabelPlugin, stack, stackedPercentageArea, getColorValueByName, CHART_PALETTE_CS3, CHART_PALETTE_CS_S_EXTENDED, TextColorProvider, NuiChartsModule } from '@nova-ui/charts'; import defaultsDeep from 'lodash/defaultsDeep'; import { BehaviorSubject, ReplaySubject, Subject, zip, merge, combineLatest, of, noop, EMPTY, Observable } from 'rxjs'; import { trigger, state, transition, style, animate } from '@angular/animations'; import set from 'lodash/set'; import isArray from 'lodash/isArray'; import some from 'lodash/some'; import union from 'lodash/union'; import omit from 'lodash/omit'; import * as i5 from '@angular/cdk/portal'; import { ComponentPortal, PortalModule } from '@angular/cdk/portal'; import values from 'lodash/values'; import xor from 'lodash/xor'; import { takeUntil, filter, distinctUntilChanged, tap, map, switchMap, startWith, debounceTime, distinctUntilKeyChanged, pluck, take, distinct, catchError } from 'rxjs/operators'; import isUndefined from 'lodash/isUndefined'; import { __decorate, __param, __metadata } from 'tslib'; import _isNil from 'lodash/isNil'; import isEmpty from 'lodash/isEmpty'; import uniq from 'lodash/uniq'; import get from 'lodash/get'; import clone from 'lodash/clone'; import pick from 'lodash/pick'; import _difference from 'lodash/difference'; import keyBy from 'lodash/keyBy'; import isEqual from 'lodash/isEqual'; import * as i1$1 from '@angular/platform-browser'; import moment, { duration } from 'moment/moment'; import cloneDeep from 'lodash/cloneDeep'; import * as d3 from 'd3'; import * as i5$1 from '@angular/cdk/drag-drop'; import { DragDropModule } from '@angular/cdk/drag-drop'; import * as i2$1 from '@angular/cdk/overlay'; import sumBy from 'lodash/sumBy'; import toNumber from 'lodash/toNumber'; import toString from 'lodash/toString'; import find from 'lodash/find'; import findIndex from 'lodash/findIndex'; import zipObject from 'lodash/zipObject'; import { Subject as Subject$1 } from 'rxjs/internal/Subject'; import includes from 'lodash/includes'; import capitalize from 'lodash/capitalize'; import * as i3 from '@angular/router'; import { NavigationEnd } from '@angular/router'; import isFunction from 'lodash/isFunction'; import sum from 'lodash/sum'; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. class PreviewOverlayComponent { static { this.lateLoadKey = "PreviewOverlayComponent"; } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreviewOverlayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: PreviewOverlayComponent, selector: "nui-preview-overlay", ngImport: i0, template: `<div class="nui-text-label content" i18n> This is a non-interactive widget preview </div>`, isInline: true, styles: [":host{opacity:0;transition-property:opacity;transition-duration:.5s;position:absolute;z-index:1060;background-color:var(--nui-color-bg-content_popover,#fff);height:100%;width:100%}:host:hover{opacity:.96}:host .content{padding:10px;display:flex;justify-content:center;align-items:center;position:absolute;inset:0 2px 2px;cursor:not-allowed}\n"] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreviewOverlayComponent, decorators: [{ type: Component, args: [{ selector: "nui-preview-overlay", template: `<div class="nui-text-label content" i18n> This is a non-interactive widget preview </div>`, styles: [":host{opacity:0;transition-property:opacity;transition-duration:.5s;position:absolute;z-index:1060;background-color:var(--nui-color-bg-content_popover,#fff);height:100%;width:100%}:host:hover{opacity:.96}:host .content{padding:10px;display:flex;justify-content:center;align-items:center;position:absolute;inset:0 2px 2px;cursor:not-allowed}\n"] }] }] }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. class WidgetErrorComponent { static { this.lateLoadKey = "WidgetErrorComponent"; } constructor(changeDetector) { this.changeDetector = changeDetector; this.defaultClasses = "d-flex flex-column justify-content-center w-100 p-3"; /** * Optional class for styling */ this.elementClass = ""; } ngOnInit() { this.classNames = `${this.defaultClasses} ${this.elementClass}`; } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetErrorComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); } /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: WidgetErrorComponent, selector: "nui-widget-error", inputs: { image: "image", title: "title", description: "description", elementClass: "elementClass" }, host: { properties: { "class": "this.classNames" } }, ngImport: i0, template: "<nui-image [image]=\"image\"></nui-image>\n<div class=\"widget-error__title\">\n <strong>{{ title }}</strong>\n</div>\n<div class=\"d-flex justify-content-center text-center\">{{ description }}</div>\n", styles: [".widget-error__title{display:flex;justify-content:center;text-align:center;margin-top:20px;margin-bottom:10px}\n"], dependencies: [{ kind: "component", type: i2.ImageComponent, selector: "nui-image", inputs: ["image", "description", "float", "margin", "isWatermark", "width", "height", "autoFill"] }] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetErrorComponent, decorators: [{ type: Component, args: [{ selector: "nui-widget-error", template: "<nui-image [image]=\"image\"></nui-image>\n<div class=\"widget-error__title\">\n <strong>{{ title }}</strong>\n</div>\n<div class=\"d-flex justify-content-center text-center\">{{ description }}</div>\n", styles: [".widget-error__title{display:flex;justify-content:center;text-align:center;margin-top:20px;margin-bottom:10px}\n"] }] }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { image: [{ type: Input }], title: [{ type: Input }], description: [{ type: Input }], elementClass: [{ type: Input }], classNames: [{ type: HostBinding, args: ["class"] }] } }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** The default threshold at which unit conversion goes into effect */ const DEFAULT_UNIT_CONVERSION_THRESHOLD = 1000000; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** * Pipe for transforming large values to their abbreviated counterparts. * Conversions are applied for values 10000 or greater */ class DashboardUnitConversionPipe { constructor(unitConversionService) { this.unitConversionService = unitConversionService; /** * Transforms a large number value to its abbreviated counterpart * * @param value The value to convert * * @returns The string representation of the converted value */ this.transform = (value, units = "generic", defaultThreshold = DEFAULT_UNIT_CONVERSION_THRESHOLD) => { const valueAsNumber = typeof value === "string" ? parseFloat(value) : value; if (valueAsNumber === undefined || isNaN(valueAsNumber) || (valueAsNumber < defaultThreshold && units !== "percent" && units !== "milliseconds")) { return value?.toString() || ""; } const conversion = this.unitConversionService.convert(valueAsNumber, unitConversionBases[units], 1); return this.unitConversionService.getFullDisplay(conversion, units); }; } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DashboardUnitConversionPipe, deps: [{ token: i2.UnitConversionService }], target: i0.ɵɵFactoryTarget.Pipe }); } /** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: DashboardUnitConversionPipe, name: "nuiDashboardUnitConversion" }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DashboardUnitConversionPipe, decorators: [{ type: Pipe, args: [{ name: "nuiDashboardUnitConversion" }] }], ctorParameters: () => [{ type: i2.UnitConversionService }] }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. const commonComponents = [PreviewOverlayComponent, WidgetErrorComponent]; class NuiDashboardsCommonModule { /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NuiDashboardsCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: NuiDashboardsCommonModule, declarations: [DashboardUnitConversionPipe, PreviewOverlayComponent, WidgetErrorComponent], imports: [CommonModule, NuiImageModule], exports: [CommonModule, DashboardUnitConversionPipe, PreviewOverlayComponent, WidgetErrorComponent] }); } /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NuiDashboardsCommonModule, imports: [CommonModule, NuiImageModule, CommonModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NuiDashboardsCommonModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, NuiImageModule], declarations: [DashboardUnitConversionPipe, ...commonComponents], exports: [CommonModule, DashboardUnitConversionPipe, ...commonComponents], }] }] }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. const DEFAULT_GRIDSTER_CONFIG = { displayGrid: DisplayGrid.None, gridType: GridType.VerticalFixed, compactType: CompactType.CompactUp, margin: 15, outerMargin: true, outerMarginTop: null, outerMarginRight: null, outerMarginBottom: null, outerMarginLeft: null, mobileBreakpoint: 640, minCols: 12, maxCols: 12, minRows: 12, fixedRowHeight: 44, minItemArea: 1, defaultItemCols: 6, defaultItemRows: 6, keepFixedHeightInMobile: false, keepFixedWidthInMobile: false, scrollSensitivity: 10, scrollSpeed: 20, enableEmptyCellClick: false, enableEmptyCellContextMenu: false, enableEmptyCellDrop: false, enableEmptyCellDrag: false, emptyCellDragMaxCols: 50, emptyCellDragMaxRows: 50, ignoreMarginInRow: false, draggable: { enabled: false, ignoreContent: true, dragHandleClass: "nui-dashboard__widget--drag-handle", }, resizable: { enabled: false, handles: { s: true, e: true, n: true, w: true, se: true, ne: true, sw: true, nw: true, }, }, swap: false, pushItems: true, pushResizeItems: true, disablePushOnDrag: false, disablePushOnResize: false, pushDirections: { north: true, east: true, south: true, west: true }, disableWindowResize: false, disableWarnings: false, scrollToNewItems: false, }; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. const DEFAULT_PIZZAGNA_ROOT = "/"; const REFRESH = new EventDefinition("REFRESH"); const SET_NEXT_PAGE = new EventDefinition("SET_NEXT_PAGE"); const SCROLL_NEXT_PAGE = new EventDefinition("SCROLL_NEXT_PAGE"); const WIDGET_REMOVE = new EventDefinition("WIDGET_REMOVE"); const WIDGET_EDIT = new EventDefinition("WIDGET_EDIT"); const WIDGET_CREATE = new EventDefinition("WIDGET_CREATE"); const WIDGET_READY = new EventDefinition("WIDGET_READY"); const WIDGET_RESIZE = new EventDefinition("WIDGET_RESIZE"); const WIDGET_POSITION_CHANGE = new EventDefinition("WIDGET_POSITION_CHANGE"); const WIDGET_SEARCH = new EventDefinition("WIDGET_SEARCH", () => new BehaviorSubject({ payload: "" })); const SET_PROPERTY_VALUE = new EventDefinition("SET_PROPERTY_VALUE"); const SET_TIMEFRAME = new EventDefinition("SET_TIMEFRAME"); const PREVIEW_EVENT = new EventDefinition("PREVIEW_EVENT"); const DATA_SOURCE_BUSY = new EventDefinition("DATA_SOURCE_BUSY"); const DASHBOARD_EDIT_MODE = new EventDefinition("DASHBOARD_EDIT_MODE", () => new ReplaySubject(1)); const INTERACTION = new EventDefinition("INTERACTION"); const SELECTION = new EventDefinition("SELECTION"); const CHANGE_SELECTION = new EventDefinition("CHANGE_SELECTION"); const SELECTED_ITEMS = new EventDefinition("SELECTED_ITEMS"); const DATA_SOURCE_INVOKED = new EventDefinition("DATA_SOURCE_INVOKED"); const DRILLDOWN = new EventDefinition("DRILLDOWN"); const NOVA_DATASOURCE_INTERVAL_REFRESHER = "NOVA_DATASOURCE_INTERVAL_REFRESHER"; const NOVA_DATASOURCE_ADAPTER = "NOVA_DATASOURCE_ADAPTER"; const NOVA_TIMESERIES_DATASOURCE_ADAPTER = "NOVA_TIMESERIES_DATASOURCE_ADAPTER"; const NOVA_KPI_DATASOURCE_ADAPTER = "NOVA_KPI_DATASOURCE_ADAPTER"; const NOVA_DRILLDOWN_DATASOURCE_ADAPTER = "NOVA_DRILLDOWN_DATASOURCE_ADAPTER"; const NOVA_KPI_COLOR_PRIORITIZER = "NOVA_KPI_COLOR_PRIORITIZER"; const NOVA_TITLE_AND_DESCRIPTION_CONVERTER = "NOVA_TITLE_AND_DESCRIPTION_CONVERTER"; const NOVA_PROPORTIONAL_WIDGET_CHART_OPTIONS_CONVERTER = "NOVA_PROPORTIONAL_WIDGET_CHART_OPTIONS_CONVERTER"; const NOVA_KPI_TILES_CONVERTER = "NOVA_KPI_TILES_CONVERTER"; const NOVA_TIMESERIES_METADATA_CONVERTER = "NOVA_TIMESERIES_METADATA_CONVERTER"; const NOVA_TIMESERIES_SERIES_CONVERTER = "NOVA_TIMESERIES_SERIES_CONVERTER"; const NOVA_DASHBOARD_EVENT_PROXY = "NOVA_DASHBOARD_EVENT_PROXY"; const NOVA_TABLE_COLUMNS_CONVERTER = "NOVA_TABLE_COLUMNS_CONVERTER"; const NOVA_TABLE_FILTERS_CONVERTER = "NOVA_TABLE_FILTERS_CONVERTER"; const NOVA_TABLE_SCROLL_TYPE_CONVERTER = "NOVA_TABLE_SCROLL_TYPE_CONVERTER"; const NOVA_TABLE_DATASOURCE_ADAPTER = "NOVA_TABLE_DATASOURCE_ADAPTER"; const NOVA_GENERIC_CONVERTER = "NOVA_GENERIC_CONVERTER"; const NOVA_GENERIC_ARRAY_CONVERTER = "NOVA_GENERIC_ARRAY_CONVERTER"; const NOVA_KPI_SECTION_CONVERTER = "NOVA_KPI_SECTION_CONVERTER"; const NOVA_TIMESERIES_TILE_INDICATOR_DATA_CONVERTER = "NOVA_TIMESERIES_TILE_INDICATOR_DATA_CONVERTER"; const NOVA_LOADING_ADAPTER = "NOVA_LOADING_ADAPTER"; const NOVA_STATUS_CONTENT_FALLBACK_ADAPTER = "NOVA_STATUS_CONTENT_FALLBACK_ADAPTER"; const NOVA_KPI_STATUS_CONTENT_FALLBACK_ADAPTER = "NOVA_KPI_STATUS_CONTENT_FALLBACK_ADAPTER"; const NOVA_KPI_SCALE_SYNC_BROKER = "NOVA_KPI_SCALE_SYNC_BROKER"; const NOVA_URL_INTERACTION_HANDLER = "NOVA_URL_INTERACTION_HANDLER"; const NOVA_EVENT_BUS_DEBUGGER = "NOVA_EVENT_BUS_DEBUGGER"; const NOVA_PIZZAGNA_BROADCASTER = "NOVA_PIZZAGNA_BROADCASTER"; const NOVA_VIRTUAL_VIEWPORT_MANAGER = "NOVA_VIRTUAL_VIEWPORT_MANAGER"; const NOVA_TABLE_FORMATTERS_REGISTRY = "NOVA_TABLE_FORMATTERS_REGISTRY"; const NOVA_KPI_FORMATTERS_REGISTRY = "NOVA_KPI_FORMATTERS_REGISTRY"; const NOVA_RISK_SCORE_FORMATTERS_REGISTRY = "NOVA_RISK_SCORE_FORMATTERS_REGISTRY"; const NOVA_PROPORTIONAL_CONTENT_FORMATTERS_REGISTRY = "NOVA_PROPORTIONAL_CONTENT_FORMATTERS_REGISTRY"; const NOVA_TEST_REGISTRY = "NOVA_TEST_REGISTRY"; const NOVA_CONFIGURATOR_DATA_SOURCE_MANAGER = "NOVA_CONFIGURATOR_DATA_SOURCE_MANAGER"; const CHART_METRIC_REMOVE = { id: "CHART_METRIC_REMOVE", }; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. const PIZZAGNA_EVENT_BUS = new InjectionToken("PIZZAGNA_EVENT_BUS"); const DASHBOARD_EVENT_BUS = new InjectionToken("DASHBOARD_EVENT_BUS"); const DATA_SOURCE = new InjectionToken("DATA_SOURCE"); const FORMATTERS_REGISTRY = new InjectionToken("FORMATTERS_REGISTRY"); const TEST_REGISTRY = new InjectionToken("TEST_REGISTRY"); const HEADER_LINK_PROVIDER = new InjectionToken("HEADER_LINK_PROVIDER"); var WellKnownProviders; (function (WellKnownProviders) { WellKnownProviders["DataSource"] = "dataSource"; WellKnownProviders["Adapter"] = "adapter"; WellKnownProviders["Converter"] = "converter"; WellKnownProviders["Broadcaster"] = "broadcaster"; WellKnownProviders["Refresher"] = "refresher"; WellKnownProviders["EventProxy"] = "eventProxy"; WellKnownProviders["LoadingAdapter"] = "loadingAdapter"; WellKnownProviders["ContentFallbackAdapter"] = "contentFallbackAdapter"; WellKnownProviders["InteractionHandler"] = "interactionHandler"; WellKnownProviders["EventBusDebugger"] = "eventBusDebugger"; WellKnownProviders["KpiColorPrioritizer"] = "kpiColorPrioritizer"; WellKnownProviders["FormattersRegistry"] = "formattersRegistry"; WellKnownProviders["DataSourceManager"] = "dataSourceManager"; })(WellKnownProviders || (WellKnownProviders = {})); var WellKnownPathKey; (function (WellKnownPathKey) { WellKnownPathKey["Root"] = "root"; WellKnownPathKey["DataSourceConfigComponentType"] = "dataSourceConfigComponentType"; WellKnownPathKey["TileDescriptionConfigComponentType"] = "tileDescriptionConfigComponentType"; WellKnownPathKey["DataSourceProviders"] = "dataSourceProviders"; WellKnownPathKey["Formatters"] = "formatters"; WellKnownPathKey["TileDescriptionBackgroundColors"] = "tileDescriptionBackgroundColors"; WellKnownPathKey["TileBackgroundColorRulesBackgroundColors"] = "tileBackgroundColorRulesBackgroundColors"; })(WellKnownPathKey || (WellKnownPathKey = {})); var WellKnownDataSourceFeatures; (function (WellKnownDataSourceFeatures) { WellKnownDataSourceFeatures["Interactivity"] = "interactivity"; WellKnownDataSourceFeatures["DisableTableColumnGeneration"] = "disableTableColumnGeneration"; })(WellKnownDataSourceFeatures || (WellKnownDataSourceFeatures = {})); var PizzagnaLayer; (function (PizzagnaLayer) { PizzagnaLayer["Structure"] = "structure"; PizzagnaLayer["Configuration"] = "configuration"; PizzagnaLayer["Data"] = "data"; })(PizzagnaLayer || (PizzagnaLayer = {})); var AccordionState; (function (AccordionState) { AccordionState["CRITICAL"] = "critical"; AccordionState["WARNING"] = "warning"; AccordionState["DEFAULT"] = "default"; })(AccordionState || (AccordionState = {})); var HttpStatusCode; (function (HttpStatusCode) { HttpStatusCode["Unknown"] = "0"; HttpStatusCode["Ok"] = "200"; HttpStatusCode["Forbidden"] = "403"; HttpStatusCode["NotFound"] = "404"; })(HttpStatusCode || (HttpStatusCode = {})); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** * This directive assigns a "widgetId" property to host gridster item. We need it there because moving and resizing the widget with gridster only contains * gridster position data and gridster component payload, so we need to identify which widget that event belongs to. */ class GridsterItemWidgetIdDirective { constructor(gridsterItem) { this.gridsterItem = gridsterItem; } ngOnChanges(changes) { if (changes.nuiGridsterItemWidgetId) { this.gridsterItem.widgetId = this.nuiGridsterItemWidgetId; } } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GridsterItemWidgetIdDirective, deps: [{ token: i1.GridsterItemComponent, host: true, self: true }], target: i0.ɵɵFactoryTarget.Directive }); } /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: GridsterItemWidgetIdDirective, selector: "[nuiGridsterItemWidgetId]", inputs: { nuiGridsterItemWidgetId: "nuiGridsterItemWidgetId" }, usesOnChanges: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GridsterItemWidgetIdDirective, decorators: [{ type: Directive, args: [{ selector: "[nuiGridsterItemWidgetId]", }] }], ctorParameters: () => [{ type: i1.GridsterItemComponent, decorators: [{ type: Host }, { type: Self }] }], propDecorators: { nuiGridsterItemWidgetId: [{ type: Input }] } }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. class LoadingComponent { static { this.lateLoadKey = "LoadingComponent"; } constructor(changeDetector) { this.changeDetector = changeDetector; this.active = false; } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoadingComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); } /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: LoadingComponent, selector: "nui-loading", inputs: { active: "active" }, ngImport: i0, template: "<nui-progress\n [@animate]=\"active\"\n (@animate.start)=\"$event.element.style.display = 'block'\"\n (@animate.done)=\"\n $event.element.style.display = $event.toState ? 'block' : 'none'\n \"\n [show]=\"true\"\n compactMode=\"true\"\n>\n</nui-progress>\n", styles: [":host{height:5px;flex-shrink:0}\n"], dependencies: [{ kind: "component", type: i2.ProgressComponent, selector: "nui-progress", inputs: ["show", "showProgress", "message", "showNumber", "percent", "allowCancel", "cancelText", "helpText", "stacked", "compactMode", "ariaLabel", "helpTemplateRef"], outputs: ["cancel"] }], animations: [ trigger("animate", [ state("true", style({ opacity: 1 })), state("false", style({ opacity: 0 })), transition("false <=> true", animate(500)), ]), ] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoadingComponent, decorators: [{ type: Component, args: [{ selector: "nui-loading", animations: [ trigger("animate", [ state("true", style({ opacity: 1 })), state("false", style({ opacity: 0 })), transition("false <=> true", animate(500)), ]), ], template: "<nui-progress\n [@animate]=\"active\"\n (@animate.start)=\"$event.element.style.display = 'block'\"\n (@animate.done)=\"\n $event.element.style.display = $event.toState ? 'block' : 'none'\n \"\n [show]=\"true\"\n compactMode=\"true\"\n>\n</nui-progress>\n", styles: [":host{height:5px;flex-shrink:0}\n"] }] }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { active: [{ type: Input }] } }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. class WidgetConfigurationService { updateWidget(widget) { this.widget = widget; } getWidget() { return this.widget; } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetConfigurationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetConfigurationService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetConfigurationService, decorators: [{ type: Injectable }] }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. class WidgetTypesService { constructor() { this.widgetTypes = {}; } registerWidgetType(key, version, widgetType) { let widgetTypeVersions = this.widgetTypes[key]; if (!widgetTypeVersions) { widgetTypeVersions = []; this.widgetTypes[key] = widgetTypeVersions; } if (widgetTypeVersions.length < version) { widgetTypeVersions.length = version; } widgetTypeVersions[version - 1] = widgetType; } getWidgetType(type, version) { const widgetTypeVersions = this.widgetTypes[type]; if (!widgetTypeVersions || widgetTypeVersions.length === 0) { throw new Error("Type '" + type + "' not found in the registry. Available types: " + Object.keys(this.widgetTypes).join(", ")); } if (typeof version !== "undefined" && (version <= 0 || widgetTypeVersions.length < version)) { throw new Error("Version " + version + " for widget type '" + type + "' not registered. Max available version is " + widgetTypeVersions.length); } const adjustedVersion = typeof version === "undefined" ? widgetTypeVersions.length : version; return widgetTypeVersions[adjustedVersion - 1]; } /** * Take a widget and merge it with the pizzagna of its type * * @param widget * * @return new reference of a widget including the pizzagna of its type */ mergeWithWidgetType(widget) { const widgetType = this.getWidgetType(widget.type, widget.version); return { ...widget, pizzagna: defaultsDeep(widget.pizzagna, widgetType.widget), }; } setNode(widgetTemplate, section, pathKey, value) { const widgetSection = `${section}.${PizzagnaLayer.Structure}`; const itemPath = `${widgetTemplate.paths?.[section]?.[pathKey] || pathKey}`; const path = `${widgetSection}.${itemPath}`; set(widgetTemplate, path, value); } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetTypesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetTypesService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetTypesService, decorators: [{ type: Injectable }], ctorParameters: () => [] }); // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** * This function takes a source object with a prioritized list of changes. Goes through and detects the changes on every one of these structures and builds * a new object that respects immutability and updates object references only where necessary. This is used to merge lasagna overlays into a component state * that maintains its immutability and high performance of change detection. * * @param result * @param changes */ function mergeChanges(result, ...changes) { const validChanges = changes.filter((c) => typeof c.previousValue !== "undefined" || typeof c.currentValue !== "undefined"); // there were no changes in the provided values, so just return the input object if (!some(validChanges, (c) => c.currentValue !== c.previousValue)) { return result; } // if there is only one layer of change just return the currentValue to preserve references if (validChanges.length === 1) { return validChanges[0].currentValue; } // first we need to determine the value type const valueType = findType(validChanges); // if it's a primitive type or an array, then we don't go further and we take a new value with the highest priority if (!["object", "object[]"].includes(valueType)) { // we take the value with the last priority return takeHighestPriorityValue(validChanges); } // collect all the keys of all the objects in given changes const keys = union(...validChanges.map((c) => typeof c.currentValue === "object" ? Object.keys(c.currentValue || {}) : [])); const accTemplate = valueType === "object[]" ? [] : {}; const ret = keys.reduce((acc, key) => { const checkedResult = typeof result === "undefined" || result === null || typeof result[key] === "undefined" ? undefined : result[key]; const nestedChanges = validChanges.map((c) => ({ previousValue: typeof c.previousValue === "undefined" || c.previousValue == null ? undefined : c.previousValue[key], currentValue: typeof c.currentValue === "undefined" || c.currentValue == null ? undefined : c.currentValue[key], })); // recursively execute this method for given property acc[key] = mergeChanges(checkedResult, ...nestedChanges); return acc; }, accTemplate); return ret; } /** * Take current value from given changes with highest priority - the last one wins * * @param changes */ function takeHighestPriorityValue(changes) { for (let i = changes.length - 1; i >= 0; i--) { const value = changes[i].currentValue; if (typeof value !== "undefined") { return value; }