Interface ComponentContext<ComponentContextInputs>

The Component Context provides access to the component's inputs, the page's time range, to the LoggingDataClient and ResourceDataClient and to other application data.

interface ComponentContext {
    appData: ComponentContextAppData;
    componentBaseUrl: string;
    destroyed: boolean;
    inputMap: Map<string, any>;
    inputs: ComponentContextInputs;
    mode: "view" | "edit";
    ontimerangechange: null | ((newTimeRange) => any);
    onvpnclientstatuschange: null | ((newStatus) => any);
    timeRange: LoggingDataTimeRange;
    timeRangeIsAdjustable: boolean;
    vpnClientStatus: null | VpnClientStatus;
    createBackendComponentClient(): BackendComponentClient;
    createLoggingDataClient(): LoggingDataClient;
    createObjectStorageClient(): ObjectStorageClient;
    createResourceDataClient(): ResourceDataClient;
    createTooltip(target, options): Tooltip;
    destroy(): void;
    getApiUrl(rel, params?): string;
    navigateByUrl(url): void;
    openAlertDialog(options): Promise<undefined | true>;
    openConfirmDialog(options): Promise<undefined | boolean>;
    openFormDialog(options): Promise<undefined | false | FormDialogResult>;
    saveAsFile(data, fileName): void;
    setTimeRange(timeRange): void;
    showVpnStatusDetails(agentId): void;
    testVpnAccess(agentId): boolean;
    toggleVpn(agentId): void;
    translate(key, interpolateParams?, options?): string;
    translate<T>(key, interpolateParams?, options?): Record<T, string>;
    translate<T>(key, interpolateParams?, options?): string | Record<T, string>;
}

Type Parameters

  • ComponentContextInputs extends object = {
        [key: string]: any;
    }

Properties

Application data.

componentBaseUrl: string

The component's base URL. This can be used to compose an absolute URL to a static component asset.

For example:

new URL('./static/image.png', context.componentBaseUrl).href;
destroyed: boolean

True if destroy is called and has destroyed all clients.

inputMap: Map<string, any>

Values for the inputs declared in the components manifest file as a Javascript Map.

inputs: ComponentContextInputs

Values for the inputs declared in the components manifest file

mode: "view" | "edit"

'edit' when the component is used in the Studio, else 'view'.

ontimerangechange: null | ((newTimeRange) => any)

Called when the time range is changed

Type declaration

onvpnclientstatuschange: null | ((newStatus) => any)

Called when the VPN client status changes

Type declaration

Snapshot of the current time range

timeRangeIsAdjustable: boolean

If the time range is adjustable.

vpnClientStatus: null | VpnClientStatus

Snapshot of the current VPN client status.

Methods

  • Creates a client to retrieve logging data.

    Every time this method is called, a new client is created.

    Returns LoggingDataClient

  • Attaches a tooltip on the target element.

    Parameters

    • target: HTMLElement

      the target element

    • options: TooltipOptions

      configures the tooltip message and other (optional) properties

    Returns Tooltip

    returns the tooltip instance

  • Destroy the clients associated to this context and destroy the context.

    Returns void

  • Get the endpoint for a resource, the rel.

    Parameters

    • rel: string

      The name of the resource, see the reference for all resource relations.

    • Optional params: {
          [param: string]: string;
      }

      Extra query parameters, see the reference for all the URL and query paramaters that can be used for a specific resource.

      • [param: string]: string

    Returns string

  • Use this method to navigate to a specific page in the portal, for example the VNC-viewer. Don't use this method to navigate to navigate outside the Portal.

    Parameters

    • url: string

      The URL to navigate to, don't include the host.

    Returns void

  • Opens an alert dialog.

    Parameters

    Returns Promise<undefined | true>

  • Opens a confirmation dialog.

    Parameters

    Returns Promise<undefined | boolean>

  • Save a file.

    Parameters

    • data: string | Blob

      the file data to save

    • fileName: string

      the name of the file

    Returns void

  • Set a new time range. Check timeRangeIsAdjustable to verify the time range is adjustable

    Parameters

    Returns void

  • Open a dialog with VPN status details for an agent.

    Parameters

    • agentId: string

      The agent to show VPN status info for

    Returns void

  • Tests whether the currently logged in user has VPN access to the Agent with the given {@code agentId}.

    Parameters

    • agentId: string

      the Agent ID

    Returns boolean

    true if the user has access, false otherwise

  • Connects or disconnects the VPN-client

    Parameters

    • agentId: string

      The public ID of the agent to connect to or disconnect from.

    Returns void

  • Translate a key to the user's language.

    Parameters

    Returns string

  • Type Parameters

    • T extends string

    Parameters

    Returns Record<T, string>

  • Type Parameters

    • T extends string

    Parameters

    • key: string | T[]
    • Optional interpolateParams: Object
    • Optional options: TranslateOptions

    Returns string | Record<T, string>