UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

64 lines 2.65 kB
import { InventoryService, IUser, UserService } from '@c8y/client'; import { Observable, Subject } from 'rxjs'; import { AppStateService } from '../ui-state.service'; import { UserPreference } from './user-preference.model'; import * as i0 from "@angular/core"; export declare class UserPreferencesService { private user; private inventory; private appState; currentUser: Observable<IUser>; preferenceChanges$: Subject<UserPreference>; private storage; constructor(user: UserService, inventory: InventoryService, appState: AppStateService); /** * Returns an observable of a user preference with given key. * Emits its initial value first and then updated values when set by user. * @param key The storage key for searched value. * @returns An Observable of a user preference. */ observe<T>(key: string): Observable<T>; /** * Get an Observable value for searched key for current user. * @param key The storage key for searched value. * @returns An Observable with the value of preference. */ get(key: string): Observable<any>; /** * Sets a value in storage for current user. * @param key The storage key for the value to be set. * @param value The storage value to be set. * @returns A promise with saved value. */ set(key: string, value: any): Promise<any>; /** * Get an Observable value of searched key for a specific user. * @param key The storage key for searched value. * @param user The user for whom the search is done. * @returns An Observable with the value of preference. */ getForUser(key: string, user: IUser): Observable<any>; /** * Sets a value in storage for a specific user. * @param key The storage key for the value to be set. * @param value The storage value to be set. * @returns A promise with saved value. */ setForUser(key: string, value: any, user: IUser): Promise<any>; /** * Get a string of key concatenated with username. * @param key The storage key for searched value. * @param user The user for whom the search is done. * @returns A string of key concatenated with username. */ private getRawKey; /** * Gets a proper storage depending on the user roles. * @param user The user for whom the role check is done. * @returns A proper storage. */ private getStorage; static ɵfac: i0.ɵɵFactoryDeclaration<UserPreferencesService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<UserPreferencesService>; } //# sourceMappingURL=user-preferences.service.d.ts.map