@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
254 lines (246 loc) • 9.92 kB
TypeScript
import * as i0 from '@angular/core';
import { WritableSignal, ElementRef } from '@angular/core';
import { DatapointsGraphWidgetConfig } from '@c8y/ngx-components/echart';
import { TimeContext, TimeContextComponent } from '@c8y/ngx-components/time-context';
import { FormGroup } from '@angular/forms';
import { IIdentified, aggregationType, IManagedObject } from '@c8y/client';
import { DynamicComponentAlertAggregator } from '@c8y/ngx-components';
import { SelectedDatapoint } from '@c8y/ngx-components/alarm-event-selector';
import { KPIDetails, DatapointAttributesFormConfig } from '@c8y/ngx-components/datapoint-selector';
import { ExportConfig } from '@c8y/ngx-components/datapoints-export-selector';
import { DatapointsGraphWidgetConfig as DatapointsGraphWidgetConfig$1, AlarmDetailsExtended, EventDetailsExtended, DatapointsGraphKPIDetails, CHART_VIEW_CONTEXT, TimeContextProps, AlarmOrEventExtended } from '@c8y/ngx-components/echart/models';
import { Interval } from '@c8y/ngx-components/interval-picker';
import { Observable } from 'rxjs';
declare class NameGeneratorService {
generateName(): string;
static ɵfac: i0.ɵɵFactoryDeclaration<NameGeneratorService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NameGeneratorService>;
}
interface WorkspaceConfiguration {
id: string;
label: string;
config: DatapointsGraphWidgetConfig;
}
interface Settings {
hideWorkspaceConfig?: boolean;
hideExportSelector?: boolean;
hideWidgetActions?: boolean;
timeContext?: TimeContext;
defaultConfigurationId?: string;
}
interface DataExplorerUrlConfig {
datapoints?: BaseDatapointConfig[];
alarmsEventsConfigs?: BaseAlarmEventConfig[];
dateFrom?: Date | string | null;
dateTo?: Date | string | null;
[key: string]: any;
}
interface BaseDatapointConfig {
fragment: string;
series: string;
__target?: {
id?: string;
[key: string]: any;
};
__template?: string;
[key: string]: any;
}
interface BaseAlarmEventConfig {
timelineType: string;
label: string;
filters: {
type: string;
[key: string]: any;
};
__target?: {
id?: string;
[key: string]: any;
};
[key: string]: any;
}
declare const DATA_EXPLORER_BASE_CONFIG: DatapointsGraphWidgetConfig;
declare const REVERSE_KEY_MAP: {
d: string;
a: string;
f: string;
s: string;
t: string;
m: string;
l: string;
r: string;
y: string;
df: string;
dt: string;
ac: string;
c: string;
i: string;
tp: string;
};
declare const KEY_MAP: {
[k: string]: string;
};
declare class WorkspaceConfigurationService {
private readonly baseKey;
private readonly baseDefaultKey;
contextIdSignal: WritableSignal<number | string | null>;
private readonly alertService;
get LOCAL_STORAGE_KEY(): string;
get LOCAL_STORAGE_DEFAULT_ID_KEY(): string;
/**
* Generates a full datapoint explorer link from a bare config
*/
generateExplorerLink(config: Partial<DatapointsGraphWidgetConfig> | DataExplorerUrlConfig, label: string, id: string): string;
/** Load workspace configs from localStorage */
getConfigurations(): WorkspaceConfiguration[];
getDefaultConfigurationId(): string | null;
/** Save workspace configs in localStorage */
saveConfigurations(configurations: WorkspaceConfiguration[], id: string): void;
/**
*
* @param urlConfig - configuration from the URL, either compressed string or already decoded object
* @returns
*/
getConfigurationFromUrl(urlConfig: DatapointsGraphWidgetConfig | string): DatapointsGraphWidgetConfig;
/**
* Encode a config for the URL:
* - Cleanup the __target objects to contain only name and id
* - Remove default values (diff from base)
* - Minify keys
* - Compress with lz-string
*/
encodeConfig(config: DatapointsGraphWidgetConfig): string;
/**
* Decode a config from the URL:
* - Decompress
* - Expand keys
* - Merge with base config
*/
decodeConfig(urlConfig: string): Partial<DatapointsGraphWidgetConfig>;
/** Minify keys recursively using KEY_MAP */
private minifyKeys;
/** Expand keys recursively using REVERSE_KEY_MAP */
private expandKeys;
/**
* Remove properties from `config` that match `base` so only changed values remain.
*/
private removeDefaults;
/**
* Cleans up __target objects to only keep id and name and remove the rest.
*/
private cleanUpTargetObject;
static ɵfac: i0.ɵɵFactoryDeclaration<WorkspaceConfigurationService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<WorkspaceConfigurationService>;
}
declare class DatapointExplorerComponent {
#private;
settings$: Observable<Settings>;
chart: ElementRef;
timeContext: TimeContextComponent;
config: DatapointsGraphWidgetConfig$1;
exportConfig: ExportConfig;
alerts: DynamicComponentAlertAggregator | undefined;
alarms: AlarmDetailsExtended[];
events: EventDetailsExtended[];
datapointsOutOfSync: Map<DatapointsGraphKPIDetails, boolean>;
contextAsset: IIdentified;
formGroup: FormGroup;
activeDatapoints: KPIDetails[];
hasAtLeastOneAlarmActive: boolean;
isMarkedAreaEnabled: boolean;
alarmsOrEventsHaveNoMatchingDps: boolean;
canAddReport: boolean;
timeProps: {
dateFrom: Date;
dateTo: Date;
interval?: Interval['id'];
realtime?: boolean;
aggregation?: aggregationType | null;
};
datapointSelectDefaultFormOptions: Partial<DatapointAttributesFormConfig>;
chartViewContext: CHART_VIEW_CONTEXT;
private readonly dataExplorerService;
private readonly formBuilder;
private readonly alertService;
private readonly bsModalService;
private readonly permissions;
private readonly contextDashboardService;
private readonly activatedRoute;
private readonly contextRouteService;
private readonly chartHelpersService;
private readonly gainsightService;
private readonly datapointSyncService;
constructor();
ngOnInit(): void;
onTimeContextChange(timeProps: TimeContextProps): void;
onConfigurationChange(config: DatapointsGraphWidgetConfig$1): Promise<void>;
onSliderZoom(timeProps: {
dateFrom: Date;
dateTo: Date;
interval?: Interval['id'];
}): void;
updateTimeRangeOnRealtime(timeRange: Pick<DatapointsGraphWidgetConfig$1, 'dateFrom' | 'dateTo'>): void;
updateAlarmsAndEvents(alarmsEventsConfigs: AlarmOrEventExtended[]): void;
handleDatapointOutOfSync(dpOutOfSync: DatapointsGraphKPIDetails): void;
updateActiveDatapoints(activeDatapoints: KPIDetails[]): void;
updateAggregatedSliderDatapoint(selectedDatapoint: SelectedDatapoint | null): void;
createNewReportWithWidget(): Promise<void>;
sendAsWidgetToReport(): Promise<void>;
sendAsWidgetToDashboard(): Promise<void>;
private isActualDate;
private isAlarm;
private isEvent;
private hasActiveAlarms;
private checkForMatchingDatapoints;
private updateExportConfig;
private initializeContextSourceId;
private createWidgetConfig;
private initForm;
static ɵfac: i0.ɵɵFactoryDeclaration<DatapointExplorerComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DatapointExplorerComponent, "c8y-datapoint-explorer", never, {}, {}, never, never, true, never>;
}
declare class DataExplorerService {
private readonly inventory;
private readonly contextDashboardService;
private readonly workspaceConfigurationService;
private readonly moChunkLoader;
private readonly datapointSyncService;
private readonly router;
private readonly maxNumberOfManagedObjectsPerRequest;
fetchReportDashboard(reportId: string): Promise<IManagedObject>;
fetchContextDashboard(dashboardId: string, contextAsset: IManagedObject): Promise<IManagedObject>;
loadManagedObjectsInChunks(uniqIds: string[]): Promise<{
result: IManagedObject[];
errors: any[];
}>;
/**
* Navigate to datapoint explorer with given config.
* The goal of this method is to navigate to the data explorer with a provided config from any other application.
* @param config Configuration to use
* @param label Label to be displayed for the configuration
* @param id ID for the configuration
*/
navigateToDataExplorer(config: DataExplorerUrlConfig, label: string, id: string): void;
/**
* Generate a URL for the datapoint explorer with the given config.
* The goal of this method is to generate a shareable link to the data explorer.
* @param config Configuration to use
* @param label Label to be displayed for the configuration
* @param id ID for the configuration
* @returns The generated URL
*/
getUrlForConfig(config: DataExplorerUrlConfig, label: string, id: string): string;
processAlarmEventConfigs(config: DatapointsGraphWidgetConfig): void;
processDatapoints(config: DatapointsGraphWidgetConfig): void;
/**
* Generates a color from a fixed palette based on the index.
* Used to assign colors to alarm/event configs in the UI.
*/
generateColor(index: number): string;
loadAndAssignManagedObjects(config: DatapointsGraphWidgetConfig, uniqueIds: string[]): Promise<void>;
private loadAChunkOfManagedObjects;
static ɵfac: i0.ɵɵFactoryDeclaration<DataExplorerService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DataExplorerService>;
}
export { DATA_EXPLORER_BASE_CONFIG, DataExplorerService, DatapointExplorerComponent, KEY_MAP, NameGeneratorService, REVERSE_KEY_MAP, WorkspaceConfigurationService };
export type { BaseAlarmEventConfig, BaseDatapointConfig, DataExplorerUrlConfig, Settings, WorkspaceConfiguration };
//# sourceMappingURL=index.d.ts.map