import * as _c8y_client from '@c8y/client'; import { IManagedObject, QueriesUtil, InventoryService, UserService, IResult, Paging, IIdentified } from '@c8y/client'; import * as i1 from '@c8y/ngx-components'; import { NavigatorNode, GroupService, ModalService, AlertService, BreadcrumbService, AppStateService, OptionsService, NavigatorNodeData, GroupFragment, ClickOptions } from '@c8y/ngx-components'; import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { Router, ActivatedRouteSnapshot } from '@angular/router'; import { ApiService } from '@c8y/ngx-components/api'; import * as i0 from '@angular/core'; import { InjectionToken, OnInit, EventEmitter, ChangeDetectorRef, SimpleChanges, ElementRef, ModuleWithProviders } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import * as i2 from 'ngx-bootstrap/collapse'; import * as i3 from 'ngx-bootstrap/dropdown'; import * as i4 from '@angular/forms'; import { AbstractControl, ValidationErrors } from '@angular/forms'; import * as _c8y_ngx_components_assets_navigator from '@c8y/ngx-components/assets-navigator'; declare enum AssetsNavigatorAction { FETCH = 0, NEXT = 1, REFRESH = 2, LOADING_DONE = 3 } declare const ASSET_NAVIGATOR_CONFIG: InjectionToken; /** * Configuration object of the AssetsNavigatorModule. */ interface AssetNavigatorConfig { /** * Allows to enable smart groups in the module. * Default value: false. */ smartGroups?: boolean; /** * Expands the root navigator node when the navigator is initialized. * Default value: false */ openOnStart?: boolean; /** * Allows to change the position of the root group in the navigator. * The higher the value, the higher the position in navigation. * Default value: 2000. */ rootNodePriority?: number; /** * Allows to drag and drop items in the asset navigator. * Default value: true. */ disableDragAndDrop?: boolean; /** * Allows to override properies of the root group or hide it. * Setup examples: * - `rootNavigatorNode: true` - shows the default navigator node (default), * - `rootNavigatorNode: false` - hides the navigator node, * - `rootNavigatorNode: { label: 'New name', ... }` - overrides default navigator node, * - `rootNavigatorNode: new NavigatorNode({ label: 'New name', ... })` - overrides default navigator node, */ rootNavigatorNode?: boolean | Partial; } declare class DeviceGroupService { private migratedDeviceGroupService; constructor(migratedDeviceGroupService: GroupService); icon(mo: IManagedObject, open?: boolean): Promise; isGroup(mo: IManagedObject): boolean; isDynamicGroup(mo: IManagedObject): boolean; isDataBroker(mo: IManagedObject): boolean; isDataBrokerActive(mo: IManagedObject): boolean; isAsset(mo: IManagedObject): boolean; isAnyGroup(mo: IManagedObject): boolean; isDevice(mo: IManagedObject): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } interface AssetNodeMo { id: string; type: string; } declare class AssetNodeService { rootNode: AssetNode; firstUrl: boolean; draggedData: AssetNode; queriesUtil: QueriesUtil; protected PAGE_SIZE: number; private refreshTrigger$; private rootGroupsFetched; rootGroups$: Observable; inventory: InventoryService; apiService: ApiService; modal: ModalService; alert: AlertService; translateService: TranslateService; protected breadcrumbService: BreadcrumbService; protected user: UserService; protected appState: AppStateService; protected optionsService: OptionsService; moduleConfig: AssetNavigatorConfig; protected deviceGroupService: DeviceGroupService; protected router: Router; constructor(); /** * Expands the navigator nodes on first navigation. * @param snapshot The current navigation snapshot. */ expandNodesOnStart(snapshot: ActivatedRouteSnapshot): Promise; /** * Expands all the given ids recursively. Stops if it does not find any. * @param node The node where the expanding should be started * @param ids The ids that should be expanded. */ expandAll(node: AssetNode, ids: string[]): void; label(mo: IManagedObject): string; icon(mo: IManagedObject, open?: boolean): Promise; isGroup(mo: IManagedObject): boolean; isDynamicGroup(mo: IManagedObject): boolean; isDataBroker(mo: IManagedObject): boolean; isDataBrokerActive(mo: IManagedObject): boolean; isAsset(mo: IManagedObject): boolean; isAnyGroup(mo: IManagedObject): boolean; isDevice(mo: IManagedObject): boolean; createRootNode(config?: NavigatorNodeData): AssetNode; createDynamicGroupNode(config: any): DynamicGroupNode; createAssetNode(config: Partial): AssetNode; createChildNode(managedObject: any, config: Partial): AssetNode | DynamicGroupNode; getRootNodes(customFilter?: any): Promise; refresh(): void; fetchRootGroups(customFilter?: any): Promise; getAllInventories(customFilter?: any): Promise; getGroupItems(moId: string, extraFilter?: object, withChildren?: boolean, filterQuery?: string): Promise<_c8y_client.IResultList>; getUnassignedDevices(withChildren?: boolean, filterQuery?: string): Promise<_c8y_client.IResultList>; getDynamicGroupItems(groupQuery: string, filterObj?: any): Promise<_c8y_client.IResultList>; getDeviceChildren(moId: string, extraFilter?: object, filterQuery?: string, withChildren?: boolean): Promise<_c8y_client.IResultList>; getUnassignedDevicesQueryStr(filterQuery: any): string; groupQueryFilter(moId: string, filterQuery?: string): string; navRootQueryFilter(): { __filter: { type: GroupFragment; __has?: undefined; }; __orderby: any[]; } | { __filter: { __has: GroupFragment; type?: undefined; }; __orderby: any[]; }; rootQueryFilter(): { __filter: { type: GroupFragment; __has?: undefined; }; __orderby: any[]; } | { __filter: { __has: GroupFragment; type?: undefined; }; __orderby: any[]; }; onUpdate({ mo, root }: { mo: any; root: any; }): Observable<{ data: IManagedObject; method: string; url: string; }>; isNewManagedObjectRoot(response?: Partial>): boolean; /** * Check if it is possible to drop a node after dragging. * @param dropOnRoot Is the drop performed on the root node */ canDropNode(dropOnRoot: boolean): boolean; /** * There could be multiple breadcrumbs for devices, * so we set a preferred one on click on a device. * @param parents The parent nodes of the device to select the prefered one. */ preferBreadcrumb(parents: NavigatorNode[]): void; protected createFilter(extraParams?: any): any; private buildCombinedQuery; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class LoadMoreNode extends NavigatorNode { static NAME: string; label: "Load more"; icon: string; droppable: boolean; constructor(); toString(): string; isGroup(): boolean; } declare class AssetNode extends NavigatorNode { protected service: AssetNodeService; protected config: NavigatorNodeData; static NAME: string; root: boolean; mo: any; hideDevices: boolean; filterQuery$: BehaviorSubject; showChildDevices: boolean; /** * Asset node children (subentries). */ children: AssetNode[]; get hasChildren(): boolean; get isDevice(): boolean; get isDeviceOrProbablyChildDevice(): boolean; get isNeitherDeviceOrGroup(): boolean; events: Subject; nodesFetched: Subject; protected paging: Paging; protected loadMoreNode: LoadMoreNode; private onUpdateSubscription; constructor(service: AssetNodeService, config?: NavigatorNodeData); getPath(): string; refresh(mo?: any, method?: string): void; setLabel(): void; click(options?: ClickOptions): void; sort(): void; addManagedObject(mo: any): void; isChildAddition(childAdditions: any, mo: any): any; destroy(): void; get canDrop(): boolean; dragStart($event: any): void; dragEnd($event: any): void; drop($event: any): Promise; hookEvents(): void; toString(): string; /** * Checks if the current node has child devices. */ hasChildDevices(): boolean; protected fetch(): Promise; protected updateIcon(open: any): Promise; protected countChildren(): number; protected handleEvent(evt: AssetsNavigatorAction): Promise; protected addNodes(res: any): void; protected toggleLoadMore(show: boolean): void; private moveNode; private showDropConfirm; private verifyNodeAccess; private addMovedNode; private isAsset; private removeMovedNode; } declare class DynamicGroupNode extends AssetNode { protected service: AssetNodeService; constructor(service: AssetNodeService, config?: {}); get hasChildren(): boolean; get query(): any; protected fetch(): any; } interface AssetStatus { sendStatus: { icon: string; class: string; status: string; label: string; tooltip: string; }; pushStatus: { icon: string; class: string; status: string; label: string; tooltip: string; }; maintenanceStatus: boolean; } interface MaintenanceStatus { sendStatus: boolean; pushStatus: boolean; maintenanceStatus: { icon: string; class: string; tooltip: string; }; } interface AssetSelectionChangeEvent { items: IIdentified | IIdentified[]; change: { item: IManagedObject; isSelected: boolean; }; } interface GroupNodeConfig { root?: boolean; mo?: IManagedObject; groupsOnly?: boolean; groupsSelectable?: boolean; showChildDevices?: boolean; } declare const CONFIG_OPTIONS_DEFAULT: AssetSelectorOptions; interface AssetSelectorOptions { /** * Already selected devices. */ selectedDevices?: IIdentified | IIdentified[]; /** * Defines a label to be shown to the user. */ label?: string; /** * Can the user select multiple assets. */ multi?: boolean; /** * displays a filter input on every column when using the miller view. */ showFilter?: boolean; /** * displays a column header on every column when using the miller view. */ columnHeaders?: boolean; /** * Displays only the select column. */ singleColumn?: boolean; /** * Set to true to mark it as required on a form. */ required?: boolean; /** * In simple model-mode the result will only contain the IDs and name of the selected * assets. In full mode, everything is contained. */ modelMode?: 'simple' | 'full'; /** * Set this to true, if the selector should only show groups. */ groupsOnly?: any; /** * Set this true, if groups should be selectable. */ groupsSelectable?: any; /** * Enable to display global search in the asset-selector (only possible whithout device context). */ search?: boolean; /** * Displays all unassigned devices in a custom root group. */ showUnassignedDevices?: boolean; /** * Set the view of the asset selector with tree view as default. */ view?: 'tree' | 'miller'; /** * Used only for miller-view, displays the column level for the current node. * E.g if the index is one, this will be second column. */ index?: number; /** * Used only for single column, the array contains all selected columns. */ selectedColumns?: IIdentified[] | IIdentified; /** * Devices with children can be selected to show their child devices. */ showChildDevices?: boolean; /** * Allows to show chips at the top with the currently selected asset for multi select. * For single select it shows the currently selected asset. */ showSelected?: boolean; /** * Prevents automatic asset selection on component initialization. */ preventInitialSelect?: boolean; } declare class GroupNodeService extends AssetNodeService { protected PAGE_SIZE: number; createGroupNode(config: GroupNodeConfig): GroupNode; createChildNode(config: GroupNodeConfig): GroupNode; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class GroupNode extends AssetNode { protected service: GroupNodeService; static NAME: string; /** * Set this true, if only groups should be shown. */ groupsOnly: boolean; /** * Set this true, if it groups are also selectable. */ groupsSelectable: boolean; /** * Devices with children can be selected to show their child devices. */ showChildDevices: boolean; /** * Group node children (subentries). */ children: GroupNode[]; /** * Creates a new node which shows only groups. * * @param service The service to use. * @param config The default configuration of the node. * @param groupsOnly Set this true, if only groups should be shown. * @param selectable Set this true, if it is selectable. */ constructor(service: GroupNodeService, config?: GroupNodeConfig); /** * Adds the MO as a child node. * @param mo ManagedObject */ addManagedObject(mo: any): void; /** * Counts the number of children for the current node (with the exception of the UnassignedDevicesNode). */ countChildren(): number; /** * Removes all child nodes except the UnassignedDevicesNode. */ empty(): void; fetch(): Promise; toString(): string; isGroup(): boolean; } declare class AssetSelectorService extends AssetNodeService { /** * Function which will check if the node is selectable. */ private isNodeSelectableFn; /** * Sets the function that will decide if the node is selectable. * @param fn A boolean or a function that will decide if the node is selectable. */ setIsNodeSelectable(fn: boolean | ((node: GroupNode) => boolean)): void; /** * Checks if the node is selectable. * @param node The node to check. */ isNodeSelectable(node: GroupNode): boolean; /** * Simplifies the object model based on the selected mode. * @param obj The selected asset. * @param mode The mode which will decide what type of model will be returned. */ normalizeValue(obj: Partial, modelMode: 'simple' | 'full'): Partial | IIdentified; simplifyModel(model: Partial | IIdentified[], mode: 'simple' | 'full'): Partial | IIdentified; /** * Returns the index of the currently selected item. * @param selected All selected items * @param selectedMo The new selected item- * @returns An index, or -1 if not found. */ getIndexOfSelected(selected: Array> | Partial, selectedMo: IIdentified): any; private normalizeModelValue; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class AssetSelectorNodeComponent implements OnInit { private translateService; private cd; assetSelectorService: AssetSelectorService; /** * The current node. */ node: GroupNode; /** * Root node. Node found at the top of the hierarchy. */ rootNode: GroupNode; /** * All preselected items. */ preselected: IIdentified | IIdentified[]; /** * Should the path be shown. */ showPath: boolean; /** * Can the user select multiple assets. */ multi: boolean; /** * The current path to the node. */ view: 'tree' | 'miller'; /** * Used only for miller-view, displays the column level for the current node. * E.g if the index is one, this will be second column. */ index: any; /** * Sets the active node. */ active: GroupNode; /** * A function that should verify the need to add a column when a node is clicked. */ handleNextMillerViewColumn: (node: GroupNode, index: number) => boolean; disabled: boolean; /** * Event, which indicates whether the loading of the node has completed. */ isLoadingState: EventEmitter; /** * Event that emits when a node is selected. */ onSelect: EventEmitter; /** * Event that emits when a node is deselected. */ onDeselect: EventEmitter<{ deselectMode: 'single' | 'all'; mo: IManagedObject; }>; breadcrumb: string; /** * @ignore */ level: number; /** * @ignore */ unsubscribe$: Subject; isNodeSelectable: boolean; /** sets the `btn-pending` class in the load more button */ isLoading: boolean; /** * @ignore */ get expandTitle(): "Expand" | "Collapse"; /** * @ignore only di */ constructor(translateService: TranslateService, cd: ChangeDetectorRef, assetSelectorService: AssetSelectorService); /** * @ignore */ ngOnInit(): Promise; /** * Opens a node. */ click(): void; setupBreadcrumbsAndLevel(node: GroupNode): void; /** * Selects the node and emits a change on the parent component. * @param node The node to select. */ selected(node: GroupNode): void; /** * Handles clicks on a item in Miller View. * @param node The node that was clicked. */ millerViewClick(node: GroupNode): void; /** * @ignore */ ngOnDestroy(): void; isSelected(): boolean; isActive(): boolean; private updateSelection; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class AssetSelectorBase { protected groupNodeService: GroupNodeService; protected inventory: InventoryService; protected assetSelectorService: AssetSelectorService; /** * Config object containing all options for the asset selector. */ config: AssetSelectorOptions; /** * An array of predefined nodes. */ selected: Array> | IIdentified[] | IIdentified; /** * The loading state of the current node. */ isLoading: boolean; /** * Emit the selected asset or assets. */ onSelected: EventEmitter; /** * Emits if the currently selected asset is cleared. */ onClearSelected: EventEmitter; private onChange; private onTouched; constructor(groupNodeService: GroupNodeService, inventory: InventoryService, assetSelectorService: AssetSelectorService); /** * @ignore */ validate(control: AbstractControl): ValidationErrors; /** * @ignore */ writeValue(obj: any): void; /** * @ignore */ registerOnChange(fn: any): void; /** * @ignore */ registerOnTouched(fn: any): void; /** * @ignore */ doBlur(): void; /** * Deselects all expect the given one. * @param selectedMo The selected asset (optional, if empty -> just deselect all). */ deselectAll(selectedMo?: IManagedObject): void; /** * Adds an managed object to the selected array and emits the change. * @param selectedMo The selected asset. */ select(selectedMo: IManagedObject): void; /** * Removes a managed object from the selected array and emits the change. * @param selectedMo The selected asset. */ deselect(selectedMo: IManagedObject): void; /** * Returns the index of the currently selected item. * @param selected All selected items * @param selectedMo The new selected item- * @returns An index, or -1 if not found. */ getIndexOfSelected(selected: Array> | Partial, selectedMo: IIdentified): any; emitChange(selected: IIdentified | IIdentified[], item: IManagedObject, isSelected: boolean): void; createDefaultRootNode(): _c8y_ngx_components_assets_navigator.GroupNode; createManagedObjectRootNode(asset: IIdentified): Promise<_c8y_ngx_components_assets_navigator.GroupNode>; } /** * Displays a hierarchical tree selector for assets. */ declare class AssetSelectorComponent extends AssetSelectorBase implements OnInit { protected groupNodeService: GroupNodeService; protected inventory: InventoryService; protected assetSelectorService: AssetSelectorService; protected cd: ChangeDetectorRef; /** * Config object containing all options for the asset selector. */ config: AssetSelectorOptions; /** * Defines the node, which should be displayed as active. */ active: GroupNode; /** * Used only for miller-view, displays the column level for the current node. * E.g if the index is one, this will be second column. */ index: number; /** * The asset to use as root. */ asset: IIdentified; /** * The selected device. */ selectedDevice: IManagedObject; /** * An array of predefined nodes. */ selected: Array> | IIdentified[] | IIdentified; /** * The node to use as root. You can either set this, or the asset to start from. */ rootNode: GroupNode; /** * All currently selected assets. */ selectedItems: IIdentified[] | IIdentified; container: '' | 'body'; isNodeSelectable: boolean | ((node: IIdentified) => boolean); disabled: boolean; /** * Emits if one item was selected (all currently selected nodes). */ onSelected: EventEmitter; /** * Emits if the currently selected asset is cleared. */ onClearSelected: EventEmitter; /** * Used only for miller view. Emit the selected node and use it as a 'rootNode' for the new column. */ onRowSelected: EventEmitter; /** * Emits the current loading state of the node. */ onLoad: EventEmitter; /** * The current filter applied. */ filterText: string; /** * Displays the global search at all times if the miller view is used * on root group level. */ root: boolean; /** * @ignore */ unsubscribe$: Subject; /** * Returns the current header hight in pixel. */ getHeaderHeight$: BehaviorSubject; readonly ASSET_CONST: "Asset {{ assetId }}"; private header; /** * @ignore only DI */ constructor(groupNodeService: GroupNodeService, inventory: InventoryService, assetSelectorService: AssetSelectorService, cd: ChangeDetectorRef); /** * Checks when a node was selected, if a new column needs to be added. * @param node The node that was clicked. * @param index The current index of this node. * @returns True if the click was handled and a new column was added. */ handleNextMillerViewColumn(node: GroupNode, index: number): boolean; /** * @ignore */ ngOnInit(): Promise; ngOnChanges(changes: SimpleChanges): Promise; /** * @ignore */ ngAfterViewInit(): void; /** * Changes the current root to one level back. */ back(): void; /** * Clears the current filter. */ clearFilters(): void; /** * Clears the currently selected device. */ clearSelectedDevices(): void; isGroupSelected(): boolean; /** * @param nameFilter The name filter to apply. * @param moId The managed object ID to filter by. * @param showUnassignedDevices If true, it will show unassigned devices. * @return The filter query to apply. * @description * This method builds a filter query based on the provided name filter and managed object ID. */ groupNameFilter(nameFilter: string, moId: any, showUnassignedDevices?: boolean): string; /** * Applies a filter. * @param filter The filter to apply. */ applyFilter(filter: string): Promise; /** * Check if the UnassignedDevice node is the rootNode. */ isUnassignedDevicesNode(): boolean; /** * Called when the user resets the search result. */ onSearchResultReset(selectedItem: any): void; /** * Called if the user clicks on a search result. */ onSearchResultClick(mo: IManagedObject): Promise; onLoading(isLoading: boolean): void; onSelect(mo: IManagedObject): void; onDeselect(config: { deselectMode: 'single' | 'all'; mo: IManagedObject; }): void; private updateHeaderHeight; private isElementOrParentHidden; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class MillerViewComponent extends AssetSelectorBase implements OnInit { protected groupNodeService: GroupNodeService; protected inventory: InventoryService; protected assetSelectorService: AssetSelectorService; protected cd: ChangeDetectorRef; /** * Config object containing all options for the asset selector. */ config: AssetSelectorOptions; /** * The asset to use as root. */ asset: IIdentified; /** * The selected devices. */ selectedDevice: IManagedObject; /** * The node to use as root. You can either set this, or the asset to start from. */ rootNode: GroupNode; /** * Emits if the selection changes */ onSelected: EventEmitter; /** * Emits if the currently selected asset is cleared. */ onClearSelected: EventEmitter; /** * @ignore */ millerViewWrapper: ElementRef; /** * The column array will contain all currently selected nodes * which will form the miller view columns (only one per level). */ columns: any[]; /** * The current filter applied. Used for the empty state text in the view. */ filterText: string; /** * Index of the column used to check where to show the loading state. */ columnIndex: number; container: '' | 'body'; configOptionsDefault: AssetSelectorOptions; /** * Cached padding top value to avoid recalculating on every change detection cycle. */ private _cachedPaddingTop; constructor(groupNodeService: GroupNodeService, inventory: InventoryService, assetSelectorService: AssetSelectorService, cd: ChangeDetectorRef); /** * @ignore */ ngOnInit(): Promise; /** * @ignore */ ngOnChanges(changes: SimpleChanges): Promise; /** * Returns the cached padding top value for the miller view header. * The value is calculated once during initialization and when config changes. * * @returns A unit value (as string) that is multiplied by --c8y-unit-base CSS custom property */ getPaddingTop(): string; /** * Create a new column with the selected node as root. */ addNewColumn(node: any): void; /** * Change the loading state of the asset selector. */ onLoad(event: any): void; /** * Add the selected node to the selected array. */ onSelectionChange(event: AssetSelectionChangeEvent): void; /** * Calculates and caches the padding top value based on configuration options. * * The method determines the appropriate header height by considering: * - Whether selected items are shown (showSelected) * - Whether search functionality is enabled (search) * - Whether single column mode is active (singleColumn) * - Whether a label is present (label length > 0) */ private _calculatePaddingTop; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class AssetSelectorModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare class AssetsNavigatorModule { static config(config?: AssetNavigatorConfig): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare class AssetNodeFactory { private service; moduleConfig: AssetNavigatorConfig; constructor(service: AssetNodeService, moduleConfig: AssetNavigatorConfig); get(): AssetNode; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { ASSET_NAVIGATOR_CONFIG, AssetNode, AssetNodeFactory, AssetNodeService, AssetSelectorComponent, AssetSelectorModule, AssetSelectorNodeComponent, AssetsNavigatorAction, AssetsNavigatorModule, CONFIG_OPTIONS_DEFAULT, DeviceGroupService, DynamicGroupNode, GroupNode, GroupNodeService, LoadMoreNode, MillerViewComponent }; export type { AssetNavigatorConfig, AssetNodeMo, AssetSelectionChangeEvent, AssetSelectorOptions, AssetStatus, GroupNodeConfig, MaintenanceStatus }; //# sourceMappingURL=index.d.ts.map