@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
296 lines (289 loc) • 12.1 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit, OnDestroy, TemplateRef, PipeTransform } from '@angular/core';
import { OnBeforeSave } from '@c8y/ngx-components';
import { IApplication } from '@c8y/client';
import { FormArray } from '@angular/forms';
import { Observable } from 'rxjs';
interface IQuickLink {
icon: string;
label: string;
url: string;
newTab: boolean;
app?: IApplication;
}
type QuickLinksConfig = {
links: IQuickLink[];
displayOption: DisplayOptionType;
translateLinkLabels: boolean;
};
declare const QuickLinkDisplayOption: {
readonly GRID: "Grid";
readonly LIST: "List";
};
type DisplayOptionType = (typeof QuickLinkDisplayOption)[keyof typeof QuickLinkDisplayOption];
declare const DEFAULT_DISPLAY_OPTION_VALUE: "Grid";
declare const DEFAULT_QUICK_LINK_ICON = "link";
declare const HELP_AND_SERVICE_WIDGET_ID: "HelpAndService";
declare const APPLICATIONS_WIDGET_ID: "Applications";
declare const QUICK_LINKS_DEVICE_MANAGEMENT_ID: "devicemanagement.welcome.widget";
type ConvertibleWidgetID = typeof HELP_AND_SERVICE_WIDGET_ID | typeof APPLICATIONS_WIDGET_ID | typeof QUICK_LINKS_DEVICE_MANAGEMENT_ID;
type DefaultDeviceManagementQuickLinkDefinition = {
navPath: string[];
overrides?: QuickLinkOverrides;
};
interface QuickLinkOverrides {
label?: string;
icon?: string;
url?: string;
}
declare const URL_VALIDATOR_PATTERN: RegExp;
type WidgetConversionConfig = {
convertWidget: () => void;
};
declare class QuickLinksWidgetConfigComponent implements OnInit, OnBeforeSave, OnDestroy {
config: i0.InputSignal<QuickLinksConfig>;
quickLinksForm: ReturnType<QuickLinksWidgetConfigComponent['initForm']>;
selectedDisplayOption: DisplayOptionType;
appsNameChanged: i0.WritableSignal<IApplication[]>;
addLinkIsCollapsed: boolean;
set previewSet(template: TemplateRef<any>);
private destroy$;
readonly DEFAULT_QUICK_LINK_ICON = "link";
readonly DisplayOption: {
readonly GRID: "Grid";
readonly LIST: "List";
};
private readonly CHANGE_DEFAULT_ICON_LABEL;
private readonly SAVE_CHANGES_LABEL;
get quickLinksFormArray(): FormArray;
private readonly quickLinksService;
private readonly modalService;
private readonly humanizeAppNamePipe;
private readonly interAppService;
private readonly formBuilder;
private readonly translateService;
private readonly widgetConfigService;
private readonly parentForm;
ngOnInit(): void;
ngOnDestroy(): void;
getQuickLinks(): IQuickLink[];
addQuickLink(link: IQuickLink): void;
onBeforeSave(config?: QuickLinksConfig): Promise<boolean>;
assignLinksToConfig(): void;
resetLinks(): void;
private onInitConfig;
private setupQuickLinksForm;
private confirmAppIconChanges;
private initForm;
static ɵfac: i0.ɵɵFactoryDeclaration<QuickLinksWidgetConfigComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<QuickLinksWidgetConfigComponent, "c8y-quick-links-widget-config", never, { "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}
declare class QuickLinksWidgetViewComponent implements OnInit {
config: i0.InputSignal<QuickLinksConfig>;
isPreview: i0.InputSignal<boolean>;
protected readonly DEFAULT_QUICK_LINK_ICON = "link";
protected readonly DisplayOption: {
readonly GRID: "Grid";
readonly LIST: "List";
};
private readonly quickLinksService;
private readonly dashboardChild;
private readonly appSwitcherService;
private readonly appHrefPipe;
private readonly humanizeAppNamePipe;
ngOnInit(): void;
/**
* The method is responsible for converting legacy widgets into their updated versions if a conversion is required.
*
* The widgets are being converted:
* - Help and Service Widget
* - Applications Widget
* - Quick Links - Device Management Widget
*/
private convertLegacyWidget;
/**
* Converts the Device Management Quick Links widget by assigning default quick links for the device management app
* and updating the widget configuration with default options.
*/
private convertDeviceManagementQuickLinksWidget;
/**
* Converts the Applications widget by assigning default quick links
* and updating the widget configuration with default options.
*/
private convertApplicationsWidget;
/**
* Converts the Help and Service widget by assigning default quick links
* and updating the widget configuration with default options.
*/
private convertHelpAndServiceWidget;
/**
* Determines whether conversion is required for the widget.
* Conversion is needed if the widget configuration is empty and a valid widget ID exists.
*
* @returns `true` if conversion is required, otherwise `false`.
*/
private isConversionRequiredForWidget;
/**
* Retrieves the widget ID from the dashboard child data.
* If `componentId` is available, it is returned; otherwise, the widget's `name` is used.
*
* @returns The widget ID as a `ConvertibleWidgetID`, based on `componentId` or `name`.
*/
private getWidgetId;
static ɵfac: i0.ɵɵFactoryDeclaration<QuickLinksWidgetViewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<QuickLinksWidgetViewComponent, "c8y-quick-links-widget-view", never, { "config": { "alias": "config"; "required": false; "isSignal": true; }; "isPreview": { "alias": "isPreview"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}
/**
* Service for managing quick links in Cockpit and Device Management applications.
* It fetches, processes, and provides quick links to relevant documentation and navigation nodes.
*/
declare class QuickLinksService {
private navNodes;
private readonly docsService;
private readonly navigatorService;
private readonly labelsToFilterOutInDeviceManagement;
/**
* Retrieves the default quick links for Cockpit Application.
*
* @returns An observable emitting an array of quick links.
*/
getDefaultQuickLinks$(): Observable<IQuickLink[]>;
/**
* Retrieves default quick links for Device Management Application
*
* @returns An observable emitting an array of quick links for device management.
*/
getQuickLinksForDeviceManagement$(): Observable<IQuickLink[]>;
/**
* Fetches documentation links for Cockpit Application and sorts them by priority.
*
* @returns An observable emitting an array of documentation links.
*/
private getDocLinks$;
/**
* Processes and modifies documentation links.
*
* @param links - Array of documentation links.
* @param navigatorNodes - Array of navigation nodes.
*
* @returns An array of processed documentation links.
*/
private handleDocLinks;
/**
* Creates a quick link for adding a group if the "Groups" node is present.
*
* @param navigatorNodes - Array of navigation nodes.
* @returns A `DocLink` for adding a group or `undefined`.
*/
private createAddGroupDocLink;
/**
* Retrieves additional documentation links related to device management.
*
* @returns An observable that emits a list of processed documentation links.
*/
private getAdditionalDocLinksForDeviceManagement$;
/**
* Prepares documentation links by replacing some links with a main one and filtering out irrelevant links.
*
* @param links - The list of documentation links to process.
* @returns The processed list of documentation links.
*/
private prepareDocLinksForDeviceManagement;
/**
* Filters out documentation links that should not be included in device management.
*
* @param links - The list of documentation links to filter.
* @returns The filtered list of documentation links.
*/
private filterOutDocsLinksForDeviceManagement;
/**
* Replaces the first occurrence of a documentation link with a main user guide link.
*
* @param links - The list of documentation links to process.
* @returns The modified list of documentation links.
*/
private replaceDocsLinksWithMainOne;
/**
* Checks if a URL is valid.
*
* @param url - The URL string to validate.
* @returns `true` if the URL is valid, otherwise `false`.
*/
private isValidURL;
/**
* Determines if a link belongs to the current application.
*
* @param link - The documentation link to check.
* @returns `true` if the link is for the current app, otherwise `false`.
*/
private isLinkForCurrentApp;
/**
* Finds a navigation node by its label.
*
* @param nodeName - Label of the node to find.
* @param navNodes - Array of navigation nodes.
*
* @returns The found navigation node.
*/
private findNavigatorNode;
/**
* Retrieves the default quick links for device management.
*
* This method returns an array of predefined quick link definitions
* used for navigation within the device management section of the application.
*
* Each quick link is defined by a navigation path (`navPath`), and optionally
* includes override properties such as a custom label, icon, or URL.
*
* @returns An array of quick link definitions.
*/
private getDefaultQuickLinksForDeviceManagement;
/**
* Fetches documentation links for Device Management Application and sorts them by priority.
*
* @returns An observable emitting an array of documentation links.
*/
private getSortedDocLinksForDeviceManagement;
/**
* Creates a document link based on the given navigation node path labels.
*
* @param navNodePathLabels - An array of strings representing the path labels used to find the navigation node.
* @param quickLinkOverrides - An optional partial object of `DocLink` properties that can override the defaults.
* @param navNodes - An array of `NavigatorNode` objects to search within for the navigation node.
*
* @returns A `DocLink` object with the details of the found navigation node, or `undefined` if no matching node is found.
*/
private createDocLinkToNavNode;
/**
* Ensures the given path starts with a leading slash.
*
* @param path - The path to check.
* @returns The path with a leading slash.
*/
private ensureLeadingSlash;
/**
* Recursively searches for a visible navigation node that matches the given path labels.
*
* @param navNodePathLabels - An array of labels representing the navigation path.
* This array is mutated as elements are shifted during recursion.
* @param navNodes - An array of `NavigatorNode` objects to search within. Defaults to `this.navNodes`.
*
* @returns The found `NavigatorNode`.
*/
private findVisibleNavNode;
static ɵfac: i0.ɵɵFactoryDeclaration<QuickLinksService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<QuickLinksService>;
}
declare class RelativeUrlParserPipe implements PipeTransform {
transform(url: string): string;
private isFullUrl;
private isRelativeToBaseUrl;
private isRelativeUrl;
private isAppUrl;
private isQueryParameter;
static ɵfac: i0.ɵɵFactoryDeclaration<RelativeUrlParserPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<RelativeUrlParserPipe, "relativeUrlParser", true>;
}
export { APPLICATIONS_WIDGET_ID, DEFAULT_DISPLAY_OPTION_VALUE, DEFAULT_QUICK_LINK_ICON, HELP_AND_SERVICE_WIDGET_ID, QUICK_LINKS_DEVICE_MANAGEMENT_ID, QuickLinkDisplayOption, QuickLinksService, QuickLinksWidgetConfigComponent, QuickLinksWidgetViewComponent, RelativeUrlParserPipe, URL_VALIDATOR_PATTERN };
export type { ConvertibleWidgetID, DefaultDeviceManagementQuickLinkDefinition, DisplayOptionType, IQuickLink, QuickLinksConfig, WidgetConversionConfig };
//# sourceMappingURL=index.d.ts.map