@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
1,038 lines (1,025 loc) • 41 kB
TypeScript
import * as i0 from '@angular/core';
import { Injector, Type, TemplateRef, ElementRef, ViewContainerRef, OnInit, OnChanges, OnDestroy, EventEmitter, SimpleChanges, InjectionToken } from '@angular/core';
import * as _c8y_client from '@c8y/client';
import { IIdentified, IManagedObject, IAlarm, IEvent, Paging } from '@c8y/client';
import { C8yPropertyType, C8yJsonSchema, BottomDrawerRef, ExtensionPointForPlugins, PluginsResolveService, GenericHookType, GenericHookOptions } from '@c8y/ngx-components';
import { Observable, BehaviorSubject } from 'rxjs';
import { CdkDragDrop } from '@angular/cdk/drag-drop';
import { CdkTree } from '@angular/cdk/tree';
import { DataSource } from '@angular/cdk/collections';
import { Router } from '@angular/router';
import { ControlValueAccessor } from '@angular/forms';
import { AssetSelectionChangeEvent } from '@c8y/ngx-components/assets-navigator';
interface ComputedPropertyContextMap {
device: {
type: 'device';
value: IManagedObject;
};
group: {
type: 'group';
value: IManagedObject;
};
asset: {
type: 'asset';
value: IManagedObject;
};
alarm: {
type: 'alarm';
value: IAlarm;
};
event: {
type: 'event';
value: IEvent;
};
}
type ValueCallbackMetadata = {
/**
* Mode of operation:
* - 'singleValue': Get count only once (no real-time updates)
* - 'realtime': Enable real-time updates (default)
*/
mode?: 'singleValue' | 'realtime';
/**
* Observable to control real-time updates when mode is 'realtime'.
* - true: Enable real-time updates (fetches current count from server and continues)
* - false: Disable real-time updates (preserves current count, no server call)
* If not provided, real-time runs continuously.
*/
realtimeControl$?: Observable<boolean>;
};
type ComputedPropertyContextType = keyof ComputedPropertyContextMap;
type ComputedPropertyContextValue = ComputedPropertyContextMap[keyof ComputedPropertyContextMap]['value'];
type ComputedPropertyDefinitionBase<TContext extends readonly ComputedPropertyContextType[] = ComputedPropertyContextType[], TConfig = any> = {
name: string;
prop: BaseProperty;
contextType: TContext;
value: ({ config, context, metadata }: {
config?: TConfig;
context?: ComputedPropertyContextMap[TContext[number]]['value'];
metadata?: ValueCallbackMetadata;
}) => any | Observable<any> | Promise<any>;
injector?: Injector;
};
type ComputedPropertyDefinition<TContext extends readonly ComputedPropertyContextType[] = ComputedPropertyContextType[], TConfig = any> = ComputedPropertyDefinitionBase<TContext, TConfig> & ({
configComponent?: never;
loadConfigComponent?: never;
} | {
configComponent: Type<any>;
loadConfigComponent?: never;
} | {
configComponent?: never;
loadConfigComponent: () => Promise<Type<any>>;
});
type ComputedPropertyComponent = {
/**
* The configuration which is shared between configuration component and display component.
* Should be serializable to allow saving it to the API.
*/
config: unknown;
/**
* The asset, device, group, alarm or event for which the property is displayed.
*/
asset?: IManagedObject;
};
type AssetPropertyListConfig = {
/**
* List of properties that should be selected by default when the asset property list is loaded.
*/
selectedProperties?: AssetPropertyType[];
/**
* Flag to enable or disable the filter functionality in the asset property list.
* When enabled, a search input will be displayed to filter properties by their names.
*/
filterable?: boolean;
/**
* The mode of the asset property list describing how the properties are selected.
* - `single` - only one property can be selected at a time
* - `multi` - multiple properties can be selected at a time
* - `plus` - multiple properties can be selected using add/remove buttons
* - `none` - no properties can be selected
*/
selectMode?: 'single' | 'multi' | 'plus' | 'none';
/**
* The mode of the asset property list describing how the properties are expanded.
* - `expandedByDefault` - all properties are expanded by default and collapse button is shown
* - `collapsedByDefault` - all properties are collapsed by default and expand button is shown
* - `nonCollapsible` - all properties are expanded all the time and collapse button is hidden
*/
expansionMode?: 'expandedByDefault' | 'collapsedByDefault' | 'nonCollapsible';
/**
* Flag to show or hide the header of the asset property list.
* Header includes select all checkbox (if applicable) and the title of the list columns.
*/
showHeader?: boolean;
/**
* Flag to show or hide the value of the asset property.
*/
showValue?: boolean;
/**
* Flag to show or hide the key of the asset property.
* If set to true, the key of the property will be displayed alongside its value.
*/
showKey?: boolean;
/**
* Defines what should be displayed when asset is not selected and there are no properties to show.
* - `empty` - empty state with a message
* - `default-properties` - default properties are shown (like ID, name, type, etc.)
*/
emptyStateContent?: 'empty' | 'default-properties';
/**
* Flag to allow adding custom properties to the asset property list with additional dialog.
*/
allowAddingCustomProperties?: boolean;
/**
* Asset property list allows to provide custom properties as an input.
* This flag defines how the input properties are handled.
* - `merge` - input properties are merged with properties from asset list
* - `override` - input properties override properties from asset list, meaning that only input properties are shown
*/
inputPropertiesHandle?: 'merge' | 'override';
/**
* Enable or disable drag and drop functionality for reordering properties.
*/
allowDragAndDrop?: boolean;
/**
* Tabs to hide in the custom properties drawer.
*/
hiddenTabs?: HiddenTabs;
/**
* Flag to add context asset's ID and name to output properties.
*/
addAssetToProperty?: boolean;
};
declare const defaultAssetPropertyListConfig: AssetPropertyListConfig;
declare const defaultAssetProperties: Array<BaseProperty>;
declare const RESULT_TYPES: {
VALUE: {
name: string;
value: number;
label: "Only value";
};
VALUE_UNIT: {
name: string;
value: number;
label: "Value and unit";
};
VALUE_UNIT_TIME: {
name: string;
value: number;
label: "Value, unit and time";
};
};
interface BaseProperty {
name: string;
label: string;
type: C8yPropertyType;
isEditable?: boolean;
temporary?: boolean;
isStandardProperty?: boolean;
c8y_JsonSchema?: C8yJsonSchema;
active?: boolean;
computed?: boolean;
instanceId?: string;
asset?: IIdentified;
[key: string]: any;
}
interface NestedPropertyFields extends BaseProperty {
title?: string;
properties?: object;
keyPath: string[];
}
type AssetPropertyType = BaseProperty | NestedPropertyFields;
type HiddenTabs = {
regular?: boolean;
computed?: boolean;
asset?: boolean;
};
type AssetPropertyTab = keyof Required<HiddenTabs>;
/**
* Service for managing asset properties.
*/
declare class AssetPropertiesService {
private readonly FRAGMENTS_TO_OMIT;
private readonly MODEL_API_FEATURE_KEY;
private inventoryService;
private assetTypesRealtimeService;
private groupService;
private alert;
private computedPropertiesService;
private featureCacheService;
private assetDefinitionsService;
private translateService;
/**
* Filters added properties to only include those compatible with the given asset.
* Currently only checks compatibility for computed properties.
* @param allAddedProperties All properties that have been added by the user
* @param asset The current asset context
* @returns Promise resolving to properties compatible with the asset
*/
filterCompatibleProperties(allAddedProperties: AssetPropertyType[], asset: IManagedObject): Promise<AssetPropertyType[]>;
/**
* Retrieves properties for an asset.
* First, it tries to get properties from definitions API (if enabled),
* then falls back to asset library.
* @param asset The asset for which to retrieve custom properties.
* @returns A promise resolving to the list of custom properties.
*/
getAssetProperties(asset: IManagedObject): Promise<AssetPropertyType[]>;
/**
* Retrieves the initial set of properties for an asset, based on its type.
* @param asset The asset for which to retrieve properties.
* @returns A promise resolving to the list of initial properties.
*/
getInitialProperties(asset: IManagedObject): Promise<AssetPropertyType[]>;
/**
* Retrieves properties for a device asset.
* @param asset The device asset for which to retrieve properties.
* @returns A promise resolving to the list of device properties.
*/
getDeviceProperties(asset: IManagedObject): Promise<AssetPropertyType[]>;
/**
* Retrieves properties for a group asset.
* @param asset The group asset for which to retrieve properties.
* @returns A promise resolving to the list of group properties.
*/
getGroupProperties(asset: IManagedObject): Promise<AssetPropertyType[]>;
/**
* Categorizes custom properties into simple and complex types.
* @param properties The custom properties to categorize.
* @returns The categorized custom properties.
*/
categorizeCustomProperties(properties: IManagedObject[] | AssetPropertyType[]): AssetPropertyType[];
/**
* Categorizes and flattens hierarchical properties into simple and complex types.
* @param properties The hierarchical properties to categorize and flatten.
* @returns The categorized and flattened properties.
*/
categorizeAndFlattenHierarchicalProperties(properties: AssetPropertyType[]): {
computed: AssetPropertyType[];
simple: AssetPropertyType[];
complex: AssetPropertyType[];
};
/**
* Checks if a property is complex (i.e., has nested properties).
* @param property The property to check.
* @returns True if the property is complex, false otherwise.
*/
isComplexProperty(property: AssetPropertyType): boolean;
/**
* Checks if property is available based on provided available computed property names.
* @param property The property to check.
* @param availableComputedPropertyNames Set of available computed property names.
* @returns True if the property is available, false otherwise.
*/
isPropertyAvailable(property: AssetPropertyType, availableComputedPropertyNames: Set<string>): Promise<boolean>;
/**
* Checks if two properties match for selection purposes.
* @param property1 First property to compare.
* @param property2 Second property to compare.
* @param omitProperties Optional list of property keys to omit from comparison (e.g., ['instanceId','configuredAssetId']).
* @returns True if properties match.
*/
propertiesMatch(property1: AssetPropertyType, property2: AssetPropertyType, omitProperties?: (keyof AssetPropertyType)[]): boolean;
/**
* Retrieves custom properties from the properties library, optionally filtered by search text.
* @param searchText Optional search text to filter properties.
* @returns A promise resolving to the list of properties and paging information.
*/
getPropertiesFromPropertiesLibrary(searchText?: string): Promise<{
propertiesFromLibrary: AssetPropertyType[];
paging: _c8y_client.Paging<IManagedObject>;
}>;
/**
* Filters properties with hierarchical search logic:
* - Simple properties: match label or name
* - Child properties: match child label/name AND if matches- match also parent
* - Complex properties: match parent label/name AND if matches- all children
*
* @example
* // Search "or" → matches children "Major", "Minor" → includes parent + matching children
* filterPropertiesWithHierarchy([
* { name: 'c8y_ActiveAlarmsStatus', label: 'Active alarms status', type: 'object', ... },
* { name: 'major', label: 'Major', keyPath: ['c8y_ActiveAlarmsStatus', 'major'], ... },
* { name: 'minor', label: 'Minor', keyPath: ['c8y_ActiveAlarmsStatus', 'minor'], ... },
* { name: 'critical', label: 'Critical', keyPath: ['c8y_ActiveAlarmsStatus', 'critical'], ... }
* ], 'or')
* // Returns: [
* { name: 'c8y_ActiveAlarmsStatus', label: 'Active alarms status', type: 'object', ... },
* { name: 'major', label: 'Major', keyPath: ['c8y_ActiveAlarmsStatus', 'major'], ... },
* { name: 'minor', label: 'Minor', keyPath: ['c8y_ActiveAlarmsStatus', 'minor'], ... }
* ]
*
* @example
* // Search "address" → matches parent → includes parent + all children
* filterPropertiesWithHierarchy([
* { name: 'c8y_Address', label: 'Address', type: 'object', ... },
* { name: 'street', label: 'Street', keyPath: ['c8y_Address', 'street'], ... },
* { name: 'city', label: 'City', keyPath: ['c8y_Address', 'city'], ... }
* ], 'address')
* // Returns: [
* { name: 'c8y_Address', label: 'Address', type: 'object', ... },
* { name: 'street', label: 'Street', keyPath: ['c8y_Address', 'street'], ... },
* { name: 'city', label: 'City', keyPath: ['c8y_Address', 'city'], ... }
* ]
*
* @param flattenedProperties All flattened properties (simple and complex)
* @param searchTerm Search term (case-insensitive, already lowercased)
* @returns Filtered properties matching the search term
*/
filterPropertiesWithHierarchy(flattenedProperties: AssetPropertyType[], searchTerm: string): AssetPropertyType[];
/**
* Checks if a simple property (which is not a child of a complex property) matches the search term.
* @param prop The property to check.
* @param searchTerm The search term (already lowercased).
* @returns The property if it matches, otherwise null.
*/
private matchesSimpleProperty;
/**
* Checks if a simple property (which is a child of a complex property) matches the search term and if not- check if parent complex property matches.
* @param prop The property to check.
* @param searchTerm The search term (already lowercased).
* @param parentMap A map of parent complex properties.
* @returns The property if it matches, otherwise null.
*/
private matchesChildProperty;
/**
* Checks if a complex property matches the search term or if any of its child properties match the search term.
* @param prop The complex property to check.
* @param searchTerm The search term (already lowercased).
* @returns The property if it matches, otherwise null.
*/
private matchesComplexProperty;
private requestPropertiesFromPropertiesLibrary;
private addNestedProperties;
private flattenProperties;
private getManagedObjectProperties;
private extractFragments;
private shouldSkipFragment;
private addPropertyItem;
/**
* Converts asset definition from model API into AssetPropertyType array.
* @param assetDefinition The asset definition to convert.
* @returns The converted custom properties.
*/
private categorizePropertiesFromDefinition;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertiesService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<AssetPropertiesService>;
}
/**
* Service to open a drawer for selecting custom asset properties.
*/
declare class CustomPropertiesDrawerService {
private bottomDrawerService;
getCustomProperties(asset: IManagedObject, options?: {
hiddenTabs?: HiddenTabs;
}): Promise<AssetPropertyType[]>;
static ɵfac: i0.ɵɵFactoryDeclaration<CustomPropertiesDrawerService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<CustomPropertiesDrawerService>;
}
interface AssetPropertyFlatNode {
expandable: boolean;
level: number;
property: AssetPropertyType;
isVisible: boolean;
indeterminate?: boolean;
/**
* ID of asset that was selected while configuring the computed property.
*/
configuredAssetId?: string;
}
declare class FlatTreeDataSource extends DataSource<AssetPropertyFlatNode> {
private _dataChange;
constructor();
get data(): AssetPropertyFlatNode[];
set data(value: AssetPropertyFlatNode[]);
connect(): Observable<AssetPropertyFlatNode[]>;
disconnect(): void;
}
declare class AssetPropertyActionDirective {
template: TemplateRef<unknown>;
elementRef: ElementRef;
viewContainer: ViewContainerRef;
constructor(template: TemplateRef<unknown>, elementRef: ElementRef, viewContainer: ViewContainerRef);
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertyActionDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<AssetPropertyActionDirective, "[c8yAssetPropertyAction]", never, {}, {}, never, never, true, never>;
}
/**
* Represents a list of asset properties with hierarchical tree structure.
*/
declare class AssetPropertyListComponent implements OnInit, OnChanges, OnDestroy {
/**
* Reference to the CDdk tree component.
*/
tree: i0.Signal<CdkTree<AssetPropertyFlatNode, AssetPropertyFlatNode>>;
/**
* Configuration for the asset property list.
*/
config: AssetPropertyListConfig;
/**
* Managed object representing the asset.
*/
asset: IManagedObject;
/**
* Extra properties to be displayed in the list.
*/
extraProperties: AssetPropertyType[];
/**
* Emits the selected properties.
*/
selectedProperties: EventEmitter<AssetPropertyType[]>;
/**
* List of all properties.
*/
properties: AssetPropertyType[];
/**
* Text input for filtering properties.
*/
filterText: string;
/**
* Data source for the tree structure.
*/
dataSource: FlatTreeDataSource;
/**
* Map of flat nodes for quick lookup.
*/
flatNodeMap: Map<string, AssetPropertyFlatNode>;
/**
* Indicates if all nodes are selected.
*/
allSelected: boolean;
/**
* Indicates if the selection state is indeterminate.
*/
indeterminate: boolean;
/**
* Directive for asset property actions.
*/
assetPropertyAction: AssetPropertyActionDirective;
hasExpandableNodes: boolean;
areAllNodesExpanded: boolean;
collapseAllLabel: "Collapse all";
expandAllLabel: "Expand all";
dragHandleEnabledLabel: "Click and drag to reorder";
dragHandleDisabledLabel: "Clear filtering to reorder";
get cdkDragDisabled(): boolean;
readonly TREE_NODE_INDENT = 24;
/**
* Stores all nodes in their complete ordered state (source of truth for order)
*/
private allNodesComplete;
/**
* Tracks which parent nodes are expanded (key = node key, value = expanded state)
*/
private expansionState;
/**
* List of properties that have been added temporarily as custom properties.
*/
private allAddedProperties;
/**
* List of properties that have been added temporarily as custom properties filtered according to context asset.
*/
private displayAddedProperties;
/**
* Subject for handling filter input.
*/
private filterSubject$;
/**
* Subject for handling component destruction.
*/
private destroy$;
/**
* Service for managing asset properties.
*/
private assetPropertiesService;
private customPropertiesDrawerService;
private computedPropertiesService;
private modalService;
private dragDropService;
private translateService;
/**
* Constructor initializes reactive effects for expansion modes.
*/
constructor();
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): Promise<void>;
ngAfterViewInit(): void;
ngOnDestroy(): void;
/**
* Fetches and categorizes properties.
* @returns A promise resolving to the list of asset properties.
*/
getProperties(): Promise<AssetPropertyType[]>;
/**
* Opens the drawer to add new custom properties.
*/
addProperty(): Promise<void>;
/**
* Displays the configuration modal for multiple computed properties and updates their configurations.
* @param properties Properties to configure.
* @param definitions Computed property definitions including config components.
* @returns Promise resolving to array of configurations.
*/
configureMultipleProperties(properties: AssetPropertyType[], definitions: ComputedPropertyDefinition[]): Promise<unknown[]>;
/**
* Displays the configuration modal for a computed property and updates its configuration.
* @param property Property to configure.
* @param definition Computed property definition including config component.
* @returns true if the property was configured, false if cancelled.
*/
configureProperty(property: AssetPropertyType, definition: ComputedPropertyDefinition): Promise<boolean>;
/**
* Removes temporary property from the list.
* @param property The property to remove.
*/
removeProperty(property: AssetPropertyType): Promise<void>;
editProperty(property: AssetPropertyType): Promise<void>;
hasChild(node: AssetPropertyFlatNode): boolean;
/**
* Checks if the property's context asset matches the current asset.
* @param node The node to check.
* @returns True if the context asset doesn't match the current asset.
*/
isContextMismatch(node: AssetPropertyFlatNode): boolean;
/**
* Gets the level of a node.
* @param node The node to check.
* @returns The level of the node.
*/
getLevel(node: AssetPropertyFlatNode): number;
/**
* Gets the parent node of a given node.
* @param node The node to check.
* @returns The parent node or null if none exists.
*/
getParentNode(node: AssetPropertyFlatNode): AssetPropertyFlatNode | null;
/**
* Checks if a node is expanded.
* @param node The node to check.
* @returns True if the node is expanded.
*/
isNodeExpanded(node: AssetPropertyFlatNode): boolean;
/**
* Toggles the expansion state of a node.
* @param node The node to toggle.
*/
toggleNode(node: AssetPropertyFlatNode): void;
/**
* Selects or deselects all nodes.
* @param selected True to select all, false to deselect.
*/
selectAll(selected: boolean): void;
/**
* Handles single selection mode.
* @param selected True if the node is selected.
* @param node The node to select.
*/
onSelectSingle(selected: boolean, node: AssetPropertyFlatNode, emit?: boolean): void;
/**
* Handles multi-selection mode.
* @param selected True if the node is selected.
* @param node The node to select.
*/
onSelectMulti(selected: boolean, node: AssetPropertyFlatNode, emit?: boolean): void;
/**
* Initiates a filter operation.
*/
onFilter(): void;
/**
* Clears the filter input.
*/
clearFilter(): void;
drop(event: CdkDragDrop<AssetPropertyFlatNode[]>): void;
/**
* Toggles expansion of all nodes - expands all if any are collapsed, otherwise collapses all.
*/
toggleExpandCollapseAll(): void;
/**
* Calculates the max-width for a column based on node level and configuration.
* @param node The node to calculate width for.
* @returns The calculated max-width CSS value.
*/
getColumnMaxWidth(node: AssetPropertyFlatNode): string;
/**
* Gets the unique key for a node.
* @param node The node.
* @returns The unique key.
*/
private getNodeKey;
/**
* Updates the areAllNodesExpanded state based on expansion state.
*/
private updateAreAllNodesExpandedState;
/**
* Expands all nodes in the expansion state.
*/
private expandAllNodesInState;
/**
* Collapses all nodes in the expansion state.
*/
private collapseAllNodesInState;
/**
* Updates the list of properties based on the configuration.
* @param rebuildFromAsset If true, rebuilds from scratch. Otherwise preserves existing order and only adds new properties.
* @param prependProperties New properties to add if not rebuilding from asset.
*/
private updateProperties;
private applySelectedPropertiesFromConfig;
/**
* Updates the display added properties based on compatibility with current asset.
*/
private updateDisplayAddedProperties;
/**
* Updates the selection status of child nodes.
* @param parent The parent node.
* @param selected True if the parent is selected.
*/
private updateChildSelectionStatus;
/**
* Checks if a property matches the filter criteria.
* @param property The property to check.
* @param filterText The filter text.
* @returns True if the property matches.
*/
private matchesSearch;
/**
* Updates the selection state for all nodes.
*/
private updateSelectAllState;
/**
* Builds the tree nodes from the properties.
*/
private buildTreeNodes;
/**
* Update indeterminate state for all complex nodes
*/
private updateIndeterminateStates;
/**
* Filters the tree nodes based on the filter input.
*/
private filterTree;
/**
* Makes all parent nodes visible.
* @param node The node whose parents should be made visible.
*/
private makeParentsVisible;
/**
* Rebuilds visible data based on expansion state (only when not filtering).
*/
private rebuildVisibleData;
/**
* Determines if a node should be visible based on expansion state.
* @param node The node to check.
* @returns True if the node should be visible.
*/
private shouldNodeBeVisible;
/**
* Updates complete data order after drag-drop on visible data.
* @param newVisibleData The new order of visible nodes.
*/
private updateCompleteDataOrder;
/**
* Categorizes and flattens hierarchical properties.
* @param properties The properties to categorize.
* @returns The flattened list of properties.
*/
private categorizeAndFlattenHierarchicalProperties;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertyListComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AssetPropertyListComponent, "c8y-asset-property-list", never, { "config": { "alias": "config"; "required": false; }; "asset": { "alias": "asset"; "required": false; }; "extraProperties": { "alias": "extraProperties"; "required": false; }; }, { "selectedProperties": "selectedProperties"; }, ["assetPropertyAction"], never, true, never>;
}
/**
* Represents a drawer component for selecting asset properties.
* This is a thin wrapper around AssetPropertySelectorComponent that handles drawer-specific logic.
*/
declare class AssetPropertySelectorDrawerComponent {
/**
* Title of the drawer.
*/
title: "Select property";
/**
* Managed object representing the asset.
*/
contextAsset: IManagedObject;
/**
* Configuration for the asset property list.
*/
config: AssetPropertyListConfig;
/**
* Extra properties to be displayed in the list.
*/
extraProperties: AssetPropertyType[];
/**
* List of selected properties.
*/
selectedProperties: AssetPropertyType[];
/**
* Flag to allow changing the context (asset) within the drawer.
*/
allowChangingContext: boolean;
/**
* Flag to hide the selection
* */
hideSelection: boolean;
/**
* Flag to allow selecting properties from multiple assets (if context change is allowed).
*/
allowPropertiesFromMultipleAssets: boolean;
/**
* Flag to enable search functionality for asset properties.
*/
allowSearch: boolean;
/**
* Reference to the bottom drawer.
*/
bottomDrawerRef: BottomDrawerRef<any>;
/**
* Promise resolving to the selected properties.
*/
result: Promise<AssetPropertyType[]>;
/**
* Internal save handler.
*/
private _save;
/**
* Internal cancel handler.
*/
private _cancel;
ngOnInit(): void;
/**
* Handles selection changes from the selector component.
* @param selection The selected properties.
*/
selectionChange(selection: AssetPropertyType[]): void;
/**
* Saves the selected properties and closes the drawer.
*/
onSave(): void;
/**
* Cancels the selection and closes the drawer.
*/
onCancel(): void;
/**
* Checks if the select button should be disabled.
* @returns True if no active properties are selected.
*/
selectIsDisabled(): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertySelectorDrawerComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AssetPropertySelectorDrawerComponent, "c8y-asset-property-selector-drawer-component", never, { "title": { "alias": "title"; "required": false; }; }, {}, never, never, true, never>;
}
/**
* Formats the value of an asset property.
* If the property is complex, it will be stringified.
* If the property has a keyPath, it will be used to retrieve the value from the asset.
* Otherwise, the value will be taken directly from the asset.
* If the value is null or undefined, a dash ('-') will be returned.
*/
declare class AssetPropertyValuePipe {
private assetPropertiesService;
private computedPropertiesService;
private injector;
transform(property: AssetPropertyType, context: ComputedPropertyContextValue): Promise<string> | Observable<string>;
private formatPropertyValue;
private getCallbackComputedPropertyValue;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertyValuePipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<AssetPropertyValuePipe, "c8yAssetPropertyValue", true>;
}
declare const HOOK_COMPUTED_PROPERTY: InjectionToken<ComputedPropertyDefinition[]>;
declare function hookComputedProperty(property: GenericHookType<ComputedPropertyDefinition>, options?: Partial<GenericHookOptions>): i0.ValueProvider | i0.ClassProvider | i0.ExistingProvider;
declare class ComputedPropertiesService extends ExtensionPointForPlugins<ComputedPropertyDefinition> {
private router;
private groupService;
constructor(rootInjector: Injector, router: Router, plugins: PluginsResolveService);
/**
* Returns the current state.
* @readonly
* @returns The current set of computed properties.
*/
get state(): Set<ComputedPropertyDefinition>;
add(propertyDef: ComputedPropertyDefinition): void;
getByName(name: string): Promise<ComputedPropertyDefinition>;
getByContext(asset: ComputedPropertyContextValue): Promise<ComputedPropertyDefinition[]>;
private getTypeOfContext;
protected setupItemsObservable(): Observable<ComputedPropertyDefinition[]>;
static ɵfac: i0.ɵɵFactoryDeclaration<ComputedPropertiesService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ComputedPropertiesService>;
}
/**
* Represents a reusable component for displaying and managing library properties (regular and computed).
* This component handles the search, tabs, and property list display logic.
*/
declare class AssetPropertyTabsComponent implements OnInit, OnChanges, OnDestroy {
/**
* The asset context for loading properties.
*/
asset: IManagedObject;
/**
* Configuration for the asset property list.
*/
config: AssetPropertyListConfig;
/**
* Currently selected properties to be highlighted in the list.
*/
selectedProperties: AssetPropertyType[];
/**
* Controls which tabs are hidden.
*/
hiddenTabs: HiddenTabs;
/**
* The name of the tabs outlet.
*/
tabsOutletName: string;
/**
* Whether to show the search input.
*/
showSearch: boolean;
/**
* Emits when the selected properties change.
*/
selectedPropertiesChange: EventEmitter<AssetPropertyType[]>;
tabNames: Record<AssetPropertyTab, string>;
paging: Paging<IManagedObject>;
inputText: string;
selectedTab: AssetPropertyTab;
set assetProperties(value: AssetPropertyType[]);
get assetProperties(): AssetPropertyType[];
private _assetProperties;
set regularProperties(value: AssetPropertyType[]);
get regularProperties(): AssetPropertyType[];
private _regularProperties;
set computedProperties(value: AssetPropertyType[]);
get computedProperties(): AssetPropertyType[];
private _computedProperties;
displayedProperties: AssetPropertyType[];
assetCount: number;
regularCount: number;
computedCount: number;
allComputedProperties: AssetPropertyType[];
get showAsset(): boolean;
get showRegular(): boolean;
get showComputed(): boolean;
get showTabBar(): boolean;
private searchSubject$;
private destroy$;
private readonly assetPropertiesService;
private readonly computedPropertiesService;
private readonly translateService;
private selectedAssetProperties;
private selectedRegularProperties;
private selectedComputedProperties;
ngOnInit(): Promise<void>;
ngOnChanges(changes: SimpleChanges): Promise<void>;
ngOnDestroy(): void;
/**
* Updates the selected properties.
* @param properties The selected properties.
*/
onSelectedProperties(properties: AssetPropertyType[]): void;
onTabChange(tabName: keyof typeof this.tabNames): void;
onSearch(): void;
clearSearch(): void;
loadMore(): Promise<void>;
private loadComputedProperties;
private loadAssetProperties;
private updateProperties;
private updateDisplayedProperties;
/**
* Updates the config to show only the current tab's selected properties.
*/
private updateConfigWithCurrentTabSelections;
/**
* Categorizes incoming selectedProperties by matching them against loaded properties.
*/
private categorizeSelectedProperties;
/**
* Categorizes and flattens hierarchical properties.
* @param properties The properties to categorize.
* @returns The flattened list of properties.
*/
private categorizeAndFlattenHierarchicalProperties;
private withContextAssetId;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertyTabsComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AssetPropertyTabsComponent, "c8y-asset-property-tabs", never, { "asset": { "alias": "asset"; "required": false; }; "config": { "alias": "config"; "required": false; }; "selectedProperties": { "alias": "selectedProperties"; "required": false; }; "hiddenTabs": { "alias": "hiddenTabs"; "required": false; }; "tabsOutletName": { "alias": "tabsOutletName"; "required": false; }; "showSearch": { "alias": "showSearch"; "required": false; }; }, { "selectedPropertiesChange": "selectedPropertiesChange"; }, never, never, true, never>;
}
/**
* Represents a component for selecting asset properties.
* This component handles all selection logic and can be used standalone or within drawer/modal wrappers.
*/
declare class AssetPropertySelectorComponent implements OnInit, ControlValueAccessor {
/**
* Managed object representing the initial/context asset.
*/
contextAsset: IManagedObject;
/**
* Configuration for the asset property list.
*/
config: AssetPropertyListConfig;
/**
* Extra properties to be displayed in the list.
*/
extraProperties: AssetPropertyType[];
/**
* Flag to allow changing the context (asset) within the selector.
*/
allowChangingContext: boolean;
/**
* Flag to allow properties from multiple assets to be selected at once.
*/
allowPropertiesFromMultipleAssets: boolean;
/**
* Flag to hide the selection panel.
*/
hideSelection: boolean;
/**
* Flag to allow search in asset selector.
*/
allowSearch: boolean;
/**
* List of selected properties.
*/
selectedProperties: AssetPropertyType[];
/**
* Current asset selection as observable.
*/
assetSelection: BehaviorSubject<IManagedObject>;
hiddenTabs: HiddenTabs;
private touched;
private onChange;
private onTouched;
private modalService;
private computedPropertiesService;
private assetPropertiesService;
ngOnInit(): void;
/**
* ControlValueAccessor implementation - write value from form model.
*/
writeValue(obj: AssetPropertyType[]): void;
/**
* ControlValueAccessor implementation - register onChange callback.
*/
registerOnChange(fn: (properties: AssetPropertyType[]) => void): void;
/**
* ControlValueAccessor implementation - register onTouched callback.
*/
registerOnTouched(fn: () => void): void;
/**
* Updates the selected properties.
* @param properties The selected properties.
*/
onSelectedProperties(properties: AssetPropertyType[]): Promise<void>;
/**
* Handles asset selection changes.
* @param evt Asset selection change event.
*/
selectionChanged(evt: AssetSelectionChangeEvent): void;
/**
* Removes a property from the selection.
* @param property The property to remove.
*/
propertyRemoved(property: AssetPropertyType): void;
/**
* Edits (reconfigures) a computed property.
* @param property The property to edit.
*/
editProperty(property: AssetPropertyType): Promise<void>;
/**
* Selects an asset and updates the selection.
* @param asset The asset to select.
*/
private selectAsset;
/**
* Clears all selected properties.
*/
private clearSelection;
/**
* Emits the current selection to the form model.
*/
private emitCurrentSelection;
/**
* Marks the control as touched.
*/
private markAsTouched;
/**
* Handles configuration for newly added computed properties.
* @param properties The selected properties.
* @returns The properties with configured ones included.
*/
private handleComputedPropertiesConfiguration;
/**
* Displays the configuration modal for multiple computed properties and updates their configurations.
* @param properties Properties to configure.
* @param definitions Computed property definitions including config components.
* @returns Promise resolving to array of configurations.
*/
private configureMultipleProperties;
/**
* Displays the configuration modal for a single computed property and updates its configuration.
* @param property Property to configure.
* @param definition Computed property definition including config component.
* @returns true if the property was configured, false if cancelled.
*/
private configureProperty;
static ɵfac: i0.ɵɵFactoryDeclaration<AssetPropertySelectorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AssetPropertySelectorComponent, "c8y-asset-property-selector", never, { "contextAsset": { "alias": "contextAsset"; "required": false; }; "config": { "alias": "config"; "required": false; }; "extraProperties": { "alias": "extraProperties"; "required": false; }; "allowChangingContext": { "alias": "allowChangingContext"; "required": false; }; "allowPropertiesFromMultipleAssets": { "alias": "allowPropertiesFromMultipleAssets"; "required": false; }; "hideSelection": { "alias": "hideSelection"; "required": false; }; "allowSearch": { "alias": "allowSearch"; "required": false; }; }, {}, never, never, true, never>;
}
export { AssetPropertiesService, AssetPropertyActionDirective, AssetPropertyListComponent, AssetPropertySelectorComponent, AssetPropertySelectorDrawerComponent, AssetPropertyTabsComponent, AssetPropertyValuePipe, ComputedPropertiesService, CustomPropertiesDrawerService, HOOK_COMPUTED_PROPERTY, RESULT_TYPES, defaultAssetProperties, defaultAssetPropertyListConfig, hookComputedProperty };
export type { AssetPropertyListConfig, AssetPropertyTab, AssetPropertyType, BaseProperty, ComputedPropertyComponent, ComputedPropertyContextType, ComputedPropertyContextValue, ComputedPropertyDefinition, HiddenTabs, NestedPropertyFields, ValueCallbackMetadata };
//# sourceMappingURL=index.d.ts.map