
In today's world, the UX has become a key point in successful IT products and
NetEye wants it to become one of its strongest features, providing a continuously
improved GUI to support the users's daily activities.

For this purpose, NetEye provides a totally redesigned, modern looking and attractive GUI for Tornado,
based on solid design and usability guidelines defined by the
`Carbon Design System <https://https://www.carbondesignsystem.com/>`_

While the new GUI is developed to completely replace the current UI, it is currently in preview and
only some features are supported such as processing tree visualization, event-driven testing and multi-tenancy.

The Graphical User Interface allows you to explore the current
configuration of your Tornado Instance.

The GUI can be divided in 3 logical blocks.
At the top of the screen we find the **toolbar**, in this area
it is possible to change the tenant and enable the edit mode.

.. figure:: /img/tornado_carbon_toolbar.png

   Toolbar

Immediately below we find the most important part: the **Processing Tree**.
All **filters** and **rulesets** of the processing tree are shown in hierarchical
order. You can navigate the tree by expanding the child nodes of a filter by
clicking on the arrow on the left side of the node.
When clicking on a node, its details will be shown. In case of a ruleset, in
addition to the details, also the list of rules will appear.
To see the details of a rule, you can click on the entry in the list of rules.

.. figure:: /img/tornado_carbon_processing_tree.png

   Processing Tree

The test event window is a panel that can be opened using the icon in
the top right corner, which allows you to send test **Events**.
These **Events** can be created through a dedicated form and are composed
by the following four fields:

* **Event type**: the type of the **Event**, such as trap, sms, email,
  etc.
* **Creation time**: the **Event** timestamp defined as an epoch in
  milliseconds.
* **Tenant ID**: The tenant ID that will be added to the event.
  Fill this field if there are filters or conditions related to the
  tenant ID, otherwise just leave it empty.
* **Enable execution of actions**: whether the actions of matching
  rules have to be executed or skipped.
* **Payload**: the event payload in JSON format.

.. figure:: /img/tornado_carbon_test_window.png

   Test window

When a test is executed by clicking the "Run Test" button, the linked
Event is sent to Tornado and the outcome of the operation will be
reported in the Processing Tree.

Following the yellow line it is possible to see the path that the event has taken.
The nodes that have matched the event are distinguishable by a full yellow
lightning bolt while those partially matched have an empty bolt.

.. figure:: /img/tornado_carbon_processing_tree_with_event.png

   Processing Tree with an event result

At this point, a rule can be in one of the following states:

* ``matched``: If a rule matched the Event.
* ``stopped``: If a rule matched the Event and then stopped the.
  execution flow. This happens if the ``continue`` flag of the rule is
  set to false.
* ``partially matched``: If the **where** condition of the Rule was
  matched but it was not possible to process the required extracted
  variables.
* ``not matched``: If the Rule did not match the Event.

.. figure:: /img/tornado_carbon_ruleset_matched.png

   Example of processed rules

   * Matched rules: Extract_sender, Extract_subject, Archive_all
   * Partially matched: Extract_message
   * Not matched: Block_invalid_senders

For each rule in the table, the extracted variables and the generated
Action payloads are shown. In addition, all these extracted variables
are also shown in the Event Test form.

.. figure:: /img/tornado_carbon_extracted_variables.png

   Sample of extracted variables

Two other buttons are visible, one for cleaning all the fields of the
form and one for cleaning the outcome of the test.

Tornado Processing Tree Editor
++++++++++++++++++++++++++++++

The Tornado GUI provides an **edit mode** that allows to modify the
configuration of the Tornado rules' processing tree directly from
NetEye's web interface.
Two important principles have been used for the development of the *edit
mode* and must be understood and taken into account when modifying
Tornado's configuration:

-  **Implicit Lock Mode**. Only one user at a time can modify the
   processing tree configuration. This prevents multiple users from
   changing the configuration simultaneously, which might lead to
   unwanted results and possibly to Tornado not working correctly due to
   incomplete or wrong configuration. When a user is editing the
   configuration, the actual, running configuration is left untouched:
   it continues to be operative and accepts incoming data to be
   processed.

-  **Edit Mode**. When starting to modify the configuration, Tornado
   will continue to work with the existing configuration--thanks to the
   implicit lock mode, while the new changes are saved in a separate
   *draft configuration*. The new configuration then must be deployed to
   become operative.

   This mode has other positive side effects: one does not need to
   complete the changes in one session, but can stop and then continue
   at a later point; another user can pick up the draft and complete
   it; in case of a disaster (like e.g., the abrupt end of the HTTPS
   connection to the GUI) it is possible to resume the draft from the
   point where it was left.

.. warning:: Only one draft at a time is allowed; that is, editing
   of multiple draft is **not** supported!

When a user enters the edit mode, a new draft is created on the fly if
none is present, which will be an exact copy of the running Tornado
configuration. If not present in the draft, a root node of type
**Filter** will be automatically added to the draft.

To check for the correctness of a Draft, without impacting the deployed
configuration, it is possible to open the **test window** also while in
**Edit Mode**. The event will be processed using the Draft and the
result will be displayed, while keeping the existing configuration
running.

You can add a new node in two ways:

* by clicking on the "Add" button in the top right corner and then
  selecting the parent node to which you want to add the new node.
* by clicking on the icon with the three dots on each node that
  from now on we will call overflow menu.

.. note:: All nodes at the same level are ordered alphabetically

For each node, it is possible to define a name.
For a filter, these three more options are available:

-  a description
-  whether it is active or not
-  the **filter** that should match the event. A specific editor is
   available for the user to create a valid filter or alternatively
   it is possible to write it via JSON-based syntax, and examples
   can be found in the various How-tos present in the *tornado*
   section of the User Guide.

Moreover, in *Edit mode*, each node can be deleted by clicking the delete
item available in the overflow menu.