Entry class of the LeanIX Reporting Library. An instance of this class is globally available as lx variable.

Example

// The sequence to initialise the library for a report looks like this:
lx.init()
.then(function (setupInfo) {
// Process setupInfo and create config object
var config = {};
lx.ready(config);
});

Constructors

Properties

Accessors

Methods

Constructors

Properties

_currentSetup: any
_latestPublishedState: any
createReportExportData: any
createReportRequirements: any
customDropdownCallbacks: any
dataModelHelpers: DataModelHelpers
doOpenFormModal: any
encodeAllImages: any
encodeImage: any
encodeSvgImage: any
getCurrentStyles: any
getLocationQuery: any
latestFacetsResults: any
latestFocusedElement: any
latestMouseEvent: any
messenger: any
mountCallback: any
mountCallbacks: any
mountCustomDropdownSelectionCallbacks: any
mountDomEventPublishing: any
mountErrorEventPublishing: any
mountExportDataCallback: any
mountFacetsCallbacks: any
mountFacetsResultCallback: any
mountFormModalUpdate: any
mountSetupCallback: any
mountSidepaneClick: any
mountSidepaneClose: any
mountSidepaneFactSheetUpdate: any
mountTableConfigCallback: any
mountUIButtonCallback: any
mountUIElementsButtonClickCallback: any
mountUISelectionCallback: any
mountUISelectionUpdateCallback: any
replaceInterpolations: any
translateHtmlTags: any
validateConfig: any
waitForElement: any

Accessors

  • get currentSetup(): HostReportSetup
  • Getter to receive the current state of the report setup. The object is only available if the report already called a successful init() LxCustomReportLib.init.

    Returns HostReportSetup

  • get latestPublishedState(): any
  • Returns any

