add optional template-type attribute to smart status icon directive for linking to workflow jobs (#4695)

The recent_jobs summary fields of the endpoints driving the status icon controller do not provide the necessary information to build a url for the correct job details endpoint in all cases.

This adds an optional template-type attribute to the smart status directive to override the default url building behavior.
This commit is contained in:
Jake McDermott 2017-01-12 19:40:28 -05:00 committed by GitHub
parent c6cae2e273
commit d5ce044e8d
4 changed files with 17 additions and 3 deletions

View File

@ -1 +1 @@
<aw-smart-status jobs="template.summary_fields.recent_jobs"></aw-smart-status>
<aw-smart-status jobs="template.summary_fields.recent_jobs" template-type="template.type"></aw-smart-status>

View File

@ -15,9 +15,21 @@ export default ['$scope', '$filter',
var singleJobStatus = true;
var firstJobStatus;
var recentJobs = $scope.jobs;
var detailsBaseUrl;
if(!recentJobs){
return;
}
// unless we explicitly define a value for the template-type attribute when invoking the
// directive, assume the status icons are for a regular (non-workflow) job when building
// the details url path
if (typeof $scope.templateType !== 'undefined' && $scope.templateType === 'workflow_job_template') {
detailsBaseUrl = '/#/workflows/';
} else {
detailsBaseUrl = '/#/jobs/';
}
var sparkData =
_.sortBy(recentJobs.map(function(job) {
@ -38,6 +50,7 @@ export default ['$scope', '$filter',
data.sortDate = job.finished || "running" + data.jobId;
data.finished = $filter('longDate')(job.finished) || job.status+"";
data.status_tip = "JOB ID: " + data.jobId + "<br>STATUS: " + data.smartStatus + "<br>FINISHED: " + data.finished;
data.detailsUrl = detailsBaseUrl + data.jobId;
// If we've already determined that there are both failed and successful jobs OR if the current job in the loop is
// pending/waiting/running then we don't worry about checking for a single job status

View File

@ -9,7 +9,8 @@ export default [ 'templateUrl',
function(templateUrl) {
return {
scope: {
jobs: '='
jobs: '=',
templateType: '=?',
},
templateUrl: templateUrl('smart-status/smart-status'),
restrict: 'E',

View File

@ -1,6 +1,6 @@
<div class="SmartStatus-container">
<div ng-repeat="job in sparkArray track by $index" class='SmartStatus-iconContainer'>
<a href="#/jobs/{{ job.jobId }}"
<a ng-href="{{job.detailsUrl}}"
aw-tool-tip="{{job.status_tip}}"
data-tip-watch="job.status_tip"
aw-tip-placement="left"