mobile menu
Information

Widget Dependencies

You are here
Dependencies

Dependencies

There are three types of dependency that can currently be specified.

Calendar Conditions

    Calendar conditions can be set in MCS and can be used in a PPF to determine if a widget should appear or not.

    To define a calendar condition use its name. Preceding the name with an exclamation point (!) will indicate a NOT TRUE statement.

    If a widget had the depend value below it would appear in the report if monday was a true calendar condition for that day AND january was NOT a true condition for that day.

    depend: [
        ['monday','!january']
    ]

Threshold Conditions

    Threshold conditions are used to determine if a widget should appear or not based on if a test result is of a certain value. For example you may want to show a body of text ONLY if VoIP Jitter was considered a good result.

    Like calendar condition an exclamation point (!) can be used to test the negative.

    The example below would be true if Upstream Jitter was considered good and Downstream Jitter was NOT considered bad.

    depend: [
        ['voip.jitter|good','!voip.djitter|bad']
    ]

Threshold Percentage Conditions

    Threshold percentage conditions are used to determine if a widget should appear or not based on if a group of test results fall above or below a set percentage. For example, text could be set to appear if bad results, as defined by the thresholds file, account for less than 25% of total results for the selected time frame.

    Like calendar condition an exclamation point (!) can be used to test the negative.

    The example below would be true if less than 25% of Upstream Jitter results were considered bad.

    depend: [
        ['!voip.jitter|bad|25']
    ]

    The example below would be true if more than 75% of Upstream Jitter results were considered good.

    depend: [
        ['voip.jitter|good|75']
    ]

Custom Function

    Defining a custom function is also a way to determine if a widget should appear in a report.

    By function we are referring to a JavaScript function, which must return true or false to be valid for dependancies.

    Parameters are also supported, which includes passing metric results.

    The depend example below would require both functions to return true for the dependency to be true.

    depend: [
        ['customFunction()','otherFunction(||voip.jitter||,"string")']
    ]

    Below is an example of how a function could look

    function otherFunction(upjitter, str) {
        if(upjitter > 0 && str === 'string') return true;
        return false;
    }

Dependency Rules

    The dependency array is processed top down. Each individual array contains AND conditions. The arrays themselves are OR conditions. Let's explain...

    Example 1:

      depend: [
          ['wednesday', 'march']
      ]

      In this example both conditions would have to be true. If either wednesday or march were not true calendar conditions for that day the dependency would be false.

    Example 2:

      depend: [
          ['wednesday'],
          ['march']
      ]

      In this example only ONE of the calendar conditions have to be true for the dependency to be true. If wednesday was false the processing moves to the next array. If march is true then the whole dependency is true.

Combining conditions

    Combining threshold conditions, calendar conditions, and custom functions is entirely possible. Take the example below.

                depend: [
        ['wednesday','voip.jitter|good'],
        ['march','customFunc("test")']
    ]

    The example above will first test the calendar condition wednesday, followed by the VoIP Jitter threshold condition. If either one of those returns false it will then process the next set of conditions, which includes another calendar condition and a custom function.