From 6b1a218649cfebac5ebc9266296c54f84003b4b8 Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Fri, 21 Mar 2014 14:40:04 +1100 Subject: [PATCH] Add in progress bars for jobs Also tweak style to fit large sets of jobs better. Change-Id: I692a149a7d02a36c7f2fb481b18dd79d9da16f1b --- etc/status/public_html/app.js | 163 ++++++++++++++++++++---------- etc/status/public_html/index.html | 13 ++- 2 files changed, 124 insertions(+), 52 deletions(-) diff --git a/etc/status/public_html/app.js b/etc/status/public_html/app.js index 16195e8e31..f8e6af282e 100644 --- a/etc/status/public_html/app.js +++ b/etc/status/public_html/app.js @@ -3,6 +3,7 @@ // Copyright 2012 OpenStack Foundation // Copyright 2013 Timo Tijhof // Copyright 2013 Wikimedia Foundation +// Copyright 2014 Rackspace Australia // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain @@ -97,6 +98,107 @@ }, format: { + job: function(job) { + if (job.url !== null) { + $job_line = $(''); + } + else{ + $job_line = $(''); + } + $job_line.text(job.name) + .append(zuul.format.job_status(job)); + + if (job.voting === false) { + $job_line.append( + $(' ').text(' (non-voting)') + ); + } + return $job_line; + }, + + job_status: function(job) { + var result = job.result ? job.result.toLowerCase() : null; + if (result === null) { + result = job.url ? 'in progress' : 'queued'; + } + + if (result == 'in progress') { + return zuul.format.progress_bar(job.elapsed_time, + job.remaining_time); + } + else { + return zuul.format.status_label(result); + } + }, + + status_label: function(result) { + $status = $(''); + $status.addClass('zuul-result label'); + + switch (result) { + case 'success': + $status.addClass('label-success'); + break; + case 'failure': + $status.addClass('label-danger'); + break; + case 'unstable': + $status.addClass('label-warning'); + break; + case 'in progress': + case 'queued': + case 'lost': + $status.addClass('label-default'); + break; + } + $status.text(result); + return $status; + }, + + progress_bar: function(elapsed_time, remaining_time) { + var progress_percent = 100 * (elapsed_time / (elapsed_time + + remaining_time)); + var $bar_inner = $('
') + .addClass('progress-bar') + .attr('role', 'progressbar') + .attr('aria-valuenow', 'progressbar') + .attr('aria-valuemin', progress_percent) + .attr('aria-valuemin', '0') + .attr('aria-valuemax', '100') + .css('width', progress_percent + '%'); + + var $bar_outter = $('
') + .addClass('progress zuul-result') + .append($bar_inner); + + return $bar_outter; + }, + + time: function(ms, words) { + if (typeof(words) === 'undefined') words = false; + var seconds = (+ms)/1000; + var minutes = Math.floor(seconds/60); + var hours = Math.floor(minutes/60); + seconds = Math.floor(seconds % 60); + minutes = Math.floor(minutes % 60); + r = ''; + if (words) { + if (hours) { + r += hours; + r += ' hr '; + } + r += minutes + ' min'; + } else { + if (hours < 10) r += '0'; + r += hours + ':'; + if (minutes < 10) r += '0'; + r += minutes + ':'; + if (seconds < 10) r += '0'; + r += seconds; + } + return r; + }, + change: function (change) { if (change.id.length === 40) { change.id = change.id.substr(0, 7); @@ -119,56 +221,14 @@ $change_header.append($id_span.addClass('zuul-change-id')); $html.append($change_header); - var $list = $('