| OLD | NEW |
| (Empty) | |
| 1 {% block status -%} |
| 2 |
| 3 <style> |
| 4 #waterfall-status-draining { |
| 5 background-color: orange; |
| 6 font-size: 2em; |
| 7 text-align: center; |
| 8 } |
| 9 </style> |
| 10 |
| 11 <script> |
| 12 // Regular expression to match the waterfall URL up through the master name. |
| 13 // |
| 14 // Input URL: https://build.chromium.org/p/chromium/console |
| 15 // Output: https://build.chromium.org/p/chromium/ |
| 16 var endpointRe = /(.+\/[ip]\/(.+)\/)/ |
| 17 |
| 18 function waterfallRoot() { |
| 19 var match = endpointRe.exec(window.location.href); |
| 20 if (match) { |
| 21 return match[0] + "json/"; |
| 22 } |
| 23 if (window.location.hostname === "localhost") { |
| 24 // Running on developer system. |
| 25 return window.location.origin + "/json/"; |
| 26 } |
| 27 throw ("Unable to get waterfall root for: " + window.location.href); |
| 28 } |
| 29 |
| 30 // This implemntation originated from: |
| 31 // http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promisifying-xmlht
tprequest |
| 32 function get(url) { |
| 33 return new Promise(function(resolve, reject) { |
| 34 var req = new XMLHttpRequest(); |
| 35 req.open('GET', url); |
| 36 |
| 37 req.onload = function() { |
| 38 // This is called even on 404 etc |
| 39 // so check the status |
| 40 if (req.status == 200) { |
| 41 // Resolve the promise with the response text |
| 42 resolve(req.response); |
| 43 } |
| 44 else { |
| 45 // Otherwise reject with the status text |
| 46 // which will hopefully be a meaningful error |
| 47 reject(Error(req.statusText)); |
| 48 } |
| 49 }; |
| 50 |
| 51 // Handle network errors |
| 52 req.onerror = function() { |
| 53 reject(Error("Network Error")); |
| 54 }; |
| 55 |
| 56 // Make the request |
| 57 req.send(); |
| 58 }); |
| 59 } |
| 60 |
| 61 function loadJson(endpoint) { |
| 62 var url = waterfallRoot() + endpoint; |
| 63 return get(url).then(function(response) { |
| 64 return JSON.parse(response); |
| 65 }); |
| 66 } |
| 67 |
| 68 function getWaterfallStatus() { |
| 69 if (typeof Promise === "undefined") { |
| 70 console.log("Promises are not supported. Status will not be reported.") |
| 71 return; |
| 72 } |
| 73 |
| 74 // Get a reference to our status element. |
| 75 var st = document.getElementById("waterfall-status-draining"); |
| 76 if (!st) { |
| 77 return; |
| 78 } |
| 79 |
| 80 loadJson("accepting_builds").then(function(response) { |
| 81 st.style.display = (!!response.accepting_builds) ? ("none") : ("block"); |
| 82 }); |
| 83 } |
| 84 </script> |
| 85 |
| 86 <!-- Will be shown if the waterfall is draining. --> |
| 87 <div id="waterfall-status-draining" style="display: none"> |
| 88 The waterfall is currently |
| 89 <a href="https://chromium.googlesource.com/infra/infra/+/master/doc/users/serv
ices/buildbot/index.md#Draining" target="_blank"> |
| 90 draining</a>. |
| 91 </div> |
| 92 |
| 93 <script> |
| 94 getWaterfallStatus(); |
| 95 </script> |
| 96 |
| 97 {% endblock %} |
| OLD | NEW |