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.
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||)$$
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);
}
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||)$$"
}
}