mobile menu

PPF Expressions & Functions

You are here
PPF Expressions & Functions

PPF Expressions & Functions

PPF expressions and functions increase the flexibility of reports by allowing report metrics to be passed to custom JavaScript functions.

How is this done? Simply create a JavaScript function within your PPF, or your HTML page, and create the syntax within your repor to pass metrics to it.

Defining an Expression or Function

Take the example JavaScript function below:

function testfunc(download,upload) {
    console.log(download);
    console.log(upload);
}

This function can be called within other widgets. For example, if the syntax below was included in a text widget the results for download and upload speed would be passed to the testfunc JavaScrit function. If that function returned a value that value would appear in the text.

$$exp.testfunc(||speed.dspeed||,||speed.uspeed||)$$

Full Example

Below is a full example of how this would look if using an expression as part of a text widget.

var ppf_datasets = {
    data: {
        speeddata: { //name of the data set
            plugins: ['speed'],
            last: '1',
            unit: 'hour',
            by: 10
        }
    }
}

var ppf_widgets = {
    example_text: { 
        ele: [ 'text_ele_id'],
        data:  'speeddata', 
        type: 4,
        text: 'The overall result of this test was $$exp.testfunc(||speed.dspeed||,||speed.uspeed||)$$',
        thrdep: [[]],
        caldep: [[]]
    }
}

function testfunc(download,upload) {
    console.log(download);
    console.log(upload);
}

Global Functions

These functions get processed once and can be referenced within the PPF.

Note: when using metrics a dataset will need to specified (c24 in the example below).

var ppf_funcs = { //reserved for PPF use.
   cCalls: 'calcCalls(||c24.capacity.dpackets||,||c24.capacity.upackets||)'
}

The example below shows how this could be used in a widget.

It's a snippet from a box widget.

The function result is called using "ppf_funcs" followed by the function name, which in this example is "cCalls".

Below also shows a great example of also using the value in an expression. The expression calls a function that returns the color to use for the text. The function in this example is not an API call.

tl_pktc: {
      inc: 'tl_capd',
      ele: ['grid2'],
      top: {
         text: "Concurrent Calls Supported"
      },
      middle: {
	text: "$$ppf_funcs.cCalls$$ calls",
	txtcol: "$$exp.getTxtCol('capacity.ccalls', ||ppf_funcs.cCalls||)$$"
      }
   }