File

src/app/shared/widgets/widget.configuration.ts

Index

Properties

Properties

_embedded
_embedded: literal type
Type : literal type
Optional
_links
_links: literal type
Type : literal type
Optional
actions
actions: literal type
Type : literal type
Optional
animationDelay
animationDelay: number
Type : number
Optional
animationEnabled
animationEnabled: boolean
Type : boolean
Optional
channels
channels: [SimpleChannelMapping]
Type : [SimpleChannelMapping]
Optional
component
component: string
Type : string
configuration
configuration: T
Type : T
elementClass
elementClass: string
Type : string
Optional
elementClassModifiers
elementClassModifiers: string[]
Type : string[]
Optional
footer
footer: WidgetConfig
Type : WidgetConfig
Optional
header
header: WidgetConfig
Type : WidgetConfig
Optional
hostClass
hostClass: string
Type : string
Optional
hostClassModifiers
hostClassModifiers: string[]
Type : string[]
Optional
id
id: string
Type : string
infoHeight
infoHeight: string
Type : string
Optional
infoText
infoText: string
Type : string
Optional
infoTitle
infoTitle: string
Type : string
Optional
infoToolTip
infoToolTip: string
Type : string
Optional
infoWidth
infoWidth: string
Type : string
Optional
inputs
inputs: [InputChannelMapping]
Type : [InputChannelMapping]
Optional
outputs
outputs: [OutputChannelMapping]
Type : [OutputChannelMapping]
Optional
overlayScrollbarActive
overlayScrollbarActive: boolean
Type : boolean
Optional
pageTitle
pageTitle: string
Type : string
Optional
wikiLink
wikiLink: string
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;
}

results matching ""

    No results matching ""