stackviz/app/js/directives/artifact-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

38 lines
926 B
JavaScript

'use strict';
var directivesModule = require('./_index.js');
/**
* @ngInject
*/
function artifactSummary($compile, datasetService, summaryService) {
var link = function(scope, el, attrs, ctrl) {
scope.$watch('artifactName', function(artifactName) {
el.empty();
datasetService.artifacts(artifactName).then(function(artifacts) {
artifacts.forEach(function(artifact) {
summaryService.directivesForType(artifact.artifact_type).forEach(function(d) {
var name = d.directiveName;
var tag = '<' + name + ' artifact-name="\'' + artifactName + '\'">' +
'</' + name + '>';
var e = $compile(tag)(scope);
el.append(e);
});
});
});
});
};
return {
restrict: 'EA',
scope: {
'artifactName': '='
},
link: link
};
}
directivesModule.directive('artifactSummary', artifactSummary);