TableBuilder is an Angular Factory in the Widget module with the name
tableBuilder.js. It provides a function that builds a generic model for tabular views. To use this service, see the documentation on injecting Angular services.
This function was made in order to reuse the code that all tabular views share – websocket calls, autorefresh, and selecting rows. It has side effects which are listed below.
|Example Usage||Arguments||Return Value|
|Name of Property||Value of Property||Purpose|
|injected Angular $scope service||buildTable attaches several functions and variables to the $scope that can be accessed from the table's controller and in the HTML|
|tag **||string of what view this is, examples being "device", "link", or "app"||This must be singular – no 's' at the end! buildTable uses this to build the strings for websocket calls and naming the root node of received data.|
|selCb||function reference of a function you want to be called when a table row is selected||Stands for "select callback". This function is called when a table row is clicked on.|
|respCb||function reference of a function you want to be called when the table data is received from the server||Stands for "response callback". This function is called when the table data is received from the server.|
|query||object with query parameters (usually gotten from $location.search())||Sends these query parameters to the server. For example, this is used in the Flow View to filter flows by a certain device ID.|
** These properties are required for buildTable to work properly.
The buildTable function puts several variables and functions on the scope to be used in controllers and directives. Here is a summary.
|array||Array of objects that model the data displayed in the table.|
|array||Array of objects that are new or have changed between the previous tableData and the new tableData just received.|
|object||Current sort parameters – the column (|
|boolean||True if the page is loading for the first time, or if it is taking longer than 500ms to get a response from the server.|
|boolean||True if auto refresh is toggled "on", false otherwise.|
|string||Message for the tooltip directive for the auto refresh button.|
Function that sends the websocket request for the
(takes one optional argument that is an object of the sort parameters)
|string or ||ID of the currently selected item or |
|function reference||Function that sets |
|function reference||Function that toggles auto refresh on and off.|