Page tree

Have questions? Stuck? Please check our FAQ for some common questions and answers.

Skip to end of metadata
Go to start of metadata

TableBuilderService

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.

NameSummary
buildTableCreates the model for a basic tabular view.

Function Descriptions

buildTable

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 UsageArgumentsReturn Value
tbs.buildTable(o);

o - an object with settings to create the tabular view, see below

none

Object Arguments

tbs.buildTable({
	scope: $scope,            // required
	tag: 'foo',               // required
	selCb: selectCallback,    // optional
	respCb: responseCallback, // optional
	query: params             // optional
});
Name of PropertyValue of PropertyPurpose

scope **

injected Angular $scope servicebuildTable 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.
selCbfunction reference of a function you want to be called when a table row is selectedStands for "select callback". This function is called when a table row is clicked on.
respCbfunction reference of a function you want to be called when the table data is received from the serverStands for "response callback". This function is called when the table data is received from the server.
queryobject 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.

Side Effects

The buildTable function puts several variables and functions on the scope to be used in controllers and directives. Here is a summary.

$scope PropertyTypeSummary
tableDataarrayArray of objects that model the data displayed in the table.
changedDataarrayArray of objects that are new or have changed between the previous tableData and the new tableData just received.
sortParamsobjectCurrent sort parameters – the column (sortCol) and sort direction (sortDir).
loadingbooleanTrue if the page is loading for the first time, or if it is taking longer than 500ms to get a response from the server.
autoRefreshbooleanTrue if auto refresh is toggled "on", false otherwise.
autoRefreshTipstringMessage for the tooltip directive for the auto refresh button.
sortCallbackfunction reference

Function that sends the websocket request for the tableData.

(takes one optional argument that is an object of the sort parameters)

selIdstring or nullID of the currently selected item or null if nothing is selected.
selectCallbackfunction referenceFunction that sets selId and calls user-given selCb if given.
toggleRefreshfunction referenceFunction that toggles auto refresh on and off.
  • No labels