@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
118 lines • 5.64 kB
JavaScript
"use strict";
// © 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeseriesWidgetComponent = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@angular/core");
const charts_1 = require("@nova-ui/charts");
const timeseries_chart_preset_service_1 = require("./timeseries-chart-preset.service");
const types_1 = require("./types");
/** @ignore */
let TimeseriesWidgetComponent = class TimeseriesWidgetComponent {
static { this.lateLoadKey = "TimeseriesWidgetComponent"; }
constructor(timeseriesChartPresetService, changeDetector, zoomPluginsSyncService) {
this.timeseriesChartPresetService = timeseriesChartPresetService;
this.changeDetector = changeDetector;
this.zoomPluginsSyncService = zoomPluginsSyncService;
this.elementClass = "";
this.zoomPlugins = [];
this.allowPopover = false;
this.timeseriesWidgetProjectType = types_1.TimeseriesWidgetProjectType;
}
ngOnInit() {
if (this.configuration?.projectType ===
types_1.TimeseriesWidgetProjectType.PerfstackApp) {
if (this.configuration.type === types_1.TimeseriesChartTypes.alert) {
// adds timeseries zoom plugin for each subcharts to make the synchronization working for the alert chart
this.widgetData?.series.forEach(() => this.zoomPlugins.push(this.getTimeseriesZoomPlugin()));
// doesn't add zoom plugin for a summary serie when there are no sub charts and only sumary serie will be displayed
if (!(this.widgetData?.series.length === 1 &&
this.widgetData.series[0].id ===
this.widgetData.summarySerie?.id)) {
this.zoomPlugins.push(this.getTimeseriesZoomPlugin());
}
}
else {
this.zoomPlugins.push(this.getTimeseriesZoomPlugin());
}
}
else {
this.zoomPlugins.push(new charts_1.ZoomPlugin());
}
}
getTimeseriesZoomPlugin() {
return new charts_1.TimeseriesZoomPlugin({ collectionId: this.collectionId }, this.zoomPluginsSyncService);
}
ngOnChanges(changes) {
if (changes.configuration) {
const configurationCurrent = changes.configuration.currentValue;
const configurationPrevious = changes.configuration.previousValue;
if (configurationCurrent?.preset !== configurationPrevious?.preset) {
this.chartPreset =
this.timeseriesChartPresetService.presets[this.configuration?.preset ?? types_1.TimeseriesChartPreset.Line];
}
}
}
/** Checks if chart should be shown. */
shouldShowChart() {
return (this.widgetData?.series?.length ?? 0) > 0;
}
toggleLeave() {
this.allowPopover = false;
}
toggleEnter() {
this.allowPopover = true;
}
isExploringEnabled() {
return (this.configuration?.type !== types_1.TimeseriesChartTypes.line &&
this.configuration?.type !== types_1.TimeseriesChartTypes.multi &&
this.configuration?.type !== types_1.TimeseriesChartTypes.status);
}
};
exports.TimeseriesWidgetComponent = TimeseriesWidgetComponent;
tslib_1.__decorate([
(0, core_1.Input)(),
tslib_1.__metadata("design:type", Object)
], TimeseriesWidgetComponent.prototype, "widgetData", void 0);
tslib_1.__decorate([
(0, core_1.Input)(),
tslib_1.__metadata("design:type", Object)
], TimeseriesWidgetComponent.prototype, "configuration", void 0);
tslib_1.__decorate([
(0, core_1.Input)(),
tslib_1.__metadata("design:type", String)
], TimeseriesWidgetComponent.prototype, "collectionId", void 0);
tslib_1.__decorate([
(0, core_1.Input)(),
(0, core_1.HostBinding)("class"),
tslib_1.__metadata("design:type", Object)
], TimeseriesWidgetComponent.prototype, "elementClass", void 0);
exports.TimeseriesWidgetComponent = TimeseriesWidgetComponent = tslib_1.__decorate([
(0, core_1.Component)({
selector: "nui-timeseries-widget",
styleUrls: ["./timeseries-widget.component.less"],
templateUrl: "./timeseries-widget.component.html",
}),
tslib_1.__metadata("design:paramtypes", [timeseries_chart_preset_service_1.TimeseriesChartPresetService,
core_1.ChangeDetectorRef,
charts_1.TimeseriesZoomPluginsSyncService])
], TimeseriesWidgetComponent);
//# sourceMappingURL=timeseries-widget.component.js.map