mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Use template for rendering smart status
This commit is contained in:
@@ -28,8 +28,8 @@ export default
|
|||||||
columnClass: 'col-md-2 col-sm-2 col-xs-2',
|
columnClass: 'col-md-2 col-sm-2 col-xs-2',
|
||||||
searchable: false,
|
searchable: false,
|
||||||
nosort: true,
|
nosort: true,
|
||||||
ngClick: "null",
|
ngInclude: "'/static/partials/job-template-smart-status.html'",
|
||||||
smartStatus: true
|
type: 'template'
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
result += (value) ? 'true' : 'false';
|
result += (value) ? 'true' : 'false';
|
||||||
result += "\" ";
|
result += "\" ";
|
||||||
break;
|
break;
|
||||||
|
case 'columnClass':
|
||||||
|
result = 'class="';
|
||||||
|
result += value;
|
||||||
|
result += '"';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = key + "=\"" + value + "\" ";
|
result = key + "=\"" + value + "\" ";
|
||||||
}
|
}
|
||||||
@@ -551,8 +556,19 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Column', ['Attr', 'Icon', 'DropDown', 'Badge', 'BadgeCount', 'BuildLink',
|
.factory('Template', ['Attr', function(Attr) {
|
||||||
function (Attr, Icon, DropDown, Badge, BadgeCount, BuildLink) {
|
return function(field) {
|
||||||
|
var ngClass = (field.ngClass) ? Attr(field, 'ngClass') : null;
|
||||||
|
var classList = (field.columnClass) ? Attr(field, 'columnClass') : null;
|
||||||
|
var ngInclude = (field.ngInclude) ? Attr(field, 'ngInclude') : null;
|
||||||
|
var attrs = _.compact([ngClass, classList, ngInclude]);
|
||||||
|
|
||||||
|
return '<td ' + attrs.join(' ') + '></td>';
|
||||||
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('Column', ['Attr', 'Icon', 'DropDown', 'Badge', 'BadgeCount', 'BuildLink', 'Template',
|
||||||
|
function (Attr, Icon, DropDown, Badge, BadgeCount, BuildLink, Template) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
var list = params.list,
|
var list = params.list,
|
||||||
fld = params.fld,
|
fld = params.fld,
|
||||||
@@ -567,6 +583,8 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
html = BadgeCount(params);
|
html = BadgeCount(params);
|
||||||
} else if (field.type === 'badgeOnly') {
|
} else if (field.type === 'badgeOnly') {
|
||||||
html = Badge(field);
|
html = Badge(field);
|
||||||
|
} else if (field.type === 'template') {
|
||||||
|
html = Template(field);
|
||||||
} else {
|
} else {
|
||||||
html += "<td class=\"" + fld + "-column";
|
html += "<td class=\"" + fld + "-column";
|
||||||
html += (field['class']) ? " " + field['class'] : "";
|
html += (field['class']) ? " " + field['class'] : "";
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
export default ['$scope', function ($scope) {
|
export default ['$scope', function ($scope) {
|
||||||
|
|
||||||
var str = $scope.job_template.id+'_smart',
|
var recentJobs = $scope.jobs;
|
||||||
recentJobs = $scope.job_template.summary_fields.recent_jobs;
|
|
||||||
$scope[str] = {
|
|
||||||
id: $scope.job_template.id,
|
|
||||||
sparkArray: [],
|
|
||||||
jobIds: {},
|
|
||||||
smartStatus: []
|
|
||||||
};
|
|
||||||
|
|
||||||
function isFailureState(status) {
|
function isFailureState(status) {
|
||||||
return status === 'failed' || status === 'error' || status === 'canceled';
|
return status === 'failed' || status === 'error' || status === 'canceled';
|
||||||
@@ -32,9 +25,9 @@ export default ['$scope', function ($scope) {
|
|||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope[str].sparkArray = _.pluck(sparkData, 'value');
|
$scope.sparkArray = _.pluck(sparkData, 'value');
|
||||||
$scope[str].jobIds = _.pluck(sparkData, 'jobId');
|
$scope.jobIds = _.pluck(sparkData, 'jobId');
|
||||||
$scope[str].smartStatus = _.pluck(sparkData, 'smartStatus');
|
$scope.smartStatus = _.pluck(sparkData, 'smartStatus');
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import smartStatusController from 'tower/smart-status/smart-status.controller.js';
|
import smartStatusController from 'tower/smart-status/smart-status.controller.js';
|
||||||
export default [ function() {
|
export default [ function() {
|
||||||
return {
|
return {
|
||||||
|
scope: {
|
||||||
|
jobs: '='
|
||||||
|
},
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
link: function (scope){
|
link: function (scope, element){
|
||||||
var str = scope.job_template.id+'_smart';
|
|
||||||
|
|
||||||
scope[str].formatter = function(sparklines, options, point){
|
scope.formatter = function(sparklines, options, point){
|
||||||
var status = options.userOptions.tooltipValueLookups.status[point.offset];
|
var status = options.userOptions.tooltipValueLookups.status[point.offset];
|
||||||
//capitalize first letter
|
//capitalize first letter
|
||||||
status = status.charAt(0).toUpperCase() + status.slice(1);
|
status = status.charAt(0).toUpperCase() + status.slice(1);
|
||||||
@@ -14,7 +16,7 @@ export default [ function() {
|
|||||||
"<br>Status: <span style=\"color: " + point.color + "\">●</span>"+status+"</div>" ;
|
"<br>Status: <span style=\"color: " + point.color + "\">●</span>"+status+"</div>" ;
|
||||||
};
|
};
|
||||||
|
|
||||||
$('aw-smart-status:eq('+scope.$index+')').sparkline(scope[str].sparkArray, {
|
element.sparkline(scope.sparkArray, {
|
||||||
type: 'tristate',
|
type: 'tristate',
|
||||||
width: '4em',
|
width: '4em',
|
||||||
height: '2em',
|
height: '2em',
|
||||||
@@ -23,11 +25,11 @@ export default [ function() {
|
|||||||
zeroBarColor: 'grey',
|
zeroBarColor: 'grey',
|
||||||
posBarColor: '#00aa00',
|
posBarColor: '#00aa00',
|
||||||
negBarColor: '#aa0000',
|
negBarColor: '#aa0000',
|
||||||
tooltipFormatter: scope[str].formatter,
|
tooltipFormatter: scope.formatter,
|
||||||
tooltipFormat: '{{value:jobs}}',
|
tooltipFormat: '{{value:jobs}}',
|
||||||
tooltipValueLookups: {
|
tooltipValueLookups: {
|
||||||
jobs: scope[str].jobIds,
|
jobs: scope.jobIds,
|
||||||
status: scope[str].smartStatus
|
status: scope.smartStatus
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
1
awx/ui/static/partials/job-template-smart-status.html
Normal file
1
awx/ui/static/partials/job-template-smart-status.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<aw-smart-status jobs="job_template.summary_fields.recent_jobs"></aw-smart-status>
|
||||||
Reference in New Issue
Block a user