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
44 lines
962 B
JavaScript
44 lines
962 B
JavaScript
'use strict';
|
|
|
|
var servicesModule = require('./_index.js');
|
|
|
|
/**
|
|
* @ngInject
|
|
*/
|
|
function SummaryService() {
|
|
var mappings = [];
|
|
|
|
var service = {
|
|
directivesForType: function(artifactType) {
|
|
return mappings.filter(function(mapping) {
|
|
return mapping.artifactType === artifactType;
|
|
});
|
|
},
|
|
|
|
mapType: function(artifactType, directiveName, priority) {
|
|
if (typeof priority === 'undefined') {
|
|
priority = 0;
|
|
}
|
|
|
|
mappings.push({
|
|
artifactType: artifactType,
|
|
directiveName: directiveName,
|
|
priority: priority
|
|
});
|
|
|
|
mappings.sort(function(a, b) {
|
|
return b.priority - a.priority;
|
|
});
|
|
}
|
|
};
|
|
|
|
// default mappings
|
|
service.mapType('subunit-stats', 'subunit-summary', 5);
|
|
service.mapType('subunit-stats', 'subunit-failures', 4);
|
|
service.mapType('console', 'console-summary', 5);
|
|
|
|
return service;
|
|
}
|
|
|
|
servicesModule.service('summaryService', SummaryService);
|