@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
169 lines • 9.28 kB
TypeScript
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { IManagedObject, InventoryService, IResultList, QueriesUtil } from '@c8y/client';
import { AlertService, ContextData, DynamicComponentService, GroupService, ModalService, NavigatorService, OptionsService, Permissions, Tab, TabsService, Widget } from '@c8y/ngx-components';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { AllowTypeDashboard, ContextDashboard, ContextDashboardManagedObject, ContextDashboardType, DashboardContext, DashboardCopyClipboard } from './context-dashboard.model';
import * as i0 from "@angular/core";
export declare class ContextDashboardService {
private inventory;
private tabs;
private modal;
private translateService;
private router;
private navigator;
private permissions;
private alert;
private dynamicComponent;
private groupService;
private optionsService;
dashboardTabs$: Observable<Tab[]>;
formDisabled$: Observable<boolean>;
readonly REPORT_PARTIAL_NAME = "report_";
copyClipboard: DashboardCopyClipboard;
queriesUtil: QueriesUtil;
readonly VERSION_HISTORY_SIZE_LIMIT = 10;
private readonly INVENTORY_ROLES;
private cache;
private readonly DEFAULT_PAGESIZE;
private readonly FRAGMENT_NAME;
private readonly DASHBOARD_ROUTE_PATH;
private readonly INDEX_SPLIT;
private readonly CACHE_TIMEOUT;
private _formDisabled;
private formDisabledSubject;
private contextDashboardsCache;
private readonly HIDE_TYPE_DASHBOARD_FOR_ASSETS;
get formDisabled(): boolean;
set formDisabled(value: boolean);
constructor(inventory: InventoryService, tabs: TabsService, modal: ModalService, translateService: TranslateService, router: Router, navigator: NavigatorService, permissions: Permissions, alert: AlertService, dynamicComponent: DynamicComponentService, groupService: GroupService, optionsService: OptionsService);
create(dashboardCfg: ContextDashboard, context?: ContextData, name?: string): Promise<ContextDashboardManagedObject>;
detail(dashboardMO: ContextDashboardManagedObject): Promise<IManagedObject>;
update(dashboard: ContextDashboardManagedObject, context?: ContextData): Promise<ContextDashboardManagedObject>;
delete(dashboard: ContextDashboardManagedObject, withConfirmation?: boolean): Promise<void>;
updateDashboardHistory(dashboard: Partial<ContextDashboardManagedObject>, dashboardCfg: ContextDashboard): Partial<ContextDashboardManagedObject>;
activateDashboards(route: ActivatedRouteSnapshot, types: ContextDashboardType[]): Observable<boolean | Tab[]>;
getDashboard(name: string, defaultWidgets: Widget[]): Observable<ContextDashboardManagedObject>;
/**
* @deprecated Use `getDashboard()` instead.
* This function will be removed in the future.
*/
getNamedDashboardOrCreate(name: string, defaultWidgets: Widget[], context?: ContextData): Observable<ContextDashboardManagedObject>;
updateNavigatorItem(mo: IManagedObject): void;
navigateToDashboard(dashboardMO: ContextDashboardManagedObject, isNewDashboard?: boolean): Promise<void>;
/**
* Checks if user is able to edit dashboard according to his roles and dashboard ownership.
*
* @param mo - Dashboard managed object.
* @returns True if user is able to edit dashboard, false if he cannot.
*/
canEditDashboard(mo: ContextDashboardManagedObject): Promise<boolean>;
/**
* Checks if user has permissions to copy dashboard according to his roles.
*
* @returns True if user has permissions to copy dashboard, false if he cannot.
*/
hasPermissionsToCopyDashboard(): boolean;
isNamed(dashboard: Partial<ContextDashboardManagedObject>): any;
isReport(dashboard: Partial<ContextDashboardManagedObject>): any;
isDeviceType(dashboard: Partial<ContextDashboardManagedObject>): any;
isDeviceDashboard(dashboard: Partial<ContextDashboardManagedObject>): boolean;
isGroupDashboard(dashboard: Partial<ContextDashboardManagedObject>): boolean;
getFilteredDashboardStyles(styleList: string[]): string[];
getStyling(styleList: any, styleName: any, defaultValue: any): any;
mapWidgets(widgets: Widget[]): any;
getDashboard$(dashboardIdOrName: any, dashboardType: ContextDashboardType[], mo?: IManagedObject): Observable<ContextDashboardManagedObject>;
pasteDashboard(newContext: DashboardContext): Promise<void>;
/**
* Creates fragment that associates dashboards with device/asset. It consists of three elements:
* - FRAGMENT_NAME - static string
* - dashboard type (e.g. 'group', 'device')
* - fragment value ( id of device/asset if it is not typed dashboard; deviceTypeValue property of dashboard if it is type dashboard)
* Example fragment for device dashboard: 'c8y_Dashboard!device!773200'
* Example fragment for group dashboard: 'c8y_Dashboard!group!84129208'
* Example fragment for typed device dashboard: 'c8y_Dashboard!type!c8y_lwm2m_connector_device'
*
* @param contextDashboardType Type of dashboard
* @param value Fragment value
* @returns Fragment for dashboard
*/
createFragmentKey<T extends ContextDashboardType, V extends string>(contextDashboardType: T, value: V): `c8y_Dashboard!${T}!${V}`;
/**
* Indicates if dashboard can be set to type dashboard.
* First, it checks if deviceTypeValue exists and if user has permission to set dashboard type.
* Then, case from sensor app is checked- dashboard created with sensor app has deviceType set to true but
* type fragment is missing- we do not support this combination.
* @param mo Dashboard managed object
* @param context {ContextData} Current context
* @returns True if dashboard can be set to type dashboard, false if it is forbidden.
*/
shouldAllowToSetDashboardType(mo: ContextDashboardManagedObject, context: ContextData): AllowTypeDashboard;
createReport(reportCfg: Partial<IManagedObject>): Promise<import("@c8y/client").IResult<IManagedObject>>;
addReportNavigatorNode(report: IManagedObject): void;
getContextForGS(mo: IManagedObject): string | null;
getContextDashboards(mo: IManagedObject, dashboardType: ContextDashboardType[]): Promise<IResultList<IManagedObject>>;
/**
* Creates a tuple describing the dashboard type and its fragments. For assets like devices and groups, it's possible
* to have two fragments: one indicating this particular device/asset with its ID, and the second indicating
* the device/asset type (if the dashboard is meant to be applied to all assets of this type).
*
* @param dashboardMO - Dashboard managed object.
* @param context - Context data of asset.
* @param name - Name of the dashboard.
* @param isEdit - True if existing dashboard is updated, false when it's creation of new dashboard.
* @returns Tuple of dashboard type and object containing dashboard fragments.
*/
private getDashboardFragments;
/**
* Clears fragments that originates from other managed object.
* E.g. typed dashboard is created for device A of type c8y_MQTTDevice and id 1, so it gets fragments object
* ```ts
* {
* c8y_Dashboard!device!1: {},
* c8y_Dashboard!type!c8y_MQTTDevice: {}
* }
*```
* then, on device B of type c8y_MQTTDevice and id 2, which also has access to this dashboard, deviceType is set to
* false, so dashboard is not typed dashboard anymore and now belongs to device B, therefore fragments should look like
* ```ts
* {
* c8y_Dashboard!device!1: null, // this value is cleared because dashboard is doesn't belong to device A anymore
* c8y_Dashboard!device!2: {}, // assign dashboard to device B
* c8y_Dashboard!type!c8y_MQTTDevice: null // this value is cleared in getDashboardFragments method as it's not typed dashboard anymore
* }
* ```
*
* @param dashboardMO - Dashboard managed object.
* @param type - Context dashboard type.
* @param fragments - Fragments object.
*/
private clearRedundantFragment;
/**
* Used to migrate dashboards from previous 12 columns layout to 24 columns.
*/
private adjustDashboardFor24Columns;
private serializeWidgetConfigs;
private createContextDashboardCopy;
private copyProperties;
private replaceContextInDataPoints;
private replaceContextInObj;
private getTabs$;
private verifyDashboardAvailability$;
private getContextDashboards$;
/**
* Cleans already corrupted dashboards from dashboardMo property.
* Added to fix dashboards on the cloud instance (eu-latest).
* @deprecated This is going to be removed after 1007.7.0.
*/
private removeDashboardMoProperty;
private cacheDashboard;
private createDashboardTab;
private clean;
private getNamedDashboard;
private createDashboardFragment;
private shouldSetGlobal;
private getDefaultDashboard;
static ɵfac: i0.ɵɵFactoryDeclaration<ContextDashboardService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ContextDashboardService>;
}
//# sourceMappingURL=context-dashboard.service.d.ts.map