Overriding Universal Topology Graphs
Learn how to override Oracle Communications Unified Assurance Universal Topology graphs.
You can override the data itself, for example, to apply custom styling, or the actions that occur when you interact with nodes or vertices on the Universal Topology graph. You can also create custom functions that you can call from topology tools in the UI.
Before overriding Universal Topology, you must be familiar with the following:
-
The process of overriding Unified Assurance user interfaces. See Overriding a User Interface.
-
ExtJs and event handling. See the Ext JS documentation for information.
-
The Ogma graphical library. See the Ogma documentation for information.
The overrides described in this section are specific to Universal Topology. They do not apply to other Unified Assurance UIs.
The class path for controlling the Universal Topology graph view is Graph.graphs.crud.controller.GraphsPanelViewController. The controller file is located in the $A1BASEDIR/www/packages/graph/src/graphs/crud/controller directory.
Overriding Data
To override the data, you can add overrides in the following GraphsPanelViewController methods, which are called at different stages of processing:
-
preprocessRawData: This method is called after the Graph::read REST API results are returned, but before the data is processed and rendered by Ogma. You can use it to manipulate the nodes and edges data inside the array or to initialize custom data.
It accepts the following parameters:
-
nodes: The array of node objects returned by the REST API.
-
edges: The array of edge objects returned by the REST API.
This method does not return any response.
For information about the properties of nodes and edges, see the Get Topology Vertices and Edges endpoint in REST API for Unified Assurance Core.
-
-
processNodeOptions: This method is called during processing for each node, before the ogmaNodeOpts is consumed by the Ogma class. You can use it to apply special condition checks on nodes, and make custom updates to the Ogma node attributes.
It accepts the following parameters:
-
nodeOpts: The node object from the REST API.
-
ogmaNodeOpts: The Ogma node attributes, converted from the REST API nodeOpts. See NodeAttributes in the Ogma API documentation for more information.
This method does not return any response.
-
-
postprocessNode: This method is called for each node, after the node has been rendered. You can use it for functions, such as pulse, that can only be applied after the node is displayed.
It accepts the node parameter, which contains the Ogma node data. See Node in the Ogma API documentation for more information.
You can apply overrides to any of the methods, as relevant to your implementation.
The sample GraphsPanelViewControllerOverride.js available in the sdk-lib package illustrates all three data override types.
Overriding UI Interactions
To override the actions that occur when you interact with nodes or vertices on the Universal Topology graph, you can add overrides in a subset of the Ogma events defined in GraphsPanelViewController. You can add overrides in the following event handlers:
-
onBefore<Event>: Override the behavior before the event occurs. Use this to:
-
Initialize a process before the main event action.
-
Check a condition to decide further actions. In this case, you must set the handler to return a boolean false value if the condition is not met.
-
-
on<Event>: Override the behavior when the event occurs.
-
onAfter<Event>: Override the behavior after the event occurs.
You can use one or more of the handlers as needed to achieve your goals. For example, you could override onKeydown to initiate the Ogma lasso selection tool when a user presses the Ctrl key, onKeyup to end lasso selection, and onBeforeKeydown to prevent the lasso selection from initiating if the mouse is hovering over a node.
In the default GraphsPanelViewController, the click event handlers are structured as follows:
view.ogma.events.on('click', function(event) {
if (me.onBeforeClick(event) !== false) {
me.onClick(event);
me.onAfterClick(event);
}
}, me);
The sample GraphsPanelViewControllerOverride.js available in the sdk-lib package illustrates several UI interaction overrides.
Supported Ogma Event Overrides
You can override the following Ogma events in GraphsPanelViewController:
-
Click: A user clicks a mouse button.
-
DoubleClick: A user double-clicks a mouse button.
-
DragProgress: A user is dragging a node or edge without releasing the mouse button.
-
DragStart: A user starts dragging a node or edge.
-
EdgesSelected: A user selects an edge either individually or as part of a group.
-
EdgesUnselected: A user deselects an edge.
-
Keydown: A user presses a keyboard key.
-
Keyup: A user releases a keyboard key.
-
MouseOut: A user stops hovering their mouse over an object.
-
MouseOver: A user hovers their mouse over an object.
-
NodesDragEnd: A user drops a node being dragged by releasing the mouse button.
-
NodesDragStart: A user starts dragging a node.
-
Zoom: A user zooms the view in or out.
See Events in the Ogma documentation for more information about these events.
Implementing Custom Functions with Topology Tools
You can create custom functions as overrides and call them from topology tools in context menus in Universal Topology graphs.
-
Create a custom function in the override file. You can use the following parameters in the function:
-
Vertex:
-
Name
-
VertexID
-
VertexClass
-
Any properties set for the vertex
-
-
Edge
-
id
-
EdgeClass
-
Any properties set for the vertex
-
For example, the sample GraphsPanelViewControllerOverride.js contains overrides that create a pulse effect. To create a tool that clears the pulse effect when selected from the context menu, you would add the following function to the override file:
clearPulse: function(menuItem) { var me = this, view = this.getView(), name = menuItem.Name, id = menuItem.VertexID; if (this.intervalHandlers) { let handler = this.intervalHandlers[id]; if (handler) { clearInterval(handler); delete this.intervalHandlers[id]; a1.AN5.toastSuccess(tr('Device') + ' (' + name + ') ' + tr('alarm is reset')); } } }
The example uses the Name and VertexID properties of the selected vertex.
-
-
Apply the override as described in Overriding a User Interface
-
Create a custom topology tool. See Tools in Unified Assurance User's Guide for information about the UI for creating topology tools.
Set Path Type to Function and specify the custom function name in Path.
To call the function created in the example, you would set Path to clearPulse.
-
Add the custom tool to the topology menu. See Menus in Unified Assurance User's Guide for information about the UI for creating topology menus.
Overriding Ogma Node Grouping and Geo Clustering transformations
This section will describe how to use an override to enable and disable Node Grouping and Geo Clustering transformations in Ogma, as well as how to customise the functionality.
By default, only the out-of-the-box Node Grouping functionality is enabled so no Geo Clustering will occur.
To change this you will need to create an override of the GraphsPanelViewController file and set the clusteringMode variable to either "geocluster" to have only Geo Clustering enabled or "mixed" to have both Node Grouping and Geo Clustering enabled.
Supported Ogma Transformation Overrides
There are several functions and variables made available to override in the GraphsPanelViewController.
All the functions and variables below are optional, except when Geo Clustering is enabled then geoClusteringNodeGenerator and geoClusteringEdgeGenerator must be defined as a minimum.
For more details on the parameters passed into functions and the expected return data's formats, see the Ogma API documentation.
General Variables
You can override the general variables described in the following table.
Variable Name | Default Value | Description |
---|---|---|
clusteringMode | default | Used to decide which transformations are enabled. Options are default, geocluster, and mixed. |
Node Grouping Variables and Functions
Caution:
Overriding any of these variables or functions will affect the default node grouping functionality.
You can override the node grouping variables described in the following table.
Variable Name | Default Value | Description |
---|---|---|
nodeGroupingPadding | 10 | Padding applied to groups showing their content. If a function is passed, each MetaNode will get a padding depending on that function. |
nodeGroupingDuration | 600 | Animation time in milliseconds. The animation will be played once after the creation of the group. |
You can override the node grouping functions described in the following table.
Function Name | Parameters | Expected Return Type | Description |
---|---|---|---|
nodeGroupingGroupIdFunction | function(node: Node) | string|undefined | Given a node, must return a string identifying a group. All nodes for which the function returns the same value will be grouped together. By default, group all the nodes that were selected together. Returning undefined means that the node should not be grouped. |
nodeGroupingShowContents | function(metaNode: Node) | boolean | Function that would define if the contents of the group node should be hidden or not. This is called on every transformation update. |
nodeGroupingGroupIdFunction | function(nodes: NodeList, groupId: string, transformation: Transformation) | NodeDataAndAttributes | Given a list of nodes that should be grouped together, must return the new node (meta-node) to be added. GeoClustering will compute automatically the coordinate of the clusters. |
Geo Clustering Variables and Functions
You can override the geo clustering variables described in the following table.
Variable Name | Default Value | Description |
---|---|---|
geoClusteringRadius | 60 | The radius in which a node gets grouped to another one. |
geoClusteringGroupEdges | true | Indicates if parallel edges that end up having at least one meta-node extremity should be grouped together (to reduce cluttering). |
geoClusteringSeparateEdgesByDirection | false | By default, edges that have opposite source and target are grouped together (resulting source and target not deterministic). If this option is true, they will not be grouped together. |
geoClusteringGroupSelfLoopEdges | false | If true, edges for which the two extremities end up being grouped into the same node will be displayed as a self-loop edge, instead of not being displayed at all. |
You can override the geo clustering functions described in the following table.
Function Name | Parameters | Expected Return Type | Description |
---|---|---|---|
geoClusteringSelector | function(node: Node) | node: Node | Only nodes that match this criteria will be grouped with other nodes. By default, all the nodes will be assigned a group. |
geoClusteringNodeGenerator | function(nodes: NodeList, groupId: string, transformation: Transformation) | NodeDataAndAttributes|null | Given a list of nodes that should be grouped together, must return the new node (meta-node) to be added. The latitude and longitude of the meta-node will be the average of the latitude and longitude of the nodes. If null is returned, the meta-node will not be created. |
geoClusteringEdgeGenerator | function(edges: EdgeList, groupId: string, transformation: Transformation) | EdgeDataAndAttributes|null | If groupEdges is true, indicates the function used to generate the new edges from the sub-edges. Ignored if groupEdges is false. If returned null, the meta edge will not be created. |
geoClusteringOnCreated | function(metaNode: Node, showContents: boolean, subNodes: NodeList, subEdges: EdgeList) | Promise |
This is a callback called after a new group is created. |
geoClusteringGroupIdFunction | function(node: Node) | string|undefined | Given a node, must return a string identifying a group. All nodes for which the function returns the same value will be grouped together. By default, group all the nodes that were selected together. |
Example Universal Topology Overrides
The sdk-lib package includes an example of a Universal Topology override. To review it, after installing the sdk-lib package, open the following file:
$A1BASEDIR/www/ui/customExampleOverrides/controller/GraphsPanelViewControllerOverride.js
The example includes overrides in:
-
preprocessRawData to initialize an array for storing a node's timer interval handlers and randomly initializes nodes with Ogma halo and pulse styles.
-
processNodeOptions to process nodes with halo styles.
-
postprocessNode to construct the timer interval and start the pulse actions.
-
onAfterClick to reset the pulse interval when a user holds the Alt key and clicks the node.
-
onBeforeMouseOver to prevent the default mouse over action of displaying node details when a user is hovering over a node with a halo style.
-
onBeforeKeydown, onKeydown and onKeyup to provide lasso selection feature and automatically zoom to the selected nodes.
You can deploy this override in your test environment to verify the behavior in the UI. See Overriding a User Interface.