Skip to content

Introduction

The generic svg (rgsv) files makes it possible via filter attribute, export attribute and serverside code present, change, and display svg content on screen. It is mainly used for presenting reports (converted reports from EXOscada) - but it can very well be implemented as a generic view.

The Generic SVG tool

A standard tool. Attributes with eventcode, and support for arguments.

Execution of generic svg

Initial page load

Filter attribute is parsed and run according to rules described in section below. The OnLoad server side function is called, and the result svg content is shown in the main area for svg content.

graph TD
  A[PageLoad] --> B[Filter attribute initial render];
  B -->C[OnLoad method called];
  C -->D[Onload response shown as initial content];

Export Suggests attribute

The export suggests attribute eventcode and life cycle is just like the filter attribute. Read about filter in dynamic filters to find detailed information.

graph TD
  A[Export button clicked] --> B[OnExport method called];
  B -->C[Download reponse as file];

The export suggest attribute should be devided in a couple of sections to ease the readability:

Note

The last statement executed in export suggest code MUST be the return of the export object array.

//First section: Initial ssf calls, constants and helper functions
//context object available, if needed
//const suggestsConfig = await context.call('.getExportSuggests');
return return [
    {
        title: "PDF file",
        icon: 'document', 
        value: "pdf"
    },
    {
        title: "Svg picture",
        value: "svg"
    }
]

Tip

You can use SSF to obtain the array of export suggests if needed. Just put a

return await context.call('.getExportSuggests');
and implement the export suggests array in an SSF which fetch from .json file. Happy hacking!

Filter attribute

The filter attribute is a Dynamic Filter which means that the very same rules follows this filter. Read more about Dynamic Filter to get detailed information. The only difference is that each time filter is changed, the OnFilterChanged method is called with filter argument, see below.

Page events methods

These attributes refers to a SSF, a server side function. The syntax for the SSF is found in the ssf chapter. If the method starts with a dot (.onLoad), this is a short hand for using the Server side callee method.

OnLoad SSF method

Method arguments

Name Type Description
filter Array The current filter object from filter attribute

This method is called during page load. The result of the method must be an object with following attributes set

Name Type Description
type string the mandatory type. ('svg')
payload Buffer the svgdata in a buffer

OnFilterChanged SSF method

Method arguments

Name Type Description
filter Array The current filter object from filter attribute

Each time a filter elements event code is executed and all local state has been resolved for the current filter object, this method is called. The response object is exactly the same as for the OnLoad ssf method.

Name Type Description
type string the mandatory type. ('svg')
payload Buffer the svgdata in a buffer

OnExport SSF method

Method arguments

Name Type Description
filter Array The current filter object from filter attribute
value Object The current selected export object from export suggests attribute

The exported object array in export suggests are shown in a export drop down menu. On user click, this method is called with above arguments. The value is the object selected in the export suggest attribute array. The result of the method is parsed and provided as a downloaded file in browser.

Name Type Description
type string the mimetype for content download
payload Buffer the downloaddata in a buffer