@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
123 lines • 3.64 kB
TypeScript
import { Route as ngRoute } from '@angular/router';
import { IIdentified, IResult, IResultList } from '@c8y/client';
import { ExtensionFactory } from '../common/extension-hooks';
import { Tab, TabWithTemplate } from '../tabs/tab.model';
import { Injector, Type } from '@angular/core';
export interface ContextData {
/**
* The data of this route. E.g. on ViewContext.Device an managed object
* of the device.
*/
contextData: IIdentified;
/**
* The current ViewContext used.
*/
context: ViewContext;
}
/**
* The context routes that are supported by the application.
*/
export declare enum ViewContext {
Device = "device/:id",
Group = "group/:id",
User = "users/:id",
Application = "ecosystem/application/applications/:id",
Extension = "ecosystem/extension/extensions/:id",
Feature = "ecosystem/application/features/:id",
Microservice = "ecosystem/microservice/microservices/:id",
SubscribedApplications = "subscribedApplications/:id",
Tenant = "tenants/:id",
Report = "reports/:id",
Service = "service/:id",
DatapointLibrary = "datapointlibrary/:id",
Simulators = "simulators/:id",
Alarms = "alarms/:id",
GroupAlarms = "group/:id/alarms/:id",
DeviceAlarms = "device/:id/alarms/:id",
ServiceAlarms = "service/:id/alarms/:id",
SimulatorsAlarms = "simulators/:id/alarms/:id",
Dashboard = "dashboard/:dashboardId"
}
export interface ViewContexServiceConfig {
[key: string]: {
/**
* Defines if the route is automatically generated by the router service or
* if the route is somewhere defined by the developer.
*/
autoRoute: boolean;
/**
* The path used to route.
*/
path: string;
/**
* The @c8y/client service to use for this context.
*/
service: Type<{
detail(entityOrId: string | number | IIdentified, filter?: object): Promise<IResult<IIdentified>>;
list(filter?: object): Promise<IResultList<IIdentified>>;
}>;
};
}
/**
* A ViewContext base route.
*/
export type ViewContextRootRoute = Route & {
rootContext: ViewContext;
};
/**
* A route that can be added via the HOOK_ROUTE.
*/
export type Route = RouteDefault | RouteWithTab | RouteWithComponent;
/**
* A usual route
*/
export interface RouteDefault extends ngRoute {
context?: never;
label?: never;
tabs?: never;
}
interface RouteBase {
/**
* Which order should be used.
*/
priority?: number;
/**
* Id to identify specific feature.
*/
featureId?: string;
/**
* The injector to use. If not set, the default root injector will be used.
*/
_injector?: Injector;
/**
* An optional root context for hooks to apend children to this route.
*/
rootContext?: ViewContext;
}
/**
* A component based context route.
*/
export interface RouteWithComponent extends ngRoute, RouteBase {
/**
* The view context to add this route to.
*/
context: ViewContext;
label?: never;
}
/**
* A tab that is added to a context route and opens the associated
* component on this context.
*/
export interface RouteWithTab extends Omit<TabWithTemplate<string | any[]>, 'injector' | 'path' | 'component'>, ngRoute, RouteBase {
/**
* The view context to add this route to.
*/
context: ViewContext;
/**
* Allow to emit multiple tabs on one context route.
*/
tabs?: Tab[];
}
export type RouteFactory = Route | Route[] | ExtensionFactory<Route>;
export {};
//# sourceMappingURL=router.model.d.ts.map