UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

124 lines 5.65 kB
import { InjectionToken } from '@angular/core'; import { ApplicationOptions } from './ApplicationOptions'; import { ExtensionFactory, GenericHookType, GenericHookOptions } from './extension-hooks'; import { SystemOptionsService, TenantOptionsService } from '@c8y/client'; import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; /** * @deprecated Consider using the `hookOptions` function instead. */ export declare const HOOK_OPTIONS: InjectionToken<ExtensionFactory<ApplicationOptions>>; /** * You can either provide a single `ApplicationOptions` as parameter: * ```typescript * hookOptions(...) * ``` * * Or an array to directly register multiple: * ```typescript * hookOptions([...]) * ``` * * Or you provide an Service that implements `ExtensionFactory<ApplicationOptions>` * ```typescript * export class MyApplicationOptionsFactory implements ExtensionFactory<ApplicationOptions> {...} * ... * hookOptions(MyApplicationOptionsFactory) * ``` * A typed alternative to `HOOK_OPTIONS`. * @param options The `ApplicationOptions`'s or `ExtensionFactory` to be provided. * @returns An `Provider` to be provided in your module. */ export declare function hookOptions(options: GenericHookType<ApplicationOptions>, hookOptions?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider; /** * A service that allows to set or get application options * which configure the default behavior of the UI. */ export declare class OptionsService extends ApplicationOptions { private systemOptionsService; private tenantOptionService; optionsUpdated$: Observable<void>; [key: string]: any; private _optionsUpdated$; constructor(options: any, systemOptionsService: SystemOptionsService, tenantOptionService: TenantOptionsService); /** * Returns an application option used to configure the UI. * @param optionKey The application options key. * @param defaultValue A value to return if non is set. * @param attemptParse Indicates whether the value should be parsed with JSON.parse. */ get<T extends keyof OptionsService>(optionKey: T, defaultValue?: OptionsService[T], attemptParse?: boolean): OptionsService[T]; /** * Returns an observable of an application option used to configure the UI. * @param optionKey The application options key. * @param defaultValue A value to return if non is set. * @param attemptParse Indicates whether the value should be parsed with JSON.parse. */ get$<T extends keyof OptionsService>(optionKey: T, defaultValue?: OptionsService[T], attemptParse?: boolean): Observable<OptionsService[T]>; /** * Sets an application option. * @param key The key to set. * @param value The value to set. */ set<T extends keyof OptionsService>(key: T, value: OptionsService[T]): void; /** * Deletes an application option. * @param key The key to remove. */ delete<T extends keyof OptionsService>(key: T): void; /** * Gets support URL from: * - application option: `supportUrl` * - or current tenant's option: `configuration / system.support.url` * - or current tenant's inherited option: `configuration / system.support.url` * - or system option: `configuration / system.support.url` * - otherwise defaults to: `false` * * @returns Returns support url or false. */ getSupportUrl(): Promise<string | boolean>; /** * Returns if the tenant allows to show the activate-support user menu entry. * Note: Only if system-level support-user/enabled is false we can activate it at tenant level. */ getActivateSupportUser(): Promise<boolean>; /** * Gets a value from the system service and parses it. * * @param category The category for this option. * @param key The key for that option. * @param defaultValue The default if the option was not found. */ getSystemOption<T = string>(category: string, key: string, defaultValue?: T): Promise<T | string>; /** * Gets a value from the tenant service and parses it. * * @param category The category for this option. * @param key The key for that option. * @param defaultValue The default if the option was not found. */ getTenantOption<T = string>(category: string, key: string, defaultValue?: T): Promise<T | string>; /** * Gets an inherited from parent value from the tenant service if inheritance supported based on given parameters. * * @param category The category for this option. * @param key The key for that option. * @param defaultValue The default if the option was not found. */ getInheritedTenantOption<T = string>(category: string, key: string, defaultValue?: T): Promise<T | string>; /** * Gets current tenant option value from the tenant service omitting the inheritance supported based on given parameters. * * @param category The category for this option. * @param key The key for that option. * @param defaultValue The default if the option was not found. */ getCurrentTenantOption<T = string>(category: string, key: string, defaultValue?: T): Promise<T | string>; private setupOptions; private applyOptions; private getOptionFromService; private parseOptionRawValue; static ɵfac: i0.ɵɵFactoryDeclaration<OptionsService, [{ optional: true; }, null, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<OptionsService>; } //# sourceMappingURL=options.service.d.ts.map