mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 18:51:06 -03:30
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:
@@ -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>
|
||||||
|
|||||||
@@ -15,9 +15,21 @@ export default ['$scope', '$filter',
|
|||||||
var singleJobStatus = true;
|
var singleJobStatus = true;
|
||||||
var firstJobStatus;
|
var firstJobStatus;
|
||||||
var recentJobs = $scope.jobs;
|
var recentJobs = $scope.jobs;
|
||||||
|
var detailsBaseUrl;
|
||||||
|
|
||||||
if(!recentJobs){
|
if(!recentJobs){
|
||||||
return;
|
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 =
|
var sparkData =
|
||||||
_.sortBy(recentJobs.map(function(job) {
|
_.sortBy(recentJobs.map(function(job) {
|
||||||
|
|
||||||
@@ -38,6 +50,7 @@ export default ['$scope', '$filter',
|
|||||||
data.sortDate = job.finished || "running" + data.jobId;
|
data.sortDate = job.finished || "running" + data.jobId;
|
||||||
data.finished = $filter('longDate')(job.finished) || job.status+"";
|
data.finished = $filter('longDate')(job.finished) || job.status+"";
|
||||||
data.status_tip = "JOB ID: " + data.jobId + "<br>STATUS: " + data.smartStatus + "<br>FINISHED: " + data.finished;
|
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
|
// 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
|
// pending/waiting/running then we don't worry about checking for a single job status
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export default [ 'templateUrl',
|
|||||||
function(templateUrl) {
|
function(templateUrl) {
|
||||||
return {
|
return {
|
||||||
scope: {
|
scope: {
|
||||||
jobs: '='
|
jobs: '=',
|
||||||
|
templateType: '=?',
|
||||||
},
|
},
|
||||||
templateUrl: templateUrl('smart-status/smart-status'),
|
templateUrl: templateUrl('smart-status/smart-status'),
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="SmartStatus-container">
|
<div class="SmartStatus-container">
|
||||||
<div ng-repeat="job in sparkArray track by $index" class='SmartStatus-iconContainer'>
|
<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}}"
|
aw-tool-tip="{{job.status_tip}}"
|
||||||
data-tip-watch="job.status_tip"
|
data-tip-watch="job.status_tip"
|
||||||
aw-tip-placement="left"
|
aw-tip-placement="left"
|
||||||
|
|||||||
Reference in New Issue
Block a user