stackviz/app/js/directives/subunit-summary.js
Tim Buckley b2fedac4fe Add service to summarize different artifact types
Currently, the home page has a hard-coded summary panel specifically
for displaying overviews of subunit artifacts, which makes it
impossible to show information on other types of artifacts. This adds
a new 'summaryService' and associated 'artifact-summary' directive
that can dynamically create summary panels depending on artifact type.

Additionally, since the summary service allows many summary panels per
type per named artifact, we can have multiple (priority-ordered)
panels for each artifact. As an example of this, the existing subunit
summary has been split into simpler 'subunit-summary' and
'subunit-errors' panels.

Change-Id: I0d075dfcb86c6aef8c697896d1728e970b62600f
2016-04-28 13:14:58 -06:00

37 lines
941 B
JavaScript

'use strict';
var directivesModule = require('./_index.js');
/**
* @ngInject
*/
function subunitSummary() {
/**
* Responsible for getting the basic run summary stats via the dataset service.
* Also calculates the duration of the run - `timeDiff` - by subtracting the
* run's start and end timestamps.
* @ngInject
*/
var controller = function($scope, $attrs, datasetService) {
$scope.$watch('artifactName', function(artifactName) {
datasetService.artifact(artifactName, 'subunit-stats').then(function(response) {
var stats = response.data;
$scope.stats = stats;
$scope.timeDiff = (new Date(stats.end) - new Date(stats.start)) / 1000;
});
});
};
return {
restrict: 'EA',
scope: {
'artifactName': '='
},
controller: controller,
templateUrl: 'directives/subunit-summary.html'
};
}
directivesModule.directive('subunitSummary', subunitSummary);