UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

419 lines (401 loc) 21 kB
import * as i0 from '@angular/core'; import { OnInit, OnDestroy, EventEmitter, PipeTransform } from '@angular/core'; import { AbstractControl, ValidationErrors, FormGroup, FormControl, ControlValueAccessor, Validator, FormBuilder, FormArray } from '@angular/forms'; import { IIdentified, AlarmService, EventService, IAlarm, IEvent } from '@c8y/client'; import { KPIDetails } from '@c8y/ngx-components/datapoint-selector'; import * as i2 from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import * as i1 from '@c8y/ngx-components'; import { ColorService, EmptyStateComponent, ContextRouteService } from '@c8y/ngx-components'; import { WidgetConfigComponent, WidgetConfigService } from '@c8y/ngx-components/context-dashboard'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import * as i7 from '@angular/router'; import { ActivatedRoute } from '@angular/router'; import { Observable, BehaviorSubject } from 'rxjs'; import * as i5 from '@c8y/ngx-components/assets-navigator'; import { AssetSelectionChangeEvent } from '@c8y/ngx-components/assets-navigator'; import * as i3 from 'ngx-bootstrap/popover'; import * as i4 from 'ngx-bootstrap/tooltip'; import * as i6 from 'ngx-bootstrap/collapse'; type TimelineType = 'ALARM' | 'EVENT'; type AlarmOrEventBase = { timelineType: TimelineType; color: string; __active?: boolean; label: string; filters: { type: string; }; __target: IIdentified; }; type AlarmDetails = AlarmOrEventBase & { timelineType: 'ALARM'; filters: { type: string; }; selectedDatapoint?: SelectedDatapoint; }; type EventDetails = AlarmOrEventBase & { timelineType: 'EVENT'; filters: { type: string; }; selectedDatapoint?: SelectedDatapoint; }; type SelectedDatapoint = { target?: string; series?: string; fragment?: string; }; type AlarmOrEvent = AlarmDetails | EventDetails; type TimelineTypeTexts = { listTitle: string; emptyStateIcon: string; emptyStateTitle: string; emptyStateSubtitle: string; addButtonLabel: string; addCustomItemButtonLabel: string; selectorTitle: string; availableItemsTitle: string; assetWithNoItemsEmptyStateSubtitle: string; largeNumberOfItemsInfo: string; selectedItemsTitle: string; noSelectedItemsTitle: string; recentItemsWarningTitle: string; recentItemsWarningText: string; addCustomText: string; }; declare const EVENT_TEXTS: TimelineTypeTexts; declare const ALARM_TEXTS: TimelineTypeTexts; /** * The configuration for the alarms-events selector modal if some properties should be omitted. */ type OmitSelectorProperties = { color?: boolean; label?: boolean; }; type ConfigStoreMode = 'ISOLATED' | 'MIXED'; declare class AlarmEventAttributesFormService { duplicateTypeValidator(selectedItems: AlarmOrEvent[]): (control: AbstractControl) => ValidationErrors | null; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventAttributesFormService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmEventAttributesFormService>; } interface AlarmEventAttributeForm { filters: FormGroup<{ type: FormControl<string>; }>; timelineType: FormControl<TimelineType>; selectedDatapoint: FormControl<null | SelectedDatapoint>; label?: FormControl<string>; } declare class AlarmEventAttributesFormComponent implements ControlValueAccessor, Validator, OnInit { private formBuilder; private alarmEventAttributesFormService; timelineType: TimelineType; omitProperties: OmitSelectorProperties; selectedItems: AlarmOrEvent[]; target: IIdentified; datapoints: KPIDetails[]; formGroup: FormGroup<AlarmEventAttributeForm>; constructor(formBuilder: FormBuilder, alarmEventAttributesFormService: AlarmEventAttributesFormService); ngOnInit(): void; validate(_control: AbstractControl): ValidationErrors; writeValue(obj: any): void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState(isDisabled: boolean): void; changeDatapointSelection(event: Event): void; trackByFn(_index: number, item: KPIDetails): string; private filterKpis; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventAttributesFormComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEventAttributesFormComponent, "c8y-alarm-event-attributes-form", never, { "timelineType": { "alias": "timelineType"; "required": false; }; "omitProperties": { "alias": "omitProperties"; "required": false; }; "selectedItems": { "alias": "selectedItems"; "required": false; }; "target": { "alias": "target"; "required": false; }; "datapoints": { "alias": "datapoints"; "required": false; }; }, {}, never, never, true, never>; } declare class AlarmEventSelectorModalComponent { private bsModal; selectType: TimelineType; contextAsset: IIdentified; allowChangingContext: boolean; allowSearch: boolean; selectedItems: AlarmOrEvent[]; title: string; groupsSelectable: boolean; hideSource: boolean; saveButtonLabel: string; omitProperties: OmitSelectorProperties; readonly result: Promise<AlarmOrEvent[]>; private save; private cancel; constructor(bsModal: BsModalRef); saveChanges(): void; close(): void; selectionChange(selection: Array<AlarmOrEvent>): void; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorModalComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEventSelectorModalComponent, "c8y-alarm-event-selector-modal", never, {}, {}, never, never, true, never>; } type AlarmEventSelectorModalOptions = Pick<AlarmEventSelectorModalComponent, 'selectType' | 'contextAsset' | 'allowChangingContext' | 'selectedItems' | 'allowSearch' | 'title' | 'saveButtonLabel' | 'hideSource' | 'groupsSelectable' | 'omitProperties'>; /** * Service to open the alarm event selector modal. */ declare class AlarmEventSelectorModalService { private modal; constructor(modal: BsModalService); /** * Opents the alarm or event selector modal. * @param initialState Initial state of the modal. * @returns Promise that resolves with the selected alarms or events. */ selectItems(initialState?: Partial<AlarmEventSelectorModalOptions>): Promise<AlarmOrEvent[]>; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorModalService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmEventSelectorModalService>; } declare class AlarmEventSelectorService { private alarmService; private eventsService; private color; private timelineTypeTextsMap; constructor(alarmService: AlarmService, eventsService: EventService, color: ColorService); /** * This method returns the texts for the timeline type. * @param timelineType The timeline type. * @returns The texts for the timeline type. */ timelineTypeTexts(timelineType: TimelineType): TimelineTypeTexts; /** * This method returns all alarms or events of the platform based on the timeline type * @param timelineType The timeline type. * @returns The alarms or events of the asset. */ getItems(timelineType: TimelineType): Promise<AlarmOrEvent[]>; /** * This method returns the items of the asset based on the timeline type. * @param parentReference The parent reference. * @param timelineType The timeline type. * @returns The alarms or events of the asset. */ getAlarmsOrEvents(parentReference: IIdentified, timelineType: TimelineType): Promise<AlarmOrEvent[]>; getUniqueAlarmsOnly(data: IAlarm[]): Promise<AlarmDetails[]>; getUniqueEventsOnly(data: IEvent[]): Promise<EventDetails[]>; createItem(timelineType: 'ALARM' & TimelineType, item: IAlarm): Promise<AlarmDetails>; createItem(timelineType: 'EVENT' & TimelineType, item: IEvent): Promise<EventDetails>; private getAlarmsOfAsset; private getEventsOfAsset; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<AlarmEventSelectorService>; } declare class AlarmEventSelectionListComponent implements ControlValueAccessor, Validator, OnInit, OnDestroy { private alarmEventModalService; private alarmEventSelectService; private formBuilder; private activatedRoute; private contextRouteService; private widgetComponent; /** * The type of timeline to be displayed. * Can be either 'ALARM' or 'EVENT'. */ timelineType: TimelineType; /** * Whether the user can remove items from the list. */ canRemove: boolean; /** * Whether the user can edit items in the alarm/event list. */ canEdit: boolean; canDragAndDrop: boolean; title: string; /** * The label for the button to add items to the list. * If not provided, a default label will be used based on the timeline type. */ addButtonLabel: string; /** * Hide or show the source of the alarm or event. */ hideSource: boolean; /** * Display the list inline or as a dropdown. * If set to true, the list will be displayed inline. */ inline: boolean; /** * Display the alarm/events as switch. If disabled it is displayed as checkbox instead. */ activeToggleAsSwitch: boolean; omitProperties: OmitSelectorProperties; datapoints: any[]; emptyState: EmptyStateComponent; /** * The configuration for the alarms-events selector modal. */ config: Partial<AlarmEventSelectorModalOptions>; formArray: FormArray; timelineTypeTexts: TimelineTypeTexts; contextSourceId: number | string | null; private destroy$; constructor(alarmEventModalService: AlarmEventSelectorModalService, alarmEventSelectService: AlarmEventSelectorService, formBuilder: FormBuilder, activatedRoute: ActivatedRoute, contextRouteService: ContextRouteService, widgetComponent: WidgetConfigComponent); ngOnInit(): void; ngOnDestroy(): void; registerOnTouched(fn: any): void; validate(_control: AbstractControl): ValidationErrors; get formGroups(): FormGroup[]; writeValue(alarmsOrEvents: AlarmOrEvent[]): void; registerOnChange(fn: any): void; add(): void; onItemRemoved(index: number): void; drop(event: CdkDragDrop<AlarmOrEvent[]>): void; private transformValue; private initializeContextSourceId; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectionListComponent, [null, null, null, { optional: true; }, { optional: true; }, { optional: true; }]>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEventSelectionListComponent, "c8y-alarm-event-selection-list", never, { "timelineType": { "alias": "timelineType"; "required": false; }; "canRemove": { "alias": "canRemove"; "required": false; }; "canEdit": { "alias": "canEdit"; "required": false; }; "canDragAndDrop": { "alias": "canDragAndDrop"; "required": false; }; "title": { "alias": "title"; "required": false; }; "addButtonLabel": { "alias": "addButtonLabel"; "required": false; }; "hideSource": { "alias": "hideSource"; "required": false; }; "inline": { "alias": "inline"; "required": false; }; "activeToggleAsSwitch": { "alias": "activeToggleAsSwitch"; "required": false; }; "omitProperties": { "alias": "omitProperties"; "required": false; }; "datapoints": { "alias": "datapoints"; "required": false; }; "config": { "alias": "config"; "required": false; }; }, {}, ["emptyState"], ["c8y-ui-empty-state"], true, never>; } declare class AlarmEventSelectorListItemComponent implements OnInit, ControlValueAccessor, Validator, OnDestroy { private formBuilder; timelineType: TimelineType; datapoints: KPIDetails[] | undefined; highlightText: string; showAddRemoveButton: boolean; isSelected: boolean; optionToRemove: boolean; showActiveToggle: boolean; allowItemEdit: boolean; hideSource: boolean; displayAsSwitch: boolean; omitProperties: OmitSelectorProperties; colorPickerTitle: string; added: EventEmitter<AlarmOrEvent>; removed: EventEmitter<AlarmOrEvent>; formGroup: FormGroup; valid$: Observable<boolean>; private destroy$; constructor(formBuilder: FormBuilder); ngOnInit(): void; ngOnDestroy(): void; toggleActive(): void; validate(_control: AbstractControl): ValidationErrors; writeValue(obj: any): void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState(isDisabled: boolean): void; addOrRemoveItem(): void; remove(): void; private transformFormValue; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorListItemComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEventSelectorListItemComponent, "c8y-alarm-event-selector-list-item", never, { "timelineType": { "alias": "timelineType"; "required": false; }; "datapoints": { "alias": "datapoints"; "required": false; }; "highlightText": { "alias": "highlightText"; "required": false; }; "showAddRemoveButton": { "alias": "showAddRemoveButton"; "required": false; }; "isSelected": { "alias": "isSelected"; "required": false; }; "optionToRemove": { "alias": "optionToRemove"; "required": false; }; "showActiveToggle": { "alias": "showActiveToggle"; "required": false; }; "allowItemEdit": { "alias": "allowItemEdit"; "required": false; }; "hideSource": { "alias": "hideSource"; "required": false; }; "displayAsSwitch": { "alias": "displayAsSwitch"; "required": false; }; "omitProperties": { "alias": "omitProperties"; "required": false; }; }, { "added": "added"; "removed": "removed"; }, never, ["c8y-li-drag-handle"], true, never>; } declare class AlarmEventSelectorComponent implements OnInit { private alarmEventSelectorService; timelineType: TimelineType; contextAsset: IIdentified; allowChangingContext: boolean; selectedItems: AlarmOrEvent[]; allowSearch: boolean; groupsSelectable: boolean; hideSource: boolean; omitProperties: OmitSelectorProperties; selectionChange: EventEmitter<AlarmOrEvent[]>; filterString: string; maxNumberOfItems: number; loadingItems$: BehaviorSubject<boolean>; assetSelection: BehaviorSubject<IIdentified>; items$: Observable<AlarmOrEvent[]>; filteredItems$: Observable<AlarmOrEvent[]>; filterStringChanges$: Observable<string>; timelineTypeTexts: TimelineTypeTexts; isExpanded: boolean; defaultColor: string; private filterString$; constructor(alarmEventSelectorService: AlarmEventSelectorService); ngOnInit(): void; itemAdded(item: AlarmOrEvent): void; itemRemoved(alarm: AlarmOrEvent): void; assetSelectionChanged(evt: AssetSelectionChangeEvent): void; trackByFn(_index: number, item: AlarmOrEvent): string; filterStringChanged(newValue?: string): void; private setLoadingState; private setupObservables; private selectAsset; private emitCurrentSelection; private includesFilterString; static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AlarmEventSelectorComponent, "c8y-alarm-event-selector", never, { "timelineType": { "alias": "timelineType"; "required": false; }; "contextAsset": { "alias": "contextAsset"; "required": false; }; "allowChangingContext": { "alias": "allowChangingContext"; "required": false; }; "selectedItems": { "alias": "selectedItems"; "required": false; }; "allowSearch": { "alias": "allowSearch"; "required": false; }; "groupsSelectable": { "alias": "groupsSelectable"; "required": false; }; "hideSource": { "alias": "hideSource"; "required": false; }; "omitProperties": { "alias": "omitProperties"; "required": false; }; }, { "selectionChange": "selectionChange"; }, never, never, true, never>; } declare class IncludesAlarmOrEventPipe implements PipeTransform { transform<T extends AlarmDetails | EventDetails>(itemList: T[], item?: T): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<IncludesAlarmOrEventPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<IncludesAlarmOrEventPipe, "includesAlarmOrEvent", true>; } declare class CustomAlarmEventFormComponent implements OnInit, OnDestroy { private formBuilder; timelineType: TimelineType; target: IIdentified; omitProperties: OmitSelectorProperties; selectedItems: AlarmOrEvent[]; defaultColor: string; added: EventEmitter<AlarmOrEvent>; cancel: EventEmitter<void>; formGroup: FormGroup; valid$: Observable<boolean>; private destroy$; constructor(formBuilder: FormBuilder); ngOnInit(): void; ngOnDestroy(): void; add(): void; private transformFormValue; static ɵfac: i0.ɵɵFactoryDeclaration<CustomAlarmEventFormComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<CustomAlarmEventFormComponent, "c8y-custom-alarm-event-form", never, { "timelineType": { "alias": "timelineType"; "required": false; }; "target": { "alias": "target"; "required": false; }; "omitProperties": { "alias": "omitProperties"; "required": false; }; "selectedItems": { "alias": "selectedItems"; "required": false; }; "defaultColor": { "alias": "defaultColor"; "required": false; }; }, { "added": "added"; "cancel": "cancel"; }, never, never, true, never>; } declare class AlarmEventSelectorModule { static ɵfac: i0.ɵɵFactoryDeclaration<AlarmEventSelectorModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<AlarmEventSelectorModule, never, [typeof i1.CommonModule, typeof i1.CoreModule, typeof i2.DragDropModule, typeof i3.PopoverModule, typeof i4.TooltipModule, typeof i5.AssetSelectorModule, typeof i6.CollapseModule, typeof i7.RouterModule, typeof AlarmEventSelectionListComponent, typeof AlarmEventSelectorListItemComponent, typeof AlarmEventAttributesFormComponent, typeof AlarmEventSelectorModalComponent, typeof AlarmEventSelectorComponent, typeof IncludesAlarmOrEventPipe, typeof CustomAlarmEventFormComponent], [typeof AlarmEventSelectionListComponent, typeof AlarmEventSelectorComponent]>; static ɵinj: i0.ɵɵInjectorDeclaration<AlarmEventSelectorModule>; } declare class WidgetEventSelectorComponent implements OnInit { /** * The name of the control in the widget configuration where * the selected events will be stored. */ controlName: string; /** * Determines how the config is updated: * - ISOLATED: Only stores items matching the events timelineType * - MIXED: Stores both alarms and events together */ configStoreMode: ConfigStoreMode; events: EventDetails[]; readonly widgetConfigService: WidgetConfigService; readonly timelineType: TimelineType; ngOnInit(): void; onEventsChange(events: EventDetails[]): void; private getEvents; private updateEventsConfig; private getAlarmsOrEventsFromWidgetConfig; static ɵfac: i0.ɵɵFactoryDeclaration<WidgetEventSelectorComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<WidgetEventSelectorComponent, "c8y-widget-event-selector", never, { "controlName": { "alias": "controlName"; "required": false; }; "configStoreMode": { "alias": "configStoreMode"; "required": false; }; }, {}, never, never, true, never>; } declare class WidgetAlarmSelectorComponent implements OnInit { /** * The name of the control in the widget configuration where * the selected alarms will be stored. */ controlName: string; /** * Determines how the config is updated: * - ISOLATED: Only stores items matching the alarms timelineType * - MIXED: Stores both alarms and events together */ configStoreMode: ConfigStoreMode; alarms: AlarmDetails[]; readonly widgetConfigService: WidgetConfigService; readonly timelineType: TimelineType; ngOnInit(): void; onAlarmsChange(alarms: AlarmDetails[]): void; private getAlarms; private updateAlarmsConfig; private getAlarmsOrEventsFromWidgetConfig; static ɵfac: i0.ɵɵFactoryDeclaration<WidgetAlarmSelectorComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<WidgetAlarmSelectorComponent, "c8y-widget-alarm-selector", never, { "controlName": { "alias": "controlName"; "required": false; }; "configStoreMode": { "alias": "configStoreMode"; "required": false; }; }, {}, never, never, true, never>; } export { ALARM_TEXTS, AlarmEventAttributesFormComponent, AlarmEventSelectionListComponent, AlarmEventSelectorComponent, AlarmEventSelectorListItemComponent, AlarmEventSelectorModalComponent, AlarmEventSelectorModalService, AlarmEventSelectorModule, AlarmEventSelectorService, CustomAlarmEventFormComponent, EVENT_TEXTS, IncludesAlarmOrEventPipe, WidgetAlarmSelectorComponent, WidgetEventSelectorComponent }; export type { AlarmDetails, AlarmEventSelectorModalOptions, AlarmOrEvent, ConfigStoreMode, EventDetails, OmitSelectorProperties, SelectedDatapoint, TimelineType, TimelineTypeTexts }; //# sourceMappingURL=index.d.ts.map