[Events] Fixed tabs

Removed tabs from EventListController and replaced
with spaces. #18.
This commit is contained in:
Sarah Hale 2015-06-24 17:08:03 -07:00
parent 203de023d2
commit d2fe71d82b

View File

@ -27,107 +27,107 @@
* Modified by shale on 06/23/2015. * Modified by shale on 06/23/2015.
*/ */
define( define(
["./DomainColumn", "./RangeColumn", "./EventListPopulator"], ["./DomainColumn", "./RangeColumn", "./EventListPopulator"],
function (DomainColumn, RangeColumn, EventListPopulator) { function (DomainColumn, RangeColumn, EventListPopulator) {
"use strict"; "use strict";
var ROW_COUNT = 100; var ROW_COUNT = 100;
/** /**
* The EventListController is responsible for populating * The EventListController is responsible for populating
* the contents of the event list view. * the contents of the event list view.
* @constructor * @constructor
*/ */
function EventListController($scope, formatter) { function EventListController($scope, formatter) {
var populator; var populator;
// Get a set of populated, ready-to-display rows for the // Get a set of populated, ready-to-display rows for the
// latest data values. // latest data values.
function getRows(telemetry) { function getRows(telemetry) {
var datas = telemetry.getResponse(), var datas = telemetry.getResponse(),
objects = telemetry.getTelemetryObjects(); objects = telemetry.getTelemetryObjects();
return populator.getRows(datas, objects, ROW_COUNT); return populator.getRows(datas, objects, ROW_COUNT);
} }
// Update the contents // Update the contents
function updateRows() { function updateRows() {
var telemetry = $scope.telemetry; var telemetry = $scope.telemetry;
$scope.rows = telemetry ? getRows(telemetry) : []; $scope.rows = telemetry ? getRows(telemetry) : [];
} }
// Set up columns based on telemetry metadata. This will // Set up columns based on telemetry metadata. This will
// include one column for each domain and range type, as // include one column for each domain and range type, as
// well as a column for the domain object name. // well as a column for the domain object name.
function setupColumns(telemetry) { function setupColumns(telemetry) {
var domainKeys = {}, var domainKeys = {},
rangeKeys = {}, rangeKeys = {},
columns = [], columns = [],
metadata; metadata;
// Add a domain to the set of columns, if a domain // Add a domain to the set of columns, if a domain
// with the same key has not yet been inclued. // with the same key has not yet been inclued.
function addDomain(domain) { function addDomain(domain) {
var key = domain.key; var key = domain.key;
if (key && !domainKeys[key]) { if (key && !domainKeys[key]) {
domainKeys[key] = true; domainKeys[key] = true;
columns.push(new DomainColumn(domain, formatter)); columns.push(new DomainColumn(domain, formatter));
} }
} }
// Add a range col to the set of columns, if a range // Add a range col to the set of columns, if a range
// with the same key has not yet been included. // with the same key has not yet been included.
function addRange(range) { function addRange(range) {
var key = range.key; var key = range.key;
if (key && !rangeKeys[key]) { if (key && !rangeKeys[key]) {
rangeKeys[key] = true; rangeKeys[key] = true;
columns.push(new RangeColumn(range, formatter)); columns.push(new RangeColumn(range, formatter));
} }
} }
// We cannot proceed if the telemetry controller // We cannot proceed if the telemetry controller
// is not available; clear all rows/columns. // is not available; clear all rows/columns.
if (!telemetry) { if (!telemetry) {
columns = []; columns = [];
$scope.rows = []; $scope.rows = [];
$scope.headers = []; $scope.headers = [];
return; return;
} }
// Add domain, range, event msg columns // Add domain, range, event msg columns
metadata = telemetry.getMetadata(); metadata = telemetry.getMetadata();
(metadata || []).forEach(function (metadata) { (metadata || []).forEach(function (metadata) {
(metadata.domains || []).forEach(addDomain); (metadata.domains || []).forEach(addDomain);
}); });
(metadata || []).forEach(function (metadata) { (metadata || []).forEach(function (metadata) {
(metadata.ranges || []).forEach(addRange); (metadata.ranges || []).forEach(addRange);
}); });
// Add default domain and range columns if none // Add default domain and range columns if none
// were described in metadata. // were described in metadata.
if (Object.keys(domainKeys).length < 1) { if (Object.keys(domainKeys).length < 1) {
columns.push(new DomainColumn({name: "Time"}, formatter)); columns.push(new DomainColumn({name: "Time"}, formatter));
} }
if (Object.keys(rangeKeys).length < 1) { if (Object.keys(rangeKeys).length < 1) {
columns.push(new RangeColumn({name: "Message"}, formatter)); columns.push(new RangeColumn({name: "Message"}, formatter));
} }
// We have all columns now; use them to initializer // We have all columns now; use them to initializer
// the populator, which will use them to generate // the populator, which will use them to generate
// actual rows and headers. // actual rows and headers.
populator = new EventListPopulator(columns); populator = new EventListPopulator(columns);
// Initialize headers // Initialize headers
$scope.headers = populator.getHeaders(); $scope.headers = populator.getHeaders();
// Fill in the contents of the rows. // Fill in the contents of the rows.
updateRows(); updateRows();
} }
$scope.$on("telemetryUpdate", updateRows); $scope.$on("telemetryUpdate", updateRows);
$scope.$watch("telemetry", setupColumns); $scope.$watch("telemetry", setupColumns);
} }
return EventListController; return EventListController;
} }
); );