From 7c80efc0d5431180f6910d432bc2ca6e92718221 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Tue, 10 Mar 2015 16:21:31 -0400 Subject: [PATCH] Use template for rendering smart status --- awx/ui/static/js/lists/JobTemplates.js | 4 ++-- awx/ui/static/js/shared/generator-helpers.js | 22 +++++++++++++++++-- .../smart-status/smart-status.controller.js | 15 ++++--------- .../js/smart-status/smart-status.directive.js | 16 ++++++++------ .../partials/job-template-smart-status.html | 1 + 5 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 awx/ui/static/partials/job-template-smart-status.html diff --git a/awx/ui/static/js/lists/JobTemplates.js b/awx/ui/static/js/lists/JobTemplates.js index 442bca15df..6b1afb5df2 100644 --- a/awx/ui/static/js/lists/JobTemplates.js +++ b/awx/ui/static/js/lists/JobTemplates.js @@ -28,8 +28,8 @@ export default columnClass: 'col-md-2 col-sm-2 col-xs-2', searchable: false, nosort: true, - ngClick: "null", - smartStatus: true + ngInclude: "'/static/partials/job-template-smart-status.html'", + type: 'template' }, name: { key: true, diff --git a/awx/ui/static/js/shared/generator-helpers.js b/awx/ui/static/js/shared/generator-helpers.js index 085e9df298..37a0be35f8 100644 --- a/awx/ui/static/js/shared/generator-helpers.js +++ b/awx/ui/static/js/shared/generator-helpers.js @@ -66,6 +66,11 @@ angular.module('GeneratorHelpers', [systemStatus.name]) result += (value) ? 'true' : 'false'; result += "\" "; break; + case 'columnClass': + result = 'class="'; + result += value; + result += '"'; + break; default: result = key + "=\"" + value + "\" "; } @@ -551,8 +556,19 @@ angular.module('GeneratorHelpers', [systemStatus.name]) }; }]) -.factory('Column', ['Attr', 'Icon', 'DropDown', 'Badge', 'BadgeCount', 'BuildLink', - function (Attr, Icon, DropDown, Badge, BadgeCount, BuildLink) { +.factory('Template', ['Attr', function(Attr) { + 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 ''; + }; +}]) + +.factory('Column', ['Attr', 'Icon', 'DropDown', 'Badge', 'BadgeCount', 'BuildLink', 'Template', + function (Attr, Icon, DropDown, Badge, BadgeCount, BuildLink, Template) { return function (params) { var list = params.list, fld = params.fld, @@ -567,6 +583,8 @@ angular.module('GeneratorHelpers', [systemStatus.name]) html = BadgeCount(params); } else if (field.type === 'badgeOnly') { html = Badge(field); + } else if (field.type === 'template') { + html = Template(field); } else { html += "Status: "+status+"" ; }; - $('aw-smart-status:eq('+scope.$index+')').sparkline(scope[str].sparkArray, { + element.sparkline(scope.sparkArray, { type: 'tristate', width: '4em', height: '2em', @@ -23,11 +25,11 @@ export default [ function() { zeroBarColor: 'grey', posBarColor: '#00aa00', negBarColor: '#aa0000', - tooltipFormatter: scope[str].formatter, + tooltipFormatter: scope.formatter, tooltipFormat: '{{value:jobs}}', tooltipValueLookups: { - jobs: scope[str].jobIds, - status: scope[str].smartStatus + jobs: scope.jobIds, + status: scope.smartStatus } }); diff --git a/awx/ui/static/partials/job-template-smart-status.html b/awx/ui/static/partials/job-template-smart-status.html new file mode 100644 index 0000000000..a9c6365970 --- /dev/null +++ b/awx/ui/static/partials/job-template-smart-status.html @@ -0,0 +1 @@ +