Methods

  • Execute a custom GraphQL query to the LeanIX GraphQL API.

    Parameters

    • query: string

      GraphQL query

    • Optional variables: string

      GraphQL variables

    Returns Promise<any>

    A promise that resolves to the resulting data

    Example

    lx.executeGraphQL(`{
    allFactSheets(factSheetType: ITComponent) {
    edges {
    node {
    id
    name
    type
    description
    }
    }
    }
    }`)
  • Allows to make a XHR requests through the parents origin.

    Parameters

    • method: "GET" | "POST" | "PUT"

      GET, PUT and POST requests are permitted. For POST and PUT requests not every endpoint is allowed.

    • path: string

      Relative URL

    • Optional body: any

      Optional body for POST and PUT requests

    • Optional responseType: "text" | "blob"

    Returns Promise<any>

    A promise that resolves to the returned data

  • Returns a formatted currency number according to the users currency settings.

    Parameters

    • value: number

      Value to be formatted

    • Optional minimumFractionDigits: number

      Minimum number of digits to use for the fraction

    • Optional compact: boolean

      Defines whether to show compact display

    • Optional locale: string

      Defines locale info 'de-DE', 'en-EN'

    Returns string

    Currency string

    Example

    lx.formatCurrency(123.50, 2) => '€123.50'
    lx.formatCurrency(12333.50, 0, true) => '€12K'
    lx.formatCurrency(1288893.50, 2, true, 'de-DE') => '1,29 Mio. €'
  • Beta

    Get all Fact Sheets from the GraphQL endpoint.

    Parameters

    • factSheetType: string

      Fact Sheet type that needs to match.

    • attributes: AttributeDescription[]

      Fact Sheet attributes that the response should include.

    • facetSelection: ReportFacetsSelection

      Filter definition for the Fact Sheets, if Composite Filters are defined, they are used instead of the normal Facet Filters.

    • pointsOfView: Record<string, GraphQLPointOfViewInput>

      A record of different point of views and their associated keys that the response should include and will return the Fact Sheets per each point of view key.

    • Optional options: GraphQLOptions

      Optional options to further specify the Fact Sheets

    Returns Promise<ReportAllFactSheetsResponse>

  • Returns the configured or default meta data for a field at a Fact Sheet.

    Parameters

    • fsType: string

      Fact Sheet type

    • fieldName: string

      Name of a Fact Sheet field or relation

    Returns FieldViewMetaData

    Meta data

    Example

    lx.getFactSheetFieldMetaData('Application', 'functionalSuitability')
    // Returns:
    // {
    // values: {
    // perfect: {
    // bgColor: '#fff',
    // color: '#000'
    // }
    // ...
    // }
    // }
    // Getting the actual background color for a field value:
    lx.getFactSheetFieldMetaData('Application', 'functionalSuitability').values['perfect'].bgColor
  • Returns the configured or default meta data for a field of a Fact Sheet relation.

    Parameters

    • fsType: string

      Fact Sheet type

    • relationName: string

      Name of the directed relation

    • fieldName: string

      Name of a field on the relation

    Returns FieldViewMetaData

    Meta data

    Example

    lx.getFactSheetRelationFieldMetaData('Application', 'relApplicationToITComponent', 'technicalSuitability')
    // Returns:
    // {
    // values: {
    // fullyAppropriate: {
    // bgColor: '#fff',
    // color: '#000'
    // }
    // ...
    // }
    // }

    // Getting the actual background color for a field value:
    lx.getFactSheetRelationFieldMetaData(
    'Application',
    'relApplicationToITComponent',
    'technicalSuitability'
    ).values['perfect'].bgColor
  • Get the current filter result.

    Returns any[]

    Current filter result

  • Beta

    Get a list of measurements from the metrics service.

    Parameters

    • Optional nameOnly: boolean

      Set this to true to receive only the measurement names

    Returns Promise<MetricsMeasurement[]>

    A promise that resolves to an array of measurements

  • Beta

    Get raw data for a metrics time series.

    Parameters

    • query: string

      A metrics service query

    Returns Promise<number[][]>

    A promise that resolves to the raw series data

  • This method allows reports to check on users' workspace permissions. Therefore, reports can enable features according to given workspace permissions. See: [Authorization Model]https://docs-eam.leanix.net/docs/authorization-model

    Parameters

    • permissions: string[]

      Shiro permissions string array to check (example: ['BOOKMARKS:CREATE:VISUALIZER', 'BOOKMARKS:CREATE:REPORTS'] creation of diagram bookmarks)

    Returns Promise<{
        [permissionKey: string]: boolean;
    }>

    Promise of all requested permissions as key-value pair of the requested user permissions.

  • Starts initialisation of the reporting framework. Returns a promise which is resolved once initialisation with the framework is finished. The resolved promise contains a ReportSetup instance with information provided to you through the framework. With that information you should be able to set up your report properly. Once that is done the LxCustomReportLib.ready function needs be called to signal that the report is ready to receive and process data and user events.

    Returns Promise<ReportSetup>

    A promise that resolves to the ReportSetup object

  • Check if a given Feature is enabled for the current Workspace.

    Parameters

    • featureId: string

      Feature identifier

    Returns Promise<boolean>

    Boolean expressing if the feature is enabled.

  • Navigate to inventory using provided filters

    Parameters

    Returns void

  • Show a customisable configuration dialog to the user, in which the user can adjust report settings.

    Parameters

    Returns Promise<false | FormModalValues>

    A promise that resolves to the configuration confirmed by the user or to false if the user canceled the configuration

    Example

    const fields = {
    level: {
    type: 'SingleSelect',
    label: 'Level to be displayed',
    options: [
    { value: '1', label: 'First level' },
    { value: '2', label: 'Both levels' }
    ]
    },
    hideEmpty: {
    type: 'Checkbox',
    label: 'Hide empty elements'
    }
    };
    const initialValues = {
    level: '2',
    hideEmpty: false
    };

    lx.openFormModal(fields, initialValues).then((values) => {
    if (values) {
    console.log('Selection:', values.level, values.hideEmpty);
    } else {
    console.log('Selection cancelled');
    }
    });
  • Show a customisable configuration dialog to the user, in which the user can adjust report settings.

    Parameters

    Returns Promise<false | FormModalValues>

    A promise that resolves to the configuration confirmed by the user or to false if the user canceled the configuration

    Example

    const fields = {
    level: {
    type: 'SingleSelect',
    label: 'Level to be displayed',
    options: [
    { value: '1', label: 'First level' },
    { value: '2', label: 'Both levels' }
    ]
    },
    hideEmpty: {
    type: 'Checkbox',
    label: 'Hide empty elements'
    }
    };
    const values = {
    level: '2',
    hideEmpty: false
    };

    const messages = {
    level: {type: 'error', message:'example message'}
    }

    const update = (formModal: lxr.FormModal): lxr.FormModal => {return createFormModal()}

    lx.openFormModal({fields, values, messages, valid: true}, updated).then((values) => {
    if (values) {
    console.log('Selection:', values.level, values.hideEmpty);
    } else {
    console.log('Selection cancelled');
    }
    });
  • This method allows you to open any link in a new browser tab. Only Chrome and Safari allows you to open a new tab out of an iframe. Since reports run inside an iframe, they are not allowed to open links in other browsers. Therefore, the framework allows you to request to open a link. This will show a popup box outside the iframe containing the link. The user can click on it in order to open the link in a new tab.

    It is not possible to directly open the link outside the iframe, since some browsers (e.g. Firefox) show a popup warning whenever a link is opened via a message coming from an iframe.

    Parameters

    • url: string

      Link-URL

    • Optional _target: string

    Returns void

    Deprecated

    _target (target is ignored due to new popup behavior)

    Example

    lx.openLink(this.baseUrl + '/factsheet/Application/28fe4aa2-6e46-41a1-a131-72afb3acf256');
    // The baseUrl can be found in the setup returned by lx.init() like this:
    // lx.init().then(setup => { this.baseUrl = setup.settings.baseUrl });
  • Beta

    This function opens a "new" instance of the report in a separate tab. The state and facet filter parameters can be used as initial values for the new opened instance of the report.

    Parameters

    • state: any

      Custom report state

    • facetSelection: ContextFacetsSelectionState[]

      Facet filter selection (UISelection.facets)

    • Optional name: string

      Preset name of the new report opened in new tab. If not set, falls back to default name.

    Returns void

  • Navigate to a route within the LeanIX single-page app.

    Parameters

    • url: string

      Relative URL within LeanIX to navigate to

    Returns void

  • Beta

    Shows an overlaying sidepane with the provided elements.

    Parameters

    • sidePaneElements: SidePaneElements
    • Optional update: ((factSheetUpdate) => void)
        • (factSheetUpdate): void
        • Parameters

          Returns void

    • Optional onClick: ((sidepaneClick) => void)
        • (sidepaneClick): void
        • Parameters

          Returns void

    Returns void

  • In case the report has some sort of internal state it should be published to the framework. The state will be persisted when the user saves a certain report configuration. Once that report configuration is restored the framework will pass the saved state to the report on initialisation (LxCustomReportLib.init and ReportSetup.savedState)

    Parameters

    • state: any

      Custom report state

    Returns void

  • Signals that the custom report is ready. A configuration must be provided to tell the framework about the requirements of the report (most importantly which data it needs). The provided configuration acts as an interface between the report code and the report framework.

    Parameters

    Returns void

  • Show a dialog to the user to select one or more Fact Sheets.

    Parameters

    Returns Promise<any>

    A promise that resolves to the selected Fact Sheet(s) or to false if the user canceled the selection

  • Send list of Fact Sheets that could not be displayed in the report due to missing data. A warning will be shown the user to inform them of this.

    Parameters

    • excludedFactSheets: any[]

      List of excluded Fact Sheets

    Returns void

  • Display a custom legend for a given number of items. If a legend from a view is currently displayed, the calls to this function are ignored.

    Parameters

    Returns void

    Example Hide

    the spinner that was previously shown via

    lx.showLegend([
    { label: 'foo', bgColor: '#ff0000' },
    { label: 'bar', bgColor: '#0000ff' }
    ])
  • Show toastr of different types, with a custom message and a optional title.

    Parameters

    • type: ToastrType

      toastr type

    • message: string

      message content

    • Optional title: string

      optional title

    Returns void

    Example

    lx.showToastr('error', 'Something went wrong');
    lx.showToastr('warning', 'This is a warning', 'Attention');
  • Track report framework events with amplitude tracking.

    Parameters

    Returns void

    Example

    lx.trackReportEvent(
    {
    type: 'DataChange'
    reportType: 'net.leanix.matrix'
    baseFactSheetType: 'Application'
    view: 'lifecycle'
    cluster: ['relApplicationToBusinessCapability']
    drilldown: ['relToChild']
    }
    );
  • Returns the translation of a custom translation key according to the user's current language. If the translation key can be resolved to a translated string interpolation will be applied. If the translation key resolves to an object the object will be returned.

    Parameters

    • key: string

      Translation key

    • Optional interpolationData: Record<string, string | number>

      Interpolation data

    Returns any

    Translation string or object

    Example

    // For the custom translation json
    {
    "header": {
    "title": "The title",
    "subtitle": "Subtitle",
    "description": "Hello {{name}}"
    }
    }

    lx.translateCustomKey('header.title') // => 'The title'
    lx.translateCustomKey('header') // => { "title": "The title", "subtitle": "Subtitle", "description": "Hello {{name}}" }
    lx.translateCustomKey('header.description', { name: 'John' }) // => 'Hello John'
  • Returns the translation of a Fact Sheet type in singular or plural form. If multiplicity is not provided the singular version will be returned.

    Parameters

    • fsType: string

      Fact Sheet type

    • Optional grammaticalNumber: "singular" | "plural"

      Grammatical number, i.e., 'singular' or 'plural'. Defaults to 'singular'.

    Returns string

    Translation

    Example

    lx.translateFactSheetType('BusinessCapability')            // => 'Business Capability'
    lx.translateFactSheetType('BusinessCapability', 'plural') // => 'Business Capabilities'
  • Returns the translation of a field on a Fact Sheet. In case the field is not present in the translation model, the fieldName would be returned.

    Parameters

    • fsType: string

      Fact Sheet type

    • fieldName: string

      Name of the Fact Sheet field

    Returns string

    Translation

    Example

    lx.translateField('Application', 'release') // => 'Release'
    
  • Returns the translation of a field value for fields with predefined set of values (e.g. Single Select). In case the field value is not present in the translation model, the value would be returned.

    Parameters

    • fsType: string

      Fact Sheet type

    • fieldName: string

      Name of the Fact Sheet field

    • value: string

      Value of this field

    Returns string

    Translation

    Example

    lx.translateFieldValue('Application', 'functionalSuitability', 'appropriate')  // => 'Appropriate'
    
  • Returns the translation of the items a Fact Sheet relation links to. In case the relation is not present in the translation model, the relationName would be returned.

    Parameters

    • relationName: string

      Name of the relation

    Returns string

    Translation

    Example

    lx.translateRelation('relDataObjectToApplication')  // => 'Applications'
    lx.translateRelation('relToChild') // => 'Children'
  • Returns the translation of a field present in a relation. In case the relation is not present in the translation model, the fieldName would be returned.

    Parameters

    • relationName: string

      Name of the relation

    • fieldName: string

      Field of the relation

    Returns string

    Translation

    Example

    lx.translateRelationField('relDataObjectToApplication', 'usage')  // => 'Usage'
    lx.translateRelationField('relApplicationToBusinessCapability', 'functionalSuitability') // => 'Functional Fit'
  • Returns the translation of a field value for fields with predefined set of values (e.g. Single Select) present in a relation. In case the relation, fieldName or fieldValue is not present in the translation model, the fieldValue would be returned.

    Parameters

    • relationName: string

      Name of the relation

    • fieldName: string

      Field of the relation

    • fieldValue: string

      Value of this field

    Returns string

    Translation

    Example

    lx.translateRelationFieldValue('relApplicationToBusinessCapability', 'functionalSuitability', 'appropriate')  // => 'Appropriate'
    
  • In case the report has new requirements towards the report framework it can update the configuration that was initially passed to LxCustomReportLib.ready.

    Parameters

    Returns void

  • A static tableConfig should be returned via ReportConfiguration.tableConfigCallback, but if the tableConfig is dynamic, this function can be used to update it at any time.

    Hint: if the provided attribute is a string field name, which is not present in the data model, this field would be ignored, and not shown as a table column.

    Parameters

    Returns void

Generated using TypeDoc