blob: 2dccd5893ba3c6f4b8dd3097e16e064ecf863f04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** Information about a particular waterfall. */
function WaterfallInfo(waterfallData) {
var waterfallName = waterfallData[0];
var waterfallUrl = waterfallData[1];
var waterfallShowsAllBots = waterfallData[2];
// Create a table cell that acts as a header for its bot section.
var linkElement = document.createElement('a');
linkElement.href = waterfallUrl;
linkElement.innerHTML = waterfallName;
var thElement = document.createElement('th');
thElement.colSpan = 15;
thElement.className = 'section-header';
thElement.appendChild(linkElement);
this.botInfo = {};
this.inFlight = 0;
this.name = waterfallName;
this.showsAllBots = waterfallShowsAllBots;
this.thElement = thElement;
this.timeLastRequested = 0;
this.rootJsonUrl = waterfallUrl + 'json/';
this.url = waterfallUrl;
}
/** Send an asynchronous request to get the main waterfall's JSON. */
WaterfallInfo.prototype.requestJson = function() {
if (this.inFlight) {
var elapsed = new Date().getTime() - this.timeLastRequested;
if (elapsed < MAX_MILLISECONDS_TO_WAIT) return;
// A response was not received in a reasonable timeframe. Try again.
this.inFlight--;
gNumRequestsInFlight--;
gNumRequestsRetried++;
}
this.inFlight++;
this.timeLastRequested = new Date().getTime();
gNumRequestsInFlight++;
// Create the request and send it off.
var waterfallInfo = this;
var url = this.url + 'json/builders/';
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
waterfallInfo.parseJSON(JSON.parse(request.responseText));
}
};
request.send(null);
};
/** Parse out the data received about the waterfall. */
WaterfallInfo.prototype.parseJSON = function(buildersJson) {
this.inFlight--;
gNumRequestsInFlight--;
// Go through each builder on the waterfall and get the latest status.
var builderNames = Object.keys(buildersJson);
for (var i = 0; i < builderNames.length; ++i) {
var builderName = builderNames[i];
if (!this.showsAllBots && !this.shouldShowBot(builderName)) continue;
// Prepare the bot info.
var builderJson = buildersJson[builderName];
if (!this.botInfo[builderName]) {
this.botInfo[builderName] = new BotInfo(builderName,
builderJson.category);
}
this.botInfo[builderName].update(this.rootJsonUrl, builderJson);
gWaterfallDataIsDirty = true;
}
};
/** Override this function to filter out particular bots. */
WaterfallInfo.prototype.shouldShowBot = function(builderName) {
return true;
};
/** Updates the HTML. */
WaterfallInfo.prototype.updateWaterfallStatusHTML = function() {
var table = document.getElementById('build-info');
// Point at the waterfall.
var headerCell = this.thElement;
headerCell.className =
'section-header' + (this.inFlight > 0 ? ' in-flight' : '');
var headerRow = table.insertRow(-1);
headerRow.appendChild(headerCell);
// Print out useful bits about the bots.
var botNames = sortBotNamesByCategory(this.botInfo);
for (var i = 0; i < botNames.length; ++i) {
var botName = botNames[i];
var botInfo = this.botInfo[botName];
var waterfallBaseUrl = this.url + 'builders/';
var botRowElement = botInfo.createHtml(waterfallBaseUrl);
// Determine whether we should apply keyword filter.
var filter = document.getElementById('text-filter').value.trim();
if (filter.length > 0) {
var keywords = filter.split(' ');
var buildNumbers = Object.keys(botInfo.builds);
var matchesFilter = false;
for (var x = 0; x < buildNumbers.length && !matchesFilter; ++x) {
var buildStatus = botInfo.builds[buildNumbers[x]].statusText;
for (var y = 0; y < keywords.length && !matchesFilter; ++y) {
if (buildStatus.indexOf(keywords[y]) >= 0)
matchesFilter = true;
}
}
if (!matchesFilter)
continue;
}
// If the user doesn't want to see completely green bots, hide it.
var shouldHideStable =
document.getElementById('checkbox-hide-stable').checked;
if (shouldHideStable && botInfo.isSteadyGreen)
continue;
table.appendChild(botRowElement);
}
};
|