diff --git a/etc/status/public_html/app.js b/etc/status/public_html/app.js index b4c82f82ec..0780346063 100644 --- a/etc/status/public_html/app.js +++ b/etc/status/public_html/app.js @@ -19,7 +19,7 @@ (function ($) { var $container, $msg, $msgWrap, $indicator, $queueInfo, $queueEventsNum, $queueResultsNum, $pipelines, $jq; - var xhr, prevHtml, zuul, + var xhr, zuul, demo = location.search.match(/[?&]demo=([^?&]*)/), source = demo ? './status-' + (demo[1] || 'basic') + '.json-sample' : @@ -47,128 +47,135 @@ zuul.emit('update-start'); - xhr = $.ajax({ - url: source, - dataType: 'json', - cache: false - }) - .done(function (data) { - var html = ''; - data = data || {}; + xhr = $.getJSON(source) + .done(function (data) { + if ('message' in data) { + $msg.text(data.message); + $msgWrap.removeClass('zuul-msg-wrap-off'); + } else { + $msg.empty(); + $msgWrap.addClass('zuul-msg-wrap-off'); + } - if ('message' in data) { - $msg.html(data.message); - $msgWrap.removeClass('zuul-msg-wrap-off'); - } else { - $msg.empty(); - $msgWrap.addClass('zuul-msg-wrap-off'); - } + if ('zuul_version' in data) { + $('#zuul-version-span').text(data['zuul_version']); + } + if ('last_reconfigured' in data) { + var last_reconfigured = + new Date(data['last_reconfigured']); + $('#last-reconfigured-span').text( + last_reconfigured.toString()); + } - if ('zuul_version' in data) { - $('#zuul-version-span').text(data['zuul_version']); - } - if ('last_reconfigured' in data) { - var last_reconfigured = - new Date(data['last_reconfigured']); - $('#last-reconfigured-span').text( - last_reconfigured.toString()); - } + $pipelines.html(''); + $.each(data.pipelines, function (i, pipeline) { + $pipelines.append(zuul.format.pipeline(pipeline)); + }); - $.each(data.pipelines, function (i, pipeline) { - html += zuul.format.pipeline(pipeline); + $queueEventsNum.text( + data.trigger_event_queue ? + data.trigger_event_queue.length : '0' + ); + $queueResultsNum.text( + data.result_event_queue ? + data.result_event_queue.length : '0' + ); + }) + .fail(function (err, jqXHR, errMsg) { + $msg.text(source + ': ' + errMsg).show(); + $msgWrap.removeClass('zuul-msg-wrap-off'); + }) + .complete(function () { + xhr = undefined; + zuul.emit('update-end'); }); - // Only re-parse the DOM if we have to - if (html !== prevHtml) { - prevHtml = html; - $pipelines.html(html); - } - - $queueEventsNum.text( - data.trigger_event_queue ? - data.trigger_event_queue.length : '0' - ); - $queueResultsNum.text( - data.result_event_queue ? - data.result_event_queue.length : '0' - ); - }) - .fail(function (err, jqXHR, errMsg) { - $msg.text(source + ': ' + errMsg).show(); - $msgWrap.removeClass('zuul-msg-wrap-off'); - }) - .complete(function () { - xhr = undefined; - zuul.emit('update-end'); - }); - return xhr; }, format: { change: function (change) { - var html = '
' + pipeline.description + - '
'; + $html.append( + $('').append( + $('').text(pipeline.description) + ) + ); } $.each(pipeline.change_queues, @@ -177,26 +184,25 @@ if (pipeline.change_queues.length > 1 && headNum === 0) { var name = changeQueue.name; - html += 'Queue: '; if (name.length > 32) { - name = name.substr(0, 32) + '...'; + short_name = name.substr(0, 32) + '...'; } - html += name + '
'; + $html.append( + $('') + .text('Queue: ') + .append( + $('') + .attr('title', name) + .text(short_name) + ) + ); } $.each(changes, function (changeNum, change) { - // If there are multiple changes in the same head - // it means they're connected - if (changeNum > 0) { - html += 'Queue lengths: 0 events, ' + '0 results.
'); - $queueEventsNum = $queueInfo.find('span').eq(0); - $queueResultsNum = $queueEventsNum.next(); + $queueEventsNum = $queueInfo.find('span').eq(0); + $queueResultsNum = $queueEventsNum.next(); $pipelines = $(''); $zuulVersion = $('Zuul version: ' + '
');