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

164 lines 7.08 kB
"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.TimeseriesInspectionMenuComponent = exports.TIMESERIES_INSPECTION_MENU_CLEAR = exports.TIMESERIES_INSPECTION_MENU_SYNCHRONIZE = exports.TIMESERIES_INSPECTION_MENU_CLOSE = exports.TIMESERIES_INSPECTION_MENU_EXPLORE = exports.TIMESERIES_INSPECTION_MENU_ZOOM_OUT = exports.TIMESERIES_INSPECTION_MENU_ZOOM_IN = void 0; const tslib_1 = require("tslib"); const core_1 = require("@angular/core"); const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const bits_1 = require("@nova-ui/bits"); const charts_1 = require("@nova-ui/charts"); const types_1 = require("../../../types"); exports.TIMESERIES_INSPECTION_MENU_ZOOM_IN = { id: "TIMESERIES_INSPECTION_MENU_ZOOM_IN", }; exports.TIMESERIES_INSPECTION_MENU_ZOOM_OUT = { id: "TIMESERIES_INSPECTION_MENU_ZOOM_OUT", }; exports.TIMESERIES_INSPECTION_MENU_EXPLORE = { id: "TIMESERIES_INSPECTION_MENU_EXPLORE", }; exports.TIMESERIES_INSPECTION_MENU_CLOSE = { id: "TIMESERIES_INSPECTION_MENU_CLOSE", }; exports.TIMESERIES_INSPECTION_MENU_SYNCHRONIZE = { id: "TIMESERIES_INSPECTION_MENU_SYNCHRONIZE", }; exports.TIMESERIES_INSPECTION_MENU_CLEAR = { id: "TIMESERIES_INSPECTION_MENU_CLEAR", }; let TimeseriesInspectionMenuComponent = class TimeseriesInspectionMenuComponent { constructor(element, eventBus, syncService) { this.element = element; this.eventBus = eventBus; this.syncService = syncService; this.exploringEnabled = false; this.allowed = false; this.offset = 38; this.destroy$ = new rxjs_1.Subject(); } ngOnInit() { this.plugin.zoomCreated$.subscribe(() => this.explore(false)); this.eventBus .getStream(exports.TIMESERIES_INSPECTION_MENU_SYNCHRONIZE) .subscribe(() => { const { startDate, endDate } = this.plugin.getInspectionFrame(); if (startDate && endDate) { this.syncService.syncPositionInsideCollection(this.collectionId ?? "", startDate, endDate); } }); this.eventBus .getStream(exports.TIMESERIES_INSPECTION_MENU_CLEAR) .subscribe(() => this.clearZoom()); this.plugin?.openPopover$ .pipe((0, operators_1.takeUntil)(this.destroy$)) .subscribe((x) => { // moves element to the correct position this.element.nativeElement.style.left = this.offset + x + "px"; }); } ngOnChanges(changes) { if (changes.allowed?.currentValue) { this.plugin.showPopover(); } else { this.plugin.closePopover(); } } ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); } clearZoom() { this.syncService.clearZoomInsideCollection(this.collectionId ?? ""); this.eventBus.next(exports.TIMESERIES_INSPECTION_MENU_CLOSE, {}); } isZoomInAllowed() { const { startDate, endDate } = this.plugin.getInspectionFrame(); if (!startDate || !endDate) { return true; } // doesn't allow zoom for timeframe smaller than 10 minutes return endDate.diff(startDate, "minutes") > 10; } zoomIn() { const inspectionTimeframe = this.plugin.getInspectionFrame(); this.eventBus.next(exports.TIMESERIES_INSPECTION_MENU_ZOOM_IN, { payload: inspectionTimeframe, }); this.syncService.clearZoomInsideCollection(this.collectionId ?? ""); } zoomOut() { const inspectionTimeframe = this.plugin.getInspectionFrame(); this.eventBus.next(exports.TIMESERIES_INSPECTION_MENU_ZOOM_OUT, { payload: inspectionTimeframe, }); setTimeout(() => { this.plugin.closePopover(); }); } explore(openSidePanel = false) { const inspectionTimeframe = this.plugin.getInspectionFrame(); this.eventBus.next(exports.TIMESERIES_INSPECTION_MENU_EXPLORE, { payload: { ids: this.metricIds, startDate: inspectionTimeframe.startDate, endDate: inspectionTimeframe.endDate, openSidePanel, exploringEnabled: this.exploringEnabled, }, }); } }; exports.TimeseriesInspectionMenuComponent = TimeseriesInspectionMenuComponent; tslib_1.__decorate([ (0, core_1.Input)(), tslib_1.__metadata("design:type", charts_1.TimeseriesZoomPlugin) ], TimeseriesInspectionMenuComponent.prototype, "plugin", void 0); tslib_1.__decorate([ (0, core_1.Input)(), tslib_1.__metadata("design:type", Object) ], TimeseriesInspectionMenuComponent.prototype, "exploringEnabled", void 0); tslib_1.__decorate([ (0, core_1.Input)(), tslib_1.__metadata("design:type", String) ], TimeseriesInspectionMenuComponent.prototype, "metricIds", void 0); tslib_1.__decorate([ (0, core_1.Input)(), tslib_1.__metadata("design:type", String) ], TimeseriesInspectionMenuComponent.prototype, "collectionId", void 0); tslib_1.__decorate([ (0, core_1.Input)(), tslib_1.__metadata("design:type", Boolean) ], TimeseriesInspectionMenuComponent.prototype, "allowed", void 0); exports.TimeseriesInspectionMenuComponent = TimeseriesInspectionMenuComponent = tslib_1.__decorate([ (0, core_1.Component)({ selector: "nui-timeseries-inspection-menu", templateUrl: "./timeseries-inspection-menu.component.html", styleUrls: ["./timeseries-inspection-menu.component.less"], standalone: false, }), tslib_1.__param(1, (0, core_1.Inject)(types_1.PIZZAGNA_EVENT_BUS)), tslib_1.__metadata("design:paramtypes", [core_1.ElementRef, bits_1.EventBus, charts_1.TimeseriesZoomPluginsSyncService]) ], TimeseriesInspectionMenuComponent); //# sourceMappingURL=timeseries-inspection-menu.component.js.map