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.
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.