Anton Shestakov <av6@dwimlabs.net>, Sat, 23 Sep 2017 13:12:20 +0800
viewer: one more place needed an explicit order_by() call
static/candolint.js
Permissions: -rw-r--r--
var humanizeTimestamps = function() { $('time[datetime]').each(function() { $this.text(moment($this.attr('datetime')).fromNow()); window.setInterval(humanizeTimestamps, 15 * 1000); $('.check-log div.task').each(function() { var task = $line.attr('data-task'); var $lines = $line.nextAll('[data-task="' + task + '"]'); if ($lines.length === 0) { return; } var $collapser = $('<a>').addClass('collapser'); $line.append($collapser); var toggle = function() { var collapsed = $collapser.hasClass('collapsed'); $lines.toggleClass('uk-hidden', collapsed); $collapser.on('click', function() { $collapser.toggleClass('collapsed'); var important = '.error, .warning, .failure, :target'; if (task !== 'checks' && $lines.filter(important).length === 0) { $collapser.addClass('collapsed'); if ($('#check-chart-data, #check-chart').length !== 2) { return; } var data = JSON.parse($('#check-chart-data').text()); var $container = $('.chart-container'); var svg = d3.select('#check-chart'); var margin = {top: 10, right: 45, bottom: 30, left: 45}; var maxE = d3.max(data.points, function(d) { return d.errors; }); var maxW = d3.max(data.points, function(d) { return d.warnings; }); var maxD = d3.max(data.points, function(d) { return d.duration; }); var x = d3.scalePoint().domain(data.points.map(function(d) { return d.ordinal; })); var y1 = d3.scaleLinear().domain([0, Math.max(maxE, maxW)]); var y2 = d3.scaleLinear().domain([0, maxD]); var formatDuration = function(d) { return moment.utc(d, 'X').format('m:ss'); var render = function() { svg.attr('width', $container.width()); svg.attr('height', $container.height()); var width = +svg.attr('width') - margin.left - margin.right; var height = +svg.attr('height') - margin.top - margin.bottom; .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); .attr('shape-rendering', 'crispEdges'); x.rangeRound([0, width]); y1.rangeRound([height, 0]); y2.rangeRound([height, 0]); .attr('stroke-dasharray', '5,2') .attr('x1', x(data.current) + 0.5) .attr('x2', x(data.current) + 0.5) var hover = cg.append('line') .attr('transform', 'translate(0,' + (height + padding) + ')') .attr('transform', 'translate(' + (-padding) + ',0)') .call(d3.axisLeft(y1).ticks(5)); .attr('transform', 'translate(' + (width + padding) + ',0)') .call(d3.axisRight(y2).ticks(5).tickFormat(formatDuration)); {name: 'duration', color: '#00a8e6', axis: y2}, {name: 'warnings', color: '#faa732', axis: y1}, {name: 'errors', color: '#da314b', axis: y1} .attr('fill', series.color) .attr('stroke-width', 2); .defined(function(d) { return d[series.name] !== null; }) .x(function(d) { return x(d.ordinal); }) .y(function(d) { return series.axis(d[series.name]); }); .attr('stroke', series.color) .filter(function(d) { return d[series.name] !== null; }) .attr('cx', function(d) { return x(d.ordinal); }) .attr('cy', function(d) { return series.axis(d[series.name]); }); .attr('x', function(d) { return x(d.ordinal) - rectW / 2 + 0.5; }) .attr('height', height + margin.top + margin.bottom) .on('mouseover', function(d) { var hx = x(d.ordinal) + 0.5; hover.attr('opacity', 1).attr('x1', hx).attr('x2', hx); .on('mouseout', function(d) { hover.attr('opacity', 0); $(window).on('resize', function() { if (+svg.attr('width') !== $container.width()) { svg.selectAll('*').remove();