File

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

Index

Properties

Properties

destination
destination: string
Type : string
source
source: string
Type : string
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 ""