stackviz/app/js/controllers/test-details.js
Austin Clark e3af3b2bd3 Add to stackviz-export and stackviz-front docs
Adds additional information to the stackviz-export and stackviz-front
technical documents. Info about `stackviz-export` output files is
now included in the corresponding document. Directive and service
descriptions were added to stackviz-front, alongside inline comments
in the appropriate .js files.

Due to the unique structure of GitHub's RST renderer, includes will
no longer be used in the main README.

Change-Id: Iaebf1f1c3b5e4cbb4ea5e262f85672bc082bbe2f
2016-04-14 10:18:28 -06:00

91 lines
2.8 KiB
JavaScript

'use strict';
var controllersModule = require('./_index');
/**
* @ngInject
*/
var TestDetailsCtrl =
/**
* Responsible for making three calls to the dataset service. First, the
* dataset corresponding to the given int id is loaded, then the raw and details
* JSON files are loaded and placed into state variables. Also note that a copy
* of the details JSON is kept in `originalDetails` so that information is not
* lost when parsing. Progress of the dataset service calls is recorded and
* displayed in a progress bar on `test-details.html`.
*/
function($scope, $location, $stateParams, $log, datasetService, progressService) {
var vm = this;
vm.datasetId = $stateParams.datasetId;
var testName = $stateParams.test;
vm.testName = testName;
progressService.start({ parent: 'div[role="main"] .panel-body' });
// load dataset, raw json, and details json
datasetService.get($stateParams.datasetId)
.then(function(response) {
vm.dataset = response;
vm.stats = response.stats;
return datasetService.raw(response);
})
.then(function(raw) {
var item = null;
for (var t in raw.data) {
if (raw.data[t].name === testName) {
item = raw.data[t];
}
}
vm.item = item;
progressService.inc();
return datasetService.details(vm.dataset);
})
.then(function(deets) {
vm.details = deets;
vm.originalDetails = angular.copy(deets.data[testName]);
vm.itemDetails = deets.data[testName];
progressService.done();
})
.catch(function(error) {
$log.error(error);
progressService.done();
});
vm.parsePythonLogging =
/**
* This function changes the `itemDetails.pythonlogging` variable to only
* show lines with the log levels specified by the four boolean parameters.
* EX: If the `showINFO` parameter is set to true, `itemDetails.pythonlogging`
* will display lines that contain the text `INFO`.
* @param {boolean} showINFO
* @param {boolean} showDEBUG
* @param {boolean} showWARNING
* @param {boolean} showERROR
*/
function(showINFO, showDEBUG, showWARNING, showERROR) {
if (vm.originalDetails && vm.originalDetails.pythonlogging) {
var log = vm.originalDetails.pythonlogging;
var ret = [];
var lines = log.split('\n');
for (var i in lines) {
var line = lines[i];
if (showINFO && line.includes("INFO")) {
ret.push(line);
}
if (showDEBUG && line.includes("DEBUG")) {
ret.push(line);
}
if (showWARNING && line.includes("WARNING")) {
ret.push(line);
}
if (showERROR && line.includes("ERROR")) {
ret.push(line);
}
}
vm.itemDetails.pythonlogging = ret.join('\n');
}
};
};
controllersModule.controller('TestDetailsController', TestDetailsCtrl);