adding click event for spark lines

This commit is contained in:
Jared Tabor
2015-03-09 13:48:08 -04:00
parent a8095e870e
commit 1e68785264
2 changed files with 20 additions and 7 deletions

View File

@@ -1,11 +1,12 @@
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 [ '$location', function($location) {
return { return {
restrict: 'E', restrict: 'E',
link: function (scope){ //}, element ){ //}, attr) { link: function (scope){
var str = scope.job_template.id+'_spark'; var str = scope.job_template.id+'_spark';
scope[str].formatter = function(sparklines, options, point){ scope[str].formatter = function(sparklines, options, point){
return "<div class=\"smart-status-tooltip\"><span style=\"color: " + point.color + "\">&#9679;</span>" + return "<div class=\"smart-status-tooltip\"><span style=\"color: " + point.color + "\">&#9679;</span>" +
"Job id: " +
options.userOptions.tooltipValueLookups.jobs[point.offset] + "</div>" ; options.userOptions.tooltipValueLookups.jobs[point.offset] + "</div>" ;
}; };
@@ -13,8 +14,11 @@ export default [ function() {
type: 'tristate', type: 'tristate',
width: '4em', width: '4em',
height: '2em', height: '2em',
barWidth: 5, barWidth: 7,
barSpacing: 2, barSpacing: 2,
zeroBarColor: 'grey',
posBarColor: '#00aa00', //@green on ansible-ui
negBarColor: '#aa0000', //@red
tooltipFormatter: scope[str].formatter, tooltipFormatter: scope[str].formatter,
tooltipFormat: '{{value:jobs}}', tooltipFormat: '{{value:jobs}}',
tooltipValueLookups: { tooltipValueLookups: {
@@ -27,8 +31,16 @@ export default [ function() {
// }) // })
} }
}); });
$('aw-smart-status:eq('+scope.$index+')').bind('sparklineClick', function(ev) {
var sparkline = ev.sparklines[0],
job = sparkline.getCurrentRegionFields(),
id;
id = sparkline.options.userOptions.tooltipValueLookups.jobs[job.offset];
location.href = '/#/jobs/' + id;
});
}, },
// templateUrl: 'static/js/smart-status/smart-status.partial.html',
controller: smartStatusController controller: smartStatusController
}; };
}]; }];

View File

@@ -186,9 +186,10 @@ a:focus {
} }
.smart-status-tooltip{ .smart-status-tooltip{
font-size: 20px; font-size: 14px;
background-color: black;
span { span {
padding: 20px; padding: 14px;
} }
} }