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
This commit is contained in:
parent
d27c01fb6a
commit
b2fedac4fe
37
app/js/directives/artifact-summary.js
Normal file
37
app/js/directives/artifact-summary.js
Normal file
@ -0,0 +1,37 @@
|
||||
'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);
|
31
app/js/directives/subunit-failures.js
Normal file
31
app/js/directives/subunit-failures.js
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var directivesModule = require('./_index.js');
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
function subunitFailures() {
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
var controller = function($scope, $attrs, datasetService) {
|
||||
$scope.$watch('artifactName', function(artifactName) {
|
||||
datasetService.artifact(artifactName, 'subunit-stats').then(function(response) {
|
||||
$scope.stats = response.data;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
restrict: 'EA',
|
||||
scope: {
|
||||
'artifactName': '='
|
||||
},
|
||||
controller: controller,
|
||||
templateUrl: 'directives/subunit-failures.html'
|
||||
};
|
||||
}
|
||||
|
||||
directivesModule.directive('subunitFailures', subunitFailures);
|
@ -5,7 +5,7 @@ var directivesModule = require('./_index.js');
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
function tempestSummary() {
|
||||
function subunitSummary() {
|
||||
|
||||
/**
|
||||
* Responsible for getting the basic run summary stats via the dataset service.
|
||||
@ -26,12 +26,11 @@ function tempestSummary() {
|
||||
return {
|
||||
restrict: 'EA',
|
||||
scope: {
|
||||
'index': '=',
|
||||
'artifactName': '='
|
||||
},
|
||||
controller: controller,
|
||||
templateUrl: 'directives/tempest-summary.html'
|
||||
templateUrl: 'directives/subunit-summary.html'
|
||||
};
|
||||
}
|
||||
|
||||
directivesModule.directive('tempestSummary', tempestSummary);
|
||||
directivesModule.directive('subunitSummary', subunitSummary);
|
43
app/js/services/summary.js
Normal file
43
app/js/services/summary.js
Normal file
@ -0,0 +1,43 @@
|
||||
'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);
|
17
app/views/directives/subunit-failures.html
Normal file
17
app/views/directives/subunit-failures.html
Normal file
@ -0,0 +1,17 @@
|
||||
<div class="panel panel-danger" ng-if="stats.failures.length > 0">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Failures</h3>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<a class="list-group-item"
|
||||
ng-repeat="fail in stats.failures"
|
||||
ui-sref="testDetails({artifactName: artifactName, test: fail.name})">
|
||||
<h4 class="list-group-item-heading">
|
||||
{{fail.name | split:'.' | slice:-2 | join:'.'}}
|
||||
</h4>
|
||||
<p ng-repeat="line in fail.details" class="list-group-item-text">
|
||||
{{line}}
|
||||
</p>
|
||||
</a>
|
||||
</ul>
|
||||
</div>
|
@ -37,21 +37,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-danger" ng-if="stats.failures.length > 0">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Failures</h3>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<a class="list-group-item"
|
||||
ng-repeat="fail in stats.failures"
|
||||
ui-sref="testDetails({artifactName: artifactName, test: fail.name})">
|
||||
<h4 class="list-group-item-heading">
|
||||
{{fail.name | split:'.' | slice:-2 | join:'.'}}
|
||||
</h4>
|
||||
<p ng-repeat="line in fail.details" class="list-group-item-text">
|
||||
{{line}}
|
||||
</p>
|
||||
</a>
|
||||
</ul>
|
||||
</div>
|
@ -9,20 +9,18 @@
|
||||
<div class="row" ng-if="!home.groups.length">
|
||||
<div class="col-lg-12">
|
||||
<div class="alert alert-danger">
|
||||
No tempest datasets could be loaded!
|
||||
No artifacts could be loaded!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-if="!!home.groups.length">
|
||||
<div class="col-lg-8">
|
||||
<tempest-summary ng-if="home.groups.length >= 1"
|
||||
artifact-name="home.focus"
|
||||
index="home.focus"></tempest-summary>
|
||||
<artifact-summary artifact-name="home.focus"></artifact-summary>
|
||||
</div>
|
||||
<div class="col-lg-4" ng-if="home.datasets.length > 1">
|
||||
<div class="col-lg-4" ng-if="home.groups.length > 1">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Additional Datasets</h3>
|
||||
<h3 class="panel-title">Other Artifacts</h3>
|
||||
</div>
|
||||
|
||||
<ul class="list-group">
|
||||
@ -32,15 +30,6 @@
|
||||
ng-click="home.focus = group"
|
||||
style="cursor: pointer">
|
||||
{{ group }}
|
||||
|
||||
<!--<small class="text-muted" style="font-size: 75%">
|
||||
{{dataset.stats.start | date:'MM/d/yyyy'}}
|
||||
</small>-->
|
||||
|
||||
<a class="btn btn-default btn-xs pull-right"
|
||||
ui-sref="timeline({artifactName: group})">
|
||||
Details
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user