Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 1 | // Client script for Zuul status page |
| 2 | // |
| 3 | // Copyright 2012 OpenStack Foundation |
| 4 | // Copyright 2013 Timo Tijhof |
| 5 | // Copyright 2013 Wikimedia Foundation |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 6 | // Copyright 2014 Rackspace Australia |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 7 | // |
| 8 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | // not use this file except in compliance with the License. You may obtain |
| 10 | // a copy of the License at |
| 11 | // |
| 12 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | // |
| 14 | // Unless required by applicable law or agreed to in writing, software |
| 15 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | // License for the specific language governing permissions and limitations |
| 18 | // under the License. |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 19 | 'use strict'; |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 20 | |
| 21 | (function ($) { |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 22 | var $container, $msg, $indicator, $queueInfo, $queueEventsNum, |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 23 | $queueResultsNum, $pipelines, $jq; |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 24 | var xhr, zuul, |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 25 | current_filter = '', |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 26 | demo = location.search.match(/[?&]demo=([^?&]*)/), |
Joshua Hesketh | 668700b | 2014-03-21 14:25:53 +1100 | [diff] [blame] | 27 | source_url = location.search.match(/[?&]source_url=([^?&]*)/), |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 28 | source = demo ? |
| 29 | './status-' + (demo[1] || 'basic') + '.json-sample' : |
James E. Blair | 7c7ed7a | 2013-05-15 13:13:26 -0700 | [diff] [blame] | 30 | 'status.json'; |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 31 | source = source_url ? source_url[1] : source; |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 32 | |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 33 | function set_cookie(name, value) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 34 | document.cookie = name + '=' + value + '; path=/'; |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | function read_cookie(name, default_value) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 38 | var nameEQ = name + '='; |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 39 | var ca = document.cookie.split(';'); |
| 40 | for(var i=0;i < ca.length;i++) { |
| 41 | var c = ca[i]; |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 42 | while (c.charAt(0) === ' ') { |
| 43 | c = c.substring(1, c.length); |
| 44 | } |
| 45 | if (c.indexOf(nameEQ) === 0) { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 46 | return c.substring(nameEQ.length, c.length); |
| 47 | } |
| 48 | } |
| 49 | return default_value; |
| 50 | } |
| 51 | |
| 52 | |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 53 | zuul = { |
| 54 | enabled: true, |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 55 | collapsed_exceptions: [], |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 56 | |
| 57 | schedule: function () { |
| 58 | if (!zuul.enabled) { |
| 59 | setTimeout(zuul.schedule, 5000); |
| 60 | return; |
| 61 | } |
| 62 | zuul.update().complete(function () { |
| 63 | setTimeout(zuul.schedule, 5000); |
| 64 | }); |
| 65 | }, |
| 66 | |
| 67 | /** @return {jQuery.Promise} */ |
| 68 | update: function () { |
| 69 | // Cancel the previous update if it hasn't completed yet. |
| 70 | if (xhr) { |
| 71 | xhr.abort(); |
| 72 | } |
| 73 | |
| 74 | zuul.emit('update-start'); |
| 75 | |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 76 | xhr = $.getJSON(source) |
| 77 | .done(function (data) { |
| 78 | if ('message' in data) { |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 79 | $msg.removeClass('alert-danger').addClass('alert-info'); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 80 | $msg.text(data.message); |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 81 | $msg.show(); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 82 | } else { |
| 83 | $msg.empty(); |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 84 | $msg.hide(); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 85 | } |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 86 | |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 87 | if ('zuul_version' in data) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 88 | $('#zuul-version-span').text(data.zuul_version); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 89 | } |
| 90 | if ('last_reconfigured' in data) { |
| 91 | var last_reconfigured = |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 92 | new Date(data.last_reconfigured); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 93 | $('#last-reconfigured-span').text( |
| 94 | last_reconfigured.toString()); |
| 95 | } |
| 96 | |
| 97 | $pipelines.html(''); |
| 98 | $.each(data.pipelines, function (i, pipeline) { |
| 99 | $pipelines.append(zuul.format.pipeline(pipeline)); |
| 100 | }); |
| 101 | |
| 102 | $queueEventsNum.text( |
| 103 | data.trigger_event_queue ? |
| 104 | data.trigger_event_queue.length : '0' |
| 105 | ); |
| 106 | $queueResultsNum.text( |
| 107 | data.result_event_queue ? |
| 108 | data.result_event_queue.length : '0' |
| 109 | ); |
| 110 | }) |
| 111 | .fail(function (err, jqXHR, errMsg) { |
| 112 | $msg.text(source + ': ' + errMsg).show(); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 113 | $msg.removeClass('zuul-msg-wrap-off'); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 114 | }) |
| 115 | .complete(function () { |
| 116 | xhr = undefined; |
| 117 | zuul.emit('update-end'); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 118 | }); |
| 119 | |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 120 | return xhr; |
| 121 | }, |
| 122 | |
| 123 | format: { |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 124 | job: function(job) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 125 | var $job_line; |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 126 | if (job.url !== null) { |
| 127 | $job_line = $('<a href="' + job.url + '" />'); |
| 128 | } |
| 129 | else{ |
| 130 | $job_line = $('<span />'); |
| 131 | } |
| 132 | $job_line.text(job.name) |
| 133 | .append(zuul.format.job_status(job)); |
| 134 | |
| 135 | if (job.voting === false) { |
| 136 | $job_line.append( |
| 137 | $(' <small />').text(' (non-voting)') |
| 138 | ); |
| 139 | } |
| 140 | return $job_line; |
| 141 | }, |
| 142 | |
| 143 | job_status: function(job) { |
| 144 | var result = job.result ? job.result.toLowerCase() : null; |
| 145 | if (result === null) { |
| 146 | result = job.url ? 'in progress' : 'queued'; |
| 147 | } |
| 148 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 149 | if (result === 'in progress') { |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 150 | return zuul.format.job_progress_bar(job.elapsed_time, |
| 151 | job.remaining_time); |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 152 | } |
| 153 | else { |
| 154 | return zuul.format.status_label(result); |
| 155 | } |
| 156 | }, |
| 157 | |
| 158 | status_label: function(result) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 159 | var $status = $('<span />'); |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 160 | $status.addClass('zuul-job-result label'); |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 161 | |
| 162 | switch (result) { |
| 163 | case 'success': |
| 164 | $status.addClass('label-success'); |
| 165 | break; |
| 166 | case 'failure': |
| 167 | $status.addClass('label-danger'); |
| 168 | break; |
| 169 | case 'unstable': |
| 170 | $status.addClass('label-warning'); |
| 171 | break; |
| 172 | case 'in progress': |
| 173 | case 'queued': |
| 174 | case 'lost': |
| 175 | $status.addClass('label-default'); |
| 176 | break; |
| 177 | } |
| 178 | $status.text(result); |
| 179 | return $status; |
| 180 | }, |
| 181 | |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 182 | job_progress_bar: function(elapsed_time, remaining_time) { |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 183 | var progress_percent = 100 * (elapsed_time / (elapsed_time + |
| 184 | remaining_time)); |
| 185 | var $bar_inner = $('<div />') |
| 186 | .addClass('progress-bar') |
| 187 | .attr('role', 'progressbar') |
| 188 | .attr('aria-valuenow', 'progressbar') |
| 189 | .attr('aria-valuemin', progress_percent) |
| 190 | .attr('aria-valuemin', '0') |
| 191 | .attr('aria-valuemax', '100') |
| 192 | .css('width', progress_percent + '%'); |
| 193 | |
| 194 | var $bar_outter = $('<div />') |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 195 | .addClass('progress zuul-job-result') |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 196 | .append($bar_inner); |
| 197 | |
| 198 | return $bar_outter; |
| 199 | }, |
| 200 | |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 201 | enqueue_time: function(ms) { |
| 202 | // Special format case for enqueue time to add style |
| 203 | var hours = 60 * 60 * 1000; |
| 204 | var now = Date.now(); |
| 205 | var delta = now - ms; |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 206 | var status = 'text-success'; |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 207 | var text = zuul.format.time(delta, true); |
| 208 | if (delta > (4 * hours)) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 209 | status = 'text-danger'; |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 210 | } else if (delta > (2 * hours)) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 211 | status = 'text-warning'; |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 212 | } |
| 213 | return '<span class="' + status + '">' + text + '</span>'; |
| 214 | }, |
| 215 | |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 216 | time: function(ms, words) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 217 | if (typeof(words) === 'undefined') { |
| 218 | words = false; |
| 219 | } |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 220 | var seconds = (+ms)/1000; |
| 221 | var minutes = Math.floor(seconds/60); |
| 222 | var hours = Math.floor(minutes/60); |
| 223 | seconds = Math.floor(seconds % 60); |
| 224 | minutes = Math.floor(minutes % 60); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 225 | var r = ''; |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 226 | if (words) { |
| 227 | if (hours) { |
| 228 | r += hours; |
| 229 | r += ' hr '; |
| 230 | } |
| 231 | r += minutes + ' min'; |
| 232 | } else { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 233 | if (hours < 10) { |
| 234 | r += '0'; |
| 235 | } |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 236 | r += hours + ':'; |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 237 | if (minutes < 10) { |
| 238 | r += '0'; |
| 239 | } |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 240 | r += minutes + ':'; |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 241 | if (seconds < 10) { |
| 242 | r += '0'; |
| 243 | } |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 244 | r += seconds; |
| 245 | } |
| 246 | return r; |
| 247 | }, |
| 248 | |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 249 | change_total_progress_bar: function(change) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 250 | var job_percent = Math.floor(100 / change.jobs.length); |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 251 | var $bar_outter = $('<div />') |
| 252 | .addClass('progress zuul-change-total-result'); |
| 253 | |
| 254 | $.each(change.jobs, function (i, job) { |
| 255 | var result = job.result ? job.result.toLowerCase() : null; |
| 256 | if (result === null) { |
| 257 | result = job.url ? 'in progress' : 'queued'; |
| 258 | } |
| 259 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 260 | if (result !== 'queued') { |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 261 | var $bar_inner = $('<div />') |
| 262 | .addClass('progress-bar'); |
| 263 | |
| 264 | switch (result) { |
| 265 | case 'success': |
| 266 | $bar_inner.addClass('progress-bar-success'); |
| 267 | break; |
| 268 | case 'lost': |
| 269 | case 'failure': |
| 270 | $bar_inner.addClass('progress-bar-danger'); |
| 271 | break; |
| 272 | case 'unstable': |
| 273 | $bar_inner.addClass('progress-bar-warning'); |
| 274 | break; |
| 275 | case 'in progress': |
| 276 | case 'queued': |
| 277 | break; |
| 278 | } |
| 279 | $bar_inner.attr('title', job.name) |
| 280 | .css('width', job_percent + '%'); |
| 281 | $bar_outter.append($bar_inner); |
| 282 | } |
| 283 | }); |
| 284 | return $bar_outter; |
| 285 | }, |
| 286 | |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 287 | change_header: function(change) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 288 | var change_id = change.id || 'NA'; |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 289 | if (change_id.length === 40) { |
| 290 | change_id = change_id.substr(0, 7); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 291 | } |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 292 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 293 | var $change_link = $('<small />'); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 294 | if (change.url !== null) { |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 295 | $change_link.append( |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 296 | $('<a />').attr('href', change.url).text(change.id) |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 297 | ); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 298 | } |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 299 | else { |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 300 | $change_link.text(change_id); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 301 | } |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 302 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 303 | var $change_progress_row_left = $('<div />') |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 304 | .addClass('col-xs-3') |
| 305 | .append($change_link); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 306 | var $change_progress_row_right = $('<div />') |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 307 | .addClass('col-xs-9') |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 308 | .append(zuul.format.change_total_progress_bar(change)); |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 309 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 310 | var $change_progress_row = $('<div />') |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 311 | .addClass('row') |
| 312 | .append($change_progress_row_left) |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 313 | .append($change_progress_row_right); |
Joshua Hesketh | f1b06ca | 2014-03-21 17:01:12 +1100 | [diff] [blame] | 314 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 315 | var $project_span = $('<span />') |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 316 | .addClass('change_project') |
| 317 | .text(change.project); |
| 318 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 319 | var $left = $('<div />') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 320 | .addClass('col-xs-8') |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 321 | .append($project_span, $('<br />'), $change_progress_row); |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 322 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 323 | var remaining_time = zuul.format.time( |
| 324 | change.remaining_time, true); |
| 325 | var enqueue_time = zuul.format.enqueue_time( |
| 326 | change.enqueue_time); |
| 327 | var $remaining_time = $('<small />').addClass('time') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 328 | .attr('title', 'Remaining Time').html(remaining_time); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 329 | var $enqueue_time = $('<small />').addClass('time') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 330 | .attr('title', 'Elapsed Time').html(enqueue_time); |
| 331 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 332 | var $right = $('<div />') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 333 | .addClass('col-xs-4 text-right') |
| 334 | .append($remaining_time, $('<br />'), $enqueue_time); |
| 335 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 336 | var $header = $('<div />') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 337 | .addClass('row') |
| 338 | .append($left, $right); |
| 339 | return $header; |
| 340 | }, |
| 341 | |
| 342 | change_list: function(jobs) { |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 343 | var $list = $('<ul />') |
| 344 | .addClass('list-group'); |
| 345 | |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 346 | $.each(jobs, function (i, job) { |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 347 | var $item = $('<li />') |
| 348 | .addClass('list-group-item') |
| 349 | .addClass('zuul-change-job') |
| 350 | .append(zuul.format.job(job)); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 351 | $list.append($item); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 352 | }); |
| 353 | |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 354 | return $list; |
| 355 | }, |
| 356 | |
| 357 | change_panel: function (change) { |
| 358 | var $header = $('<div />') |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 359 | .addClass('panel-heading patchset-header') |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 360 | .append(zuul.format.change_header(change)); |
| 361 | |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 362 | var panel_id = change.id ? change.id.replace(',', '_') |
| 363 | : change.project.replace('/', '_') + |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 364 | '-' + change.enqueue_time; |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 365 | var $panel = $('<div />') |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 366 | .attr('id', panel_id) |
Joshua Hesketh | 0ca1e2e | 2014-03-21 16:49:05 +1100 | [diff] [blame] | 367 | .addClass('panel panel-default zuul-change') |
| 368 | .append($header) |
| 369 | .append(zuul.format.change_list(change.jobs)); |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 370 | |
| 371 | $header.click(zuul.toggle_patchset); |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 372 | return $panel; |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 373 | }, |
| 374 | |
| 375 | pipeline: function (pipeline) { |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 376 | var $html = $('<div />') |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 377 | .addClass('zuul-pipeline col-md-4') |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 378 | .append($('<h3 />').text(pipeline.name)); |
| 379 | |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 380 | if (typeof pipeline.description === 'string') { |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 381 | $html.append( |
| 382 | $('<p />').append( |
| 383 | $('<small />').text(pipeline.description) |
| 384 | ) |
| 385 | ); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 386 | } |
| 387 | |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 388 | $.each(pipeline.change_queues, |
| 389 | function (queueNum, changeQueue) { |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 390 | $.each(changeQueue.heads, function (headNum, changes) { |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 391 | if (pipeline.change_queues.length > 1 && |
| 392 | headNum === 0) { |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 393 | var name = changeQueue.name; |
Joshua Hesketh | 6b1a218 | 2014-03-21 14:40:04 +1100 | [diff] [blame] | 394 | var short_name = name; |
| 395 | if (short_name.length > 32) { |
| 396 | short_name = short_name.substr(0, 32) + '...'; |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 397 | } |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 398 | $html.append( |
| 399 | $('<p />') |
| 400 | .text('Queue: ') |
| 401 | .append( |
| 402 | $('<abbr />') |
| 403 | .attr('title', name) |
| 404 | .text(short_name) |
| 405 | ) |
| 406 | ); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 407 | } |
| 408 | $.each(changes, function (changeNum, change) { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 409 | var $panel = zuul.format.change_panel(change); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 410 | $html.append($panel); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 411 | zuul.display_patchset($panel); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 412 | }); |
| 413 | }); |
| 414 | }); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 415 | return $html; |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 416 | }, |
| 417 | |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 418 | filter_form_group: function() { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 419 | // Update the filter form with a clear button if required |
| 420 | |
| 421 | var $label = $('<label />') |
| 422 | .addClass('control-label') |
| 423 | .attr('for', 'filter_string') |
| 424 | .text('Filters') |
| 425 | .css('padding-right', '0.5em'); |
| 426 | |
| 427 | var $input = $('<input />') |
| 428 | .attr('type', 'text') |
| 429 | .attr('id', 'filter_string') |
| 430 | .addClass('form-control') |
| 431 | .attr('title', |
| 432 | 'project(s), pipeline(s) or review(s) comma ' + |
| 433 | 'separated') |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 434 | .attr('value', current_filter); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 435 | |
| 436 | $input.change(zuul.handle_filter_change); |
| 437 | |
| 438 | var $clear_icon = $('<span />') |
| 439 | .addClass('form-control-feedback') |
| 440 | .addClass('glyphicon glyphicon-remove-circle') |
| 441 | .attr('id', 'filter_form_clear_box') |
| 442 | .attr('title', 'clear filter') |
| 443 | .css('cursor', 'pointer'); |
| 444 | |
| 445 | $clear_icon.click(function() { |
| 446 | $('#filter_string').val('').change(); |
| 447 | }); |
| 448 | |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 449 | if (current_filter === '') { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 450 | $clear_icon.hide(); |
| 451 | } |
| 452 | |
| 453 | var $form_group = $('<div />') |
| 454 | .addClass('form-group has-feedback') |
| 455 | .append($label, $input, $clear_icon); |
| 456 | return $form_group; |
| 457 | }, |
| 458 | |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 459 | expand_form_group: function() { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 460 | var expand_by_default = ( |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 461 | read_cookie('zuul_expand_by_default', false) === 'true'); |
| 462 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 463 | var $checkbox = $('<input />') |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 464 | .attr('type', 'checkbox') |
| 465 | .attr('id', 'expand_by_default') |
| 466 | .prop('checked', expand_by_default) |
| 467 | .change(zuul.handle_expand_by_default); |
| 468 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 469 | var $label = $('<label />') |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 470 | .css('padding-left', '1em') |
| 471 | .html('Expand by default: ') |
| 472 | .append($checkbox); |
| 473 | |
| 474 | var $form_group = $('<div />') |
| 475 | .addClass('checkbox') |
| 476 | .append($label); |
| 477 | return $form_group; |
| 478 | }, |
| 479 | |
| 480 | control_form: function() { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 481 | // Build the filter form filling anything from cookies |
| 482 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 483 | var $control_form = $('<form />') |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 484 | .attr('role', 'form') |
| 485 | .addClass('form-inline') |
| 486 | .submit(zuul.handle_filter_change); |
| 487 | |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 488 | $control_form |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 489 | .append(zuul.format.filter_form_group()) |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 490 | .append(zuul.format.expand_form_group()); |
| 491 | |
| 492 | return $control_form; |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 493 | }, |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 494 | }, |
| 495 | |
| 496 | emit: function () { |
| 497 | $jq.trigger.apply($jq, arguments); |
| 498 | return this; |
| 499 | }, |
| 500 | on: function () { |
| 501 | $jq.on.apply($jq, arguments); |
| 502 | return this; |
| 503 | }, |
| 504 | one: function () { |
| 505 | $jq.one.apply($jq, arguments); |
| 506 | return this; |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 507 | }, |
| 508 | |
| 509 | toggle_patchset: function(e) { |
| 510 | // Toggle showing/hiding the patchset when the header is clicked |
| 511 | // Grab the patchset panel |
| 512 | var $panel = $(e.target).parents('.zuul-change'); |
| 513 | var $body = $panel.children(':not(.patchset-header)'); |
| 514 | $body.toggle(200); |
| 515 | var collapsed_index = zuul.collapsed_exceptions.indexOf( |
| 516 | $panel.attr('id')); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 517 | if (collapsed_index === -1 ) { |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 518 | // Currently not an exception, add it to list |
| 519 | zuul.collapsed_exceptions.push($panel.attr('id')); |
| 520 | } |
| 521 | else { |
| 522 | // Currently an except, remove from exceptions |
| 523 | zuul.collapsed_exceptions.splice(collapsed_index, 1); |
| 524 | } |
| 525 | }, |
| 526 | |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 527 | display_patchset: function($panel, animate) { |
| 528 | // Determine if to show or hide the patchset and/or the results |
| 529 | // when loaded |
| 530 | |
| 531 | // See if we should hide the body/results |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 532 | var $body = $panel.children(':not(.patchset-header)'); |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 533 | var expand_by_default = $('#expand_by_default').prop('checked'); |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 534 | var collapsed_index = zuul.collapsed_exceptions.indexOf( |
| 535 | $panel.attr('id')); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 536 | if (expand_by_default && collapsed_index === -1 || |
| 537 | !expand_by_default && collapsed_index !== -1) { |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 538 | // Expand by default, or is an exception |
| 539 | $body.show(animate); |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 540 | } |
| 541 | else { |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 542 | $body.hide(animate); |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 543 | } |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 544 | |
| 545 | // Check if we should hide the whole panel |
| 546 | var panel_project = $panel.find('.change_project').text() |
| 547 | .toLowerCase(); |
| 548 | var panel_pipeline = $panel.parents('.zuul-pipeline') |
| 549 | .children('h3').text().toLowerCase(); |
| 550 | var panel_change = $panel.attr('id'); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 551 | if (current_filter !== '') { |
| 552 | var show_panel = false; |
| 553 | var filter = current_filter.trim().split(/[\s,]+/); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 554 | $.each(filter, function(index, f_val) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 555 | if (f_val !== '') { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 556 | f_val = f_val.toLowerCase(); |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 557 | if (panel_project.indexOf(f_val) !== -1 || |
| 558 | panel_pipeline.indexOf(f_val) !== -1 || |
| 559 | panel_change.indexOf(f_val) !== -1) { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 560 | show_panel = true; |
| 561 | } |
| 562 | } |
| 563 | }); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 564 | if (show_panel === true) { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 565 | $panel.show(animate); |
| 566 | } |
| 567 | else { |
| 568 | $panel.hide(animate); |
| 569 | } |
| 570 | } |
| 571 | else { |
| 572 | $panel.show(animate); |
| 573 | } |
| 574 | }, |
| 575 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 576 | handle_filter_change: function() { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 577 | // Update the filter and save it to a cookie |
| 578 | current_filter = $('#filter_string').val(); |
| 579 | set_cookie('zuul_filter_string', current_filter); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 580 | if (current_filter === '') { |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 581 | $('#filter_form_clear_box').hide(); |
| 582 | } |
| 583 | else { |
| 584 | $('#filter_form_clear_box').show(); |
| 585 | } |
| 586 | |
| 587 | $('.zuul-change').each(function(index, obj) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 588 | var $panel = $(obj); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 589 | zuul.display_patchset($panel, 200); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 590 | }); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 591 | return false; |
Joshua Hesketh | db8046e | 2014-03-21 18:42:25 +1100 | [diff] [blame] | 592 | }, |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 593 | |
| 594 | handle_expand_by_default: function(e) { |
| 595 | // Handle toggling expand by default |
| 596 | set_cookie('zuul_expand_by_default', e.target.checked); |
| 597 | zuul.collapsed_exceptions = []; |
| 598 | $('.zuul-change').each(function(index, obj) { |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 599 | var $panel = $(obj); |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 600 | zuul.display_patchset($panel, 200); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 601 | }); |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 602 | }, |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 603 | }; |
| 604 | |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 605 | current_filter = read_cookie('zuul_filter_string', current_filter); |
| 606 | |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 607 | $jq = $(zuul); |
| 608 | |
| 609 | $jq.on('update-start', function () { |
| 610 | $container.addClass('zuul-container-loading'); |
| 611 | $indicator.addClass('zuul-spinner-on'); |
| 612 | }); |
| 613 | |
| 614 | $jq.on('update-end', function () { |
| 615 | $container.removeClass('zuul-container-loading'); |
| 616 | setTimeout(function () { |
| 617 | $indicator.removeClass('zuul-spinner-on'); |
Joshua Hesketh | 876ca51 | 2014-03-21 18:44:22 +1100 | [diff] [blame] | 618 | }, 500); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 619 | }); |
| 620 | |
| 621 | $jq.one('update-end', function () { |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 622 | // Do this asynchronous so that if the first update adds a message, it |
| 623 | // will not animate while we fade in the content. Instead it simply |
| 624 | // appears with the rest of the content. |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 625 | setTimeout(function () { |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 626 | // Fade in the content |
| 627 | $container.addClass('zuul-container-ready'); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 628 | }); |
| 629 | }); |
| 630 | |
| 631 | $(function ($) { |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 632 | $msg = $('<div />').addClass('alert').hide(); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 633 | $indicator = $('<button class="btn pull-right zuul-spinner">' + |
| 634 | 'updating ' + |
| 635 | '<span class="glyphicon glyphicon-refresh"></span>' + |
| 636 | '</button>'); |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 637 | $queueInfo = $('<p>Queue lengths: <span>0</span> events, ' + |
| 638 | '<span>0</span> results.</p>'); |
Joshua Hesketh | 298c491 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 639 | $queueEventsNum = $queueInfo.find('span').eq(0); |
| 640 | $queueResultsNum = $queueEventsNum.next(); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 641 | |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 642 | var $control_form = zuul.format.control_form(); |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 643 | |
Joshua Hesketh | 1ed6f9d | 2014-03-31 22:53:06 +1100 | [diff] [blame] | 644 | $pipelines = $('<div class="row"></div>'); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 645 | var $zuulVersion = $('<p>Zuul version: <span id="zuul-version-span">' + |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 646 | '</span></p>'); |
Monty Taylor | 860bb0a | 2014-03-22 09:41:25 -0700 | [diff] [blame] | 647 | var $lastReconf = $('<p>Last reconfigured: ' + |
Joshua Hesketh | cbdcca1 | 2014-03-20 16:06:25 +1100 | [diff] [blame] | 648 | '<span id="last-reconfigured-span"></span></p>'); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 649 | |
Joshua Hesketh | 4863b60 | 2014-03-21 14:19:06 +1100 | [diff] [blame] | 650 | $container = $('#zuul-container').append($msg, $indicator, |
Joshua Hesketh | ae230f6 | 2014-03-22 22:14:44 +1100 | [diff] [blame] | 651 | $queueInfo, $control_form, |
Joshua Hesketh | ace4889 | 2014-03-22 17:18:31 +1100 | [diff] [blame] | 652 | $pipelines, $zuulVersion, |
| 653 | $lastReconf); |
Timo Tijhof | 51516cd | 2013-04-09 01:32:29 +0200 | [diff] [blame] | 654 | |
| 655 | zuul.schedule(); |
| 656 | |
| 657 | $(document).on({ |
| 658 | 'show.visibility': function () { |
| 659 | zuul.enabled = true; |
| 660 | zuul.update(); |
| 661 | }, |
| 662 | 'hide.visibility': function () { |
| 663 | zuul.enabled = false; |
| 664 | } |
| 665 | }); |
| 666 | }); |
| 667 | }(jQuery)); |