Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Notes on Directives

Refresh Button

The refresh button is declared something like this:

Code Block
languagexml
linenumberstrue
<div class="refresh" ng-class="{active: autoRefresh}"
     icon icon-size="36" icon-id="refresh"
     tooltip tt-msg="autoRefreshTip"
     ng-click="toggleRefresh()"></div>

class="refresh"

The refresh class is defined in table.css to style the <div> element appropriately for light and dark themes, when active or hovered-over.

ng-class="{active: autoRefresh}"

The ng-class directive is provided by Angular and adds the specified class to the element if the condition is true. In this case, if the autoRefresh boolean (defined on our controller scope) is true, then the active class is applied to the <div> element.

icon icon-id="refresh" icon-size="36"

The icon directive injects an icon with the given icon-id into the <div> element. icon-size="36" is the recommended size for table button icons.

If you really want to get into the guts of the code, see the definition of the icon directive in icon.js.

tooltip tt-msg="autoRefreshTip"

The tooltip directive uses the string stored on the scope variable autoRefreshTip to populate a tooltip when the mouse hovers over the button.

ng-click="toggleRefresh()"

The ng-click directive, provided by Angular, invokes the toggleRefresh() function (defined on our scope) when the user clicks on the <div> element.

Notes on Main Table

onos-table-resize

The onos-table-resize directive monitors the browser window and resizes the table elements whenever the window size changes. See table.js for the gory details.

 

Note that the table view makes use of two HTML <table> elements; the first for the (non-scrolling) table headers, and the second for the (scrolling) table contents:

 

Table Header

onos-sortable-header & sortable

The onos-sortable-header directive injects a click handler into every <td> element in the header that has a sortable attribute defined (see table.js for details).

sort-callback

sort-callback="sortCallback(requestParams)"The handler toggles the sort state between ascending and descending sort direction, as well as inserting the sort direction icons (up and down arrows) into the element. In addition, a sort request event is fired off to the server to re-fetch the table data, sorted with the new criteria.

Table Column Options

The first thing to note about the table columns is that the column headers use td tags (not th tags).

...