Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: masters/master.tryserver.chromium.linux/public_html/gantt_chart.js

Issue 2489813002: Revert of Adding gantt chart to Build Status page on Buildbot Masters (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 google.charts.load('current', {'packages':['gantt']});
5
6 /**
7 * reconcileSwarmingSteps reconciles a Swarming step's "trigger" step with
8 * it's subsequent "collect results" step.
9 *
10 * Swarming steps in BuildBot create two steps - one to trigger the work
11 * on swarming, and a later step to collect the results.
12 *
13 * The two steps have the same name, except the trigger step has "[trigger] "
14 * prepended to the name.
15 *
16 * This function consolidates the two steps into one by using the start
17 * time from the trigger step and the end time from the "collect results"
18 * step.
19 *
20 * This function assumes that a trigger step will be found before the
21 * corresponding "collect results" step in the list of steps.
22 * @param {Array<Object>} steps List of step objects. Each step object
23 * has the following properties: name {string}, start {Date}, end {Date}
24 */
25 function reconcileSwarmingSteps(steps) {
26 let reconciledSteps = [];
27 let triggerSteps = {};
28
29 for (let s of steps) {
30 // trigger steps have names like "[trigger] TheRestOfTheNameGoesHere..."
31 let isTriggerStep = /\[trigger\] (.*)/.exec(s.name);
32 if (isTriggerStep) {
33 triggerSteps[isTriggerStep[1]] = s;
34 } else {
35 if (triggerSteps[s.name]) {
36 s.start = triggerSteps[s.name].start;
37 }
38 reconciledSteps.push(s);
39 }
40 }
41
42 return reconciledSteps;
43 };
44
45 function drawChart(steps) {
46 let data = new google.visualization.DataTable();
47 data.addColumn('string', 'Task ID');
48 data.addColumn('string', 'Task Name');
49 data.addColumn('string', 'Resource');
50 data.addColumn('date', 'Start Date');
51 data.addColumn('date', 'End Date');
52 data.addColumn('number', 'Duration');
53 data.addColumn('number', 'Percent Complete');
54 data.addColumn('string', 'Dependencies');
55
56 for (s of steps) {
57 data.addRow([s.name, s.name, null, s.start, s.end, null, 100, null]);
58 }
59
60 let trackHeight = 25;
61 let options = {
62 height: data.getNumberOfRows() * trackHeight,
63 gantt: {
64 trackHeight: trackHeight,
65 barHeight: trackHeight * 0.8,
66 labelMaxWidth: 500,
67 }
68 };
69
70 let chart = new google.visualization.Gantt(
71 document.getElementById('chart_div'));
72 chart.draw(data, options);
73 }
74
75 let chartVisible = false;
76 function toggleChart(rawSteps) {
77 if (chartVisible) {
78 document.getElementById('chart_div').style.display = 'none';
79 chartVisible = false;
80 } else {
81 document.getElementById('chart_div').style.display = 'block';
82 let steps = reconcileSwarmingSteps(rawSteps);
83 drawChart(steps);
84 chartVisible = true;
85 }
86 }
OLDNEW
« no previous file with comments | « masters/master.tryserver.blink/templates/build.html ('k') | masters/master.tryserver.chromium.linux/templates/build.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698