src/app/shared/widgets/widget.configuration.ts
Properties |
|
_embedded |
_embedded:
|
Type : literal type
|
Optional |
_links |
_links:
|
Type : literal type
|
Optional |
actions |
actions:
|
Type : literal type
|
Optional |
animationDelay |
animationDelay:
|
Type : number
|
Optional |
animationEnabled |
animationEnabled:
|
Type : boolean
|
Optional |
channels |
channels:
|
Type : [SimpleChannelMapping]
|
Optional |
component |
component:
|
Type : string
|
configuration |
configuration:
|
Type : T
|
elementClass |
elementClass:
|
Type : string
|
Optional |
elementClassModifiers |
elementClassModifiers:
|
Type : string[]
|
Optional |
footer |
footer:
|
Type : WidgetConfig
|
Optional |
header |
header:
|
Type : WidgetConfig
|
Optional |
hostClass |
hostClass:
|
Type : string
|
Optional |
hostClassModifiers |
hostClassModifiers:
|
Type : string[]
|
Optional |
id |
id:
|
Type : string
|
infoHeight |
infoHeight:
|
Type : string
|
Optional |
infoText |
infoText:
|
Type : string
|
Optional |
infoTitle |
infoTitle:
|
Type : string
|
Optional |
infoToolTip |
infoToolTip:
|
Type : string
|
Optional |
infoWidth |
infoWidth:
|
Type : string
|
Optional |
inputs |
inputs:
|
Type : [InputChannelMapping]
|
Optional |
outputs |
outputs:
|
Type : [OutputChannelMapping]
|
Optional |
overlayScrollbarActive |
overlayScrollbarActive:
|
Type : boolean
|
Optional |
pageTitle |
pageTitle:
|
Type : string
|
Optional |
wikiLink |
wikiLink:
|
Type : string
|
Optional |
import { Link } from "../components/hal/hal";
import { Widget } from "./configuration";
export interface SimpleChannelMapping {
source: string;
destination: string;
}
export interface ChannelMapping {
channel: string;
}
export interface InputChannelMapping extends ChannelMapping {
type: "input";
source: string;
}
export interface OutputChannelMapping extends ChannelMapping {
type: "output";
destination: string;
}
export interface WidgetConfig<T = { [key: string]: any }> {
id: string;
component: string;
configuration: T;
hostClass?: string;
hostClassModifiers?: string[];
elementClass?: string;
elementClassModifiers?: string[];
pageTitle?: string;
infoTitle?: string;
infoText?: string;
infoWidth?: string;
infoHeight?: string;
infoToolTip?: string;
wikiLink?: string;
overlayScrollbarActive?: boolean;
channels?: [SimpleChannelMapping];
inputs?: [InputChannelMapping];
outputs?: [OutputChannelMapping];
header?: WidgetConfig;
animationDelay?: number;
animationEnabled?: boolean;
actions?: {
alignment?: string;
elements: WidgetConfig[];
};
footer?: WidgetConfig;
_embedded?: {
[key: string]: WidgetConfig;
};
_links?: {
[key: string]: Link | Link[];
};
}
export function getOrDefault(value, defaultValue) {
if (value !== undefined) {
return value;
}
return defaultValue;
}
export function throwIfUndefined(value) {
if (value === undefined) {
console.error(
"Value is not allowed to be undefined. Please check your configuration"
);
}
return value;
}
/**
* Throws an error if given property is undefined. Use this function over throwIfUndefined since it gives better output
* @param paramName the name of the parameter
* @param value the object to extract the value from
*/
export function throwErrorIfUndefined(paramName, configuration) {
const value = configuration[paramName];
if (value === undefined) {
console.error(
`Configuration property ${paramName} is required but was not found in`,
configuration
);
}
return value;
}