1 window.App = Ember.Application.create();
3 App.Router.map(function () {
4 this.resource('charts', {path: 'charts'});
5 this.resource('analysis', {path: 'analysis'});
6 this.resource('analysisTask', {path: 'analysis/task/:taskId'});
9 App.DashboardRow = Ember.Object.extend({
17 var cellsInfo = this.get('cellsInfo') || [];
18 var columnCount = this.get('columnCount');
19 while (cellsInfo.length < columnCount)
22 this.set('cells', cellsInfo.map(this._createPane.bind(this)));
24 addPane: function (paneInfo)
26 var pane = this._createPane(paneInfo);
27 this.get('cells').pushObject(pane);
28 this.set('columnCount', this.get('columnCount') + 1);
30 _createPane: function (paneInfo)
32 if (!paneInfo || !paneInfo.length || (!paneInfo[0] && !paneInfo[1]))
35 var pane = App.Pane.create({
36 store: this.get('store'),
37 platformId: paneInfo ? paneInfo[0] : null,
38 metricId: paneInfo ? paneInfo[1] : null,
41 return App.DashboardPaneProxyForPicker.create({content: pane});
45 App.DashboardPaneProxyForPicker = Ember.ObjectProxy.extend({
46 _platformOrMetricIdChanged: function ()
49 App.buildPopup(this.get('store'), 'choosePane', this)
50 .then(function (platforms) { self.set('pickerData', platforms); });
51 }.observes('platformId', 'metricId').on('init'),
52 paneList: function () {
53 return App.encodePrettifiedJSON([[this.get('platformId'), this.get('metricId'), null, null, false]]);
54 }.property('platformId', 'metricId'),
57 App.IndexController = Ember.Controller.extend({
58 queryParams: ['grid', 'numberOfDays'],
65 gridChanged: function ()
67 var grid = this.get('grid');
68 if (grid === this._previousGrid)
73 dashboard = App.Dashboard.create({serialized: grid});
74 if (!dashboard.get('headerColumns').length)
78 dashboard = App.Manifest.get('defaultDashboard');
82 var headerColumns = dashboard.get('headerColumns');
83 this.set('headerColumns', headerColumns);
84 var columnCount = headerColumns.length;
85 this.set('columnCount', columnCount);
87 var store = this.store;
88 this.set('rows', dashboard.get('rows').map(function (rowParam) {
89 return App.DashboardRow.create({
92 cellsInfo: rowParam.slice(1),
93 columnCount: columnCount,
97 this.set('emptyRow', new Array(columnCount));
98 }.observes('grid', 'App.Manifest.defaultDashboard').on('init'),
100 updateGrid: function()
102 var headers = this.get('headerColumns').map(function (header) { return header.label; });
103 var table = [headers].concat(this.get('rows').map(function (row) {
104 return [row.get('header')].concat(row.get('cells').map(function (pane) {
105 var platformAndMetric = [pane.get('platformId'), pane.get('metricId')];
106 return platformAndMetric[0] || platformAndMetric[1] ? platformAndMetric : [];
109 this._previousGrid = JSON.stringify(table);
110 this.set('grid', this._previousGrid);
113 _sharedDomainChanged: function ()
115 var numberOfDays = this.get('numberOfDays');
119 numberOfDays = parseInt(numberOfDays);
120 var present = Date.now();
121 var past = present - numberOfDays * 24 * 3600 * 1000;
122 this.set('sharedDomain', [past, present]);
123 }.observes('numberOfDays').on('init'),
126 setNumberOfDays: function (numberOfDays)
128 this.set('numberOfDays', numberOfDays);
130 choosePane: function (param)
132 var pane = param.position;
133 pane.set('platformId', param.platform.get('id'));
134 pane.set('metricId', param.metric.get('id'));
136 addColumn: function ()
138 this.get('headerColumns').pushObject({
139 label: this.get('newColumnHeader'),
140 index: this.get('headerColumns').length,
142 this.get('rows').forEach(function (row) {
145 this.set('newColumnHeader', null);
147 removeColumn: function (index)
149 this.get('headerColumns').removeAt(index);
150 this.get('rows').forEach(function (row) {
151 row.get('cells').removeAt(index);
156 this.get('rows').pushObject(App.DashboardRow.create({
158 header: this.get('newRowHeader'),
159 columnCount: this.get('columnCount'),
161 this.set('newRowHeader', null);
163 removeRow: function (row)
165 this.get('rows').removeObject(row);
167 resetPane: function (pane)
169 pane.set('platformId', null);
170 pane.set('metricId', null);
172 toggleEditMode: function ()
174 this.toggleProperty('editMode');
175 if (!this.get('editMode'))
183 App.Manifest.fetch(this.get('store'));
187 App.NumberOfDaysControlView = Ember.View.extend({
188 classNames: ['controls'],
189 templateName: 'number-of-days-controls',
190 didInsertElement: function ()
192 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
194 _numberOfDaysChanged: function ()
196 this._matchingElements(this._previousNumberOfDaysClass).removeClass('active');
198 var newNumberOfDaysClass = 'numberOfDaysIs' + this.get('numberOfDays');
199 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
200 this._previousNumberOfDaysClass = newNumberOfDaysClass;
201 }.observes('numberOfDays').on('init'),
202 _matchingElements: function (className)
204 var element = this.get('element');
207 return $(element.getElementsByClassName(className));
211 App.StartTimeSliderView = Ember.View.extend({
212 templateName: 'start-time-slider',
213 classNames: ['start-time-slider'],
214 startTime: Date.now() - 7 * 24 * 3600 * 1000,
215 oldestStartTime: null,
216 _numberOfDaysView: null,
218 _startTimeInSlider: null,
219 _currentNumberOfDays: null,
220 _MILLISECONDS_PER_DAY: 24 * 3600 * 1000,
222 didInsertElement: function ()
224 this.oldestStartTime = Date.now() - 365 * 24 * 3600 * 1000;
225 this._slider = $(this.get('element')).find('input');
226 this._numberOfDaysView = $(this.get('element')).find('.numberOfDays');
227 this._sliderRangeChanged();
228 this._slider.change(this._sliderMoved.bind(this));
230 _sliderRangeChanged: function ()
232 var minimumNumberOfDays = 1;
233 var maximumNumberOfDays = this._timeInPastToNumberOfDays(this.get('oldestStartTime'));
234 var precision = 1000; // FIXME: Compute this from maximumNumberOfDays.
235 var slider = this._slider;
236 slider.attr('min', Math.floor(Math.log(Math.max(1, minimumNumberOfDays)) * precision) / precision);
237 slider.attr('max', Math.ceil(Math.log(maximumNumberOfDays) * precision) / precision);
238 slider.attr('step', 1 / precision);
239 this._startTimeChanged();
240 }.observes('oldestStartTime'),
241 _sliderMoved: function ()
243 this._currentNumberOfDays = Math.round(Math.exp(this._slider.val()));
244 this._numberOfDaysView.text(this._currentNumberOfDays);
245 this._startTimeInSlider = this._numberOfDaysToTimeInPast(this._currentNumberOfDays);
246 this.set('startTime', this._startTimeInSlider);
248 _startTimeChanged: function ()
250 var startTime = this.get('startTime');
251 if (startTime == this._startTimeSetBySlider)
253 this._currentNumberOfDays = this._timeInPastToNumberOfDays(startTime);
256 this._numberOfDaysView.text(this._currentNumberOfDays);
257 this._slider.val(Math.log(this._currentNumberOfDays));
258 this._startTimeInSlider = startTime;
260 }.observes('startTime').on('init'),
261 _timeInPastToNumberOfDays: function (timeInPast)
263 return Math.max(1, Math.round((Date.now() - timeInPast) / this._MILLISECONDS_PER_DAY));
265 _numberOfDaysToTimeInPast: function (numberOfDays)
267 return Date.now() - numberOfDays * this._MILLISECONDS_PER_DAY;
271 App.Pane = Ember.Object.extend({
277 searchCommit: function (repository, keyword) {
279 var repositoryName = repository.get('id');
280 CommitLogs.fetchForTimeRange(repositoryName, null, null, keyword).then(function (commits) {
281 if (self.isDestroyed || !self.get('chartData') || !commits.length)
283 var currentRuns = self.get('chartData').current.timeSeriesByCommitTime().series();
284 if (!currentRuns.length)
287 var highlightedItems = {};
289 for (var runIndex = 0; runIndex < currentRuns.length && commitIndex < commits.length; runIndex++) {
290 var measurement = currentRuns[runIndex].measurement;
291 var commitTime = measurement.commitTimeForRepository(repositoryName);
294 if (commits[commitIndex].time <= commitTime) {
295 highlightedItems[measurement.id()] = true;
298 } while (commitIndex < commits.length && commits[commitIndex].time <= commitTime);
302 self.set('highlightedItems', highlightedItems);
304 // FIXME: Report errors
305 this.set('highlightedItems', {});
308 _fetch: function () {
309 var platformId = this.get('platformId');
310 var metricId = this.get('metricId');
311 if (!platformId && !metricId) {
312 this.set('empty', true);
315 this.set('empty', false);
316 this.set('platform', null);
317 this.set('chartData', null);
318 this.set('metric', null);
319 this.set('failure', null);
321 if (!this._isValidId(platformId))
322 this.set('failure', platformId ? 'Invalid platform id:' + platformId : 'Platform id was not specified');
323 else if (!this._isValidId(metricId))
324 this.set('failure', metricId ? 'Invalid metric id:' + metricId : 'Metric id was not specified');
328 App.Manifest.fetchRunsWithPlatformAndMetric(this.get('store'), platformId, metricId).then(function (result) {
329 self.set('platform', result.platform);
330 self.set('metric', result.metric);
331 self.set('chartData', result.runs);
332 }, function (result) {
333 if (!result || typeof(result) === "string")
334 self.set('failure', 'Failed to fetch the JSON with an error: ' + result);
335 else if (!result.platform)
336 self.set('failure', 'Could not find the platform "' + platformId + '"');
337 else if (!result.metric)
338 self.set('failure', 'Could not find the metric "' + metricId + '"');
340 self.set('failure', 'An internal error');
343 this.fetchAnalyticRanges();
345 }.observes('platformId', 'metricId').on('init'),
346 fetchAnalyticRanges: function ()
348 var platformId = this.get('platformId');
349 var metricId = this.get('metricId');
352 .find('analysisTask', {platform: platformId, metric: metricId})
353 .then(function (tasks) {
354 self.set('analyticRanges', tasks.filter(function (task) { return task.get('startRun') && task.get('endRun'); }));
357 _isValidId: function (id)
359 if (typeof(id) == "number")
361 if (typeof(id) == "string")
362 return !!id.match(/^[A-Za-z0-9_]+$/);
367 App.encodePrettifiedJSON = function (plain)
369 function numberIfPossible(string) {
370 return string == parseInt(string) ? parseInt(string) : string;
373 function recursivelyConvertNumberIfPossible(input) {
374 if (input instanceof Array) {
375 return input.map(recursivelyConvertNumberIfPossible);
377 return numberIfPossible(input);
380 return JSON.stringify(recursivelyConvertNumberIfPossible(plain))
381 .replace(/\[/g, '(').replace(/\]/g, ')').replace(/\,/g, '-');
384 App.decodePrettifiedJSON = function (encoded)
386 var parsed = encoded.replace(/\(/g, '[').replace(/\)/g, ']').replace(/\-/g, ',');
388 return JSON.parse(parsed);
389 } catch (exception) {
394 App.ChartsController = Ember.Controller.extend({
395 queryParams: ['paneList', 'zoom', 'since'],
397 _currentEncodedPaneList: null,
403 defaultSince: Date.now() - 7 * 24 * 3600 * 1000,
405 addPane: function (pane)
407 this.panes.unshiftObject(pane);
410 removePane: function (pane)
412 this.panes.removeObject(pane);
415 refreshPanes: function()
417 var paneList = this.get('paneList');
418 if (paneList === this._currentEncodedPaneList)
421 var panes = this._parsePaneList(paneList || '[]');
423 console.log('Failed to parse', jsonPaneList, exception);
426 this.set('panes', panes);
427 this._currentEncodedPaneList = paneList;
428 }.observes('paneList').on('init'),
430 refreshZoom: function()
432 var zoom = this.get('zoom');
434 this.set('sharedZoom', null);
438 zoom = zoom.split('-');
439 var selection = new Array(2);
441 selection[0] = new Date(parseFloat(zoom[0]));
442 selection[1] = new Date(parseFloat(zoom[1]));
444 console.log('Failed to parse the zoom', zoom);
446 this.set('sharedZoom', selection);
448 var startTime = this.get('startTime');
449 if (startTime && startTime > selection[0])
450 this.set('startTime', selection[0]);
452 }.observes('zoom').on('init'),
454 _startTimeChanged: function () {
455 this.set('sharedDomain', [this.get('startTime'), this.get('present')]);
456 this._scheduleQueryStringUpdate();
457 }.observes('startTime'),
459 _sinceChanged: function () {
460 var since = parseInt(this.get('since'));
462 since = this.defaultSince;
463 this.set('startTime', new Date(since));
464 }.observes('since').on('init'),
466 _parsePaneList: function (encodedPaneList)
468 var parsedPaneList = App.decodePrettifiedJSON(encodedPaneList);
472 // Don't re-create all panes.
474 return parsedPaneList.map(function (paneInfo) {
475 var timeRange = null;
476 if (paneInfo[3] && paneInfo[3] instanceof Array) {
477 var timeRange = paneInfo[3];
479 timeRange = [new Date(timeRange[0]), new Date(timeRange[1])];
481 console.log("Failed to parse the time range:", timeRange, error);
484 return App.Pane.create({
487 platformId: paneInfo[0],
488 metricId: paneInfo[1],
489 selectedItem: paneInfo[2],
490 timeRange: timeRange,
491 timeRangeIsLocked: !!paneInfo[4],
496 _serializePaneList: function (panes)
500 return App.encodePrettifiedJSON(panes.map(function (pane) {
502 pane.get('platformId'),
503 pane.get('metricId'),
504 pane.get('selectedItem'),
505 pane.get('timeRange') ? pane.get('timeRange').map(function (date) { return date.getTime() }) : null,
506 !!pane.get('timeRangeIsLocked'),
511 _scheduleQueryStringUpdate: function ()
513 Ember.run.debounce(this, '_updateQueryString', 1000);
514 }.observes('sharedZoom', 'panes.@each.platform', 'panes.@each.metric', 'panes.@each.selectedItem',
515 'panes.@each.timeRange', 'panes.@each.timeRangeIsLocked'),
517 _updateQueryString: function ()
519 this._currentEncodedPaneList = this._serializePaneList(this.get('panes'));
520 this.set('paneList', this._currentEncodedPaneList);
522 var zoom = undefined;
523 var sharedZoom = this.get('sharedZoom');
524 if (sharedZoom && !App.domainsAreEqual(sharedZoom, this.get('sharedDomain')))
525 zoom = +sharedZoom[0] + '-' + +sharedZoom[1];
526 this.set('zoom', zoom);
528 if (this.get('startTime') - this.defaultSince)
529 this.set('since', this.get('startTime') - 0);
533 addPaneByMetricAndPlatform: function (param)
535 this.addPane(App.Pane.create({
537 platformId: param.platform.get('id'),
538 metricId: param.metric.get('id'),
539 showingDetails: false
548 App.buildPopup(this.store, 'addPaneByMetricAndPlatform').then(function (platforms) {
549 self.set('platforms', platforms);
554 App.buildPopup = function(store, action, position)
556 return App.Manifest.fetch(store).then(function () {
557 return App.Manifest.get('platforms').map(function (platform) {
558 return App.PlatformProxyForPopup.create({content: platform,
559 action: action, position: position});
564 App.PlatformProxyForPopup = Ember.ObjectProxy.extend({
565 children: function ()
567 var platform = this.content;
568 var containsTest = this.content.containsTest.bind(this.content);
569 var action = this.get('action');
570 var position = this.get('position');
571 return App.Manifest.get('topLevelTests')
572 .filter(containsTest)
573 .map(function (test) {
574 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
576 }.property('App.Manifest.topLevelTests'),
579 App.TestProxyForPopup = Ember.ObjectProxy.extend({
581 children: function ()
583 var platform = this.get('platform');
584 var action = this.get('action');
585 var position = this.get('position');
587 var childTests = this.get('childTests')
588 .filter(function (test) { return platform.containsTest(test); })
589 .map(function (test) {
590 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
593 var metrics = this.get('metrics')
594 .filter(function (metric) { return platform.containsMetric(metric); })
595 .map(function (metric) {
596 var aggregator = metric.get('aggregator');
599 actionArgument: {platform: platform, metric: metric, position:position},
600 label: metric.get('label')
604 if (childTests.length && metrics.length)
605 metrics.push({isSeparator: true});
607 return metrics.concat(childTests);
608 }.property('childTests', 'metrics'),
611 App.domainsAreEqual = function (domain1, domain2) {
612 return (!domain1 && !domain2) || (domain1 && domain2 && !(domain1[0] - domain2[0]) && !(domain1[1] - domain2[1]));
615 App.PaneController = Ember.ObjectController.extend({
617 sharedTime: Ember.computed.alias('parentController.sharedTime'),
618 sharedSelection: Ember.computed.alias('parentController.sharedSelection'),
621 toggleDetails: function()
623 this.toggleProperty('showingDetails');
627 this.parentController.removePane(this.get('model'));
629 toggleBugsPane: function ()
631 if (this.toggleProperty('showingAnalysisPane'))
632 this.set('showingSearchPane', false);
634 createAnalysisTask: function ()
636 var name = this.get('newAnalysisTaskName');
637 var points = this.get('selectedPoints');
638 Ember.assert('The analysis name should not be empty', name);
639 Ember.assert('There should be at least two points in the range', points && points.length >= 2);
641 var newWindow = window.open();
643 App.AnalysisTask.create(name, points[0].measurement, points[points.length - 1].measurement).then(function (data) {
644 // FIXME: Update the UI to show the new analysis task.
645 var url = App.Router.router.generate('analysisTask', data['taskId']);
646 newWindow.location.href = '#' + url;
647 self.get('model').fetchAnalyticRanges();
648 }, function (error) {
650 if (error === 'DuplicateAnalysisTask') {
651 // FIXME: Duplicate this error more gracefully.
656 toggleSearchPane: function ()
658 if (!App.Manifest.repositoriesWithReportedCommits)
660 var model = this.get('model');
661 if (!model.get('commitSearchRepository'))
662 model.set('commitSearchRepository', App.Manifest.repositoriesWithReportedCommits[0]);
663 if (this.toggleProperty('showingSearchPane'))
664 this.set('showingAnalysisPane', false);
666 searchCommit: function () {
667 var model = this.get('model');
668 model.searchCommit(model.get('commitSearchRepository'), model.get('commitSearchKeyword'));
670 zoomed: function (selection)
672 this.set('mainPlotDomain', selection ? selection : this.get('overviewDomain'));
673 Ember.run.debounce(this, 'propagateZoom', 100);
676 _detailsChanged: function ()
678 this.set('showingAnalysisPane', false);
679 }.observes('details'),
680 _overviewSelectionChanged: function ()
682 var overviewSelection = this.get('overviewSelection');
683 this.set('mainPlotDomain', overviewSelection || this.get('overviewDomain'));
684 Ember.run.debounce(this, 'propagateZoom', 100);
685 }.observes('overviewSelection'),
686 _sharedDomainChanged: function ()
688 var newDomain = this.get('parentController').get('sharedDomain');
689 if (App.domainsAreEqual(newDomain, this.get('overviewDomain')))
691 this.set('overviewDomain', newDomain);
692 if (!this.get('overviewSelection'))
693 this.set('mainPlotDomain', newDomain);
694 }.observes('parentController.sharedDomain').on('init'),
695 propagateZoom: function ()
697 this.get('parentController').set('sharedZoom', this.get('mainPlotDomain'));
699 _sharedZoomChanged: function ()
701 var newSelection = this.get('parentController').get('sharedZoom');
702 if (App.domainsAreEqual(newSelection, this.get('mainPlotDomain')))
704 this.set('overviewSelection', newSelection);
705 }.observes('parentController.sharedZoom').on('init'),
706 _updateDetails: function ()
708 var selectedPoints = this.get('selectedPoints');
709 var currentPoint = this.get('currentItem');
710 if (!selectedPoints && !currentPoint) {
711 this.set('details', null);
715 var currentMeasurement;
718 currentMeasurement = currentPoint.measurement;
719 var previousPoint = currentPoint.series.previousPoint(currentPoint);
720 oldMeasurement = previousPoint ? previousPoint.measurement : null;
722 currentMeasurement = selectedPoints[selectedPoints.length - 1].measurement;
723 oldMeasurement = selectedPoints[0].measurement;
726 var formattedRevisions = currentMeasurement.formattedRevisions(oldMeasurement);
727 var revisions = App.Manifest.get('repositories')
728 .filter(function (repository) { return formattedRevisions[repository.get('id')]; })
729 .map(function (repository) {
730 var repositoryName = repository.get('id');
731 var revision = Ember.Object.create(formattedRevisions[repositoryName]);
732 revision['url'] = revision.previousRevision
733 ? repository.urlForRevisionRange(revision.previousRevision, revision.currentRevision)
734 : repository.urlForRevision(revision.currentRevision);
735 revision['name'] = repositoryName;
736 revision['repository'] = repository;
740 var buildNumber = null;
743 buildNumber = currentMeasurement.buildNumber();
744 var builder = App.Manifest.builder(currentMeasurement.builderId());
746 buildURL = builder.urlFromBuildNumber(buildNumber);
749 this.set('details', Ember.Object.create({
750 currentValue: currentMeasurement.mean().toFixed(2),
751 oldValue: oldMeasurement && selectedPoints ? oldMeasurement.mean().toFixed(2) : null,
752 buildNumber: buildNumber,
754 buildTime: currentMeasurement.formattedBuildTime(),
755 revisions: revisions,
757 this._updateCanAnalyze();
758 }.observes('currentItem', 'selectedPoints'),
759 _updateCanAnalyze: function ()
761 var points = this.get('selectedPoints');
762 this.set('cannotAnalyze', !this.get('newAnalysisTaskName') || !points || points.length < 2);
763 }.observes('newAnalysisTaskName'),
767 App.AnalysisRoute = Ember.Route.extend({
769 return this.store.findAll('analysisTask').then(function (tasks) {
770 return Ember.Object.create({'tasks': tasks});
775 App.AnalysisTaskRoute = Ember.Route.extend({
776 model: function (param)
778 return this.store.find('analysisTask', param.taskId);
782 App.AnalysisTaskController = Ember.Controller.extend({
783 label: Ember.computed.alias('model.name'),
784 platform: Ember.computed.alias('model.platform'),
785 metric: Ember.computed.alias('model.metric'),
789 _taskUpdated: function ()
791 var model = this.get('model');
795 var platformId = model.get('platform').get('id');
796 var metricId = model.get('metric').get('id');
797 App.Manifest.fetch(this.store).then(this._fetchedManifest.bind(this));
798 App.Manifest.fetchRunsWithPlatformAndMetric(this.store, platformId, metricId).then(this._fetchedRuns.bind(this));
799 }.observes('model').on('init'),
800 _fetchedManifest: function ()
802 var trackerIdToBugNumber = {};
803 this.get('model').get('bugs').forEach(function (bug) {
804 trackerIdToBugNumber[bug.get('bugTracker').get('id')] = bug.get('number');
807 this.set('bugTrackers', App.Manifest.get('bugTrackers').map(function (bugTracker) {
808 var bugNumber = trackerIdToBugNumber[bugTracker.get('id')];
809 return Ember.ObjectProxy.create({
811 bugNumber: bugNumber,
812 editedBugNumber: bugNumber,
816 _fetchedRuns: function (data)
818 var runs = data.runs;
820 var currentTimeSeries = runs.current.timeSeriesByCommitTime();
821 if (!currentTimeSeries)
822 return; // FIXME: Report an error.
824 var start = currentTimeSeries.findPointByMeasurementId(this.get('model').get('startRun'));
825 var end = currentTimeSeries.findPointByMeasurementId(this.get('model').get('endRun'));
827 return; // FIXME: Report an error.
829 var markedPoints = {};
830 markedPoints[start.measurement.id()] = true;
831 markedPoints[end.measurement.id()] = true;
833 var formatedPoints = currentTimeSeries.seriesBetweenPoints(start, end).map(function (point, index) {
835 id: point.measurement.id(),
836 measurement: point.measurement,
837 label: 'Point ' + (index + 1),
838 value: point.value + (runs.unit ? ' ' + runs.unit : ''),
842 var margin = (end.time - start.time) * 0.1;
843 this.set('chartData', runs);
844 this.set('chartDomain', [start.time - margin, +end.time + margin]);
845 this.set('markedPoints', markedPoints);
846 this.set('analysisPoints', formatedPoints);
848 testSets: function ()
850 var analysisPoints = this.get('analysisPoints');
853 var pointOptions = [{value: ' ', label: 'None'}]
854 .concat(analysisPoints.map(function (point) { return {value: point.id, label: point.label}; }));
856 Ember.Object.create({name: "A", options: pointOptions, selection: pointOptions[1]}),
857 Ember.Object.create({name: "B", options: pointOptions, selection: pointOptions[pointOptions.length - 1]}),
859 }.property('analysisPoints'),
860 _rootChangedForTestSet: function ()
862 var sets = this.get('testSets');
863 var roots = this.get('roots');
867 sets.forEach(function (testSet, setIndex) {
868 var currentSelection = testSet.get('selection');
869 if (currentSelection == testSet.get('previousSelection'))
871 testSet.set('previousSelection', currentSelection);
872 var pointIndex = testSet.get('options').indexOf(currentSelection);
874 roots.forEach(function (root) {
875 var set = root.sets[setIndex];
876 set.set('selection', set.revisions[pointIndex]);
880 }.observes('testSets.@each.selection'),
883 var analysisPoints = this.get('analysisPoints');
886 var repositoryToRevisions = {};
887 analysisPoints.forEach(function (point, pointIndex) {
888 var revisions = point.measurement.formattedRevisions();
889 for (var repositoryName in revisions) {
890 if (!repositoryToRevisions[repositoryName])
891 repositoryToRevisions[repositoryName] = new Array(analysisPoints.length);
892 var revision = revisions[repositoryName];
893 repositoryToRevisions[repositoryName][pointIndex] = {
894 label: point.label + ': ' + revision.label,
895 value: revision.currentRevision,
901 for (var repositoryName in repositoryToRevisions) {
902 var revisions = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryName]);
903 roots.push(Ember.Object.create({
904 name: repositoryName,
906 Ember.Object.create({name: 'A[' + repositoryName + ']',
907 revisions: revisions,
908 selection: revisions[1]}),
909 Ember.Object.create({name: 'B[' + repositoryName + ']',
910 revisions: revisions,
911 selection: revisions[revisions.length - 1]}),
916 }.property('analysisPoints'),
918 associateBug: function (bugTracker, bugNumber)
920 var model = this.get('model');
921 this.store.createRecord('bug',
922 {task: this.get('model'), bugTracker: bugTracker.get('content'), number: bugNumber}).save().then(function () {
923 // FIXME: Should we notify the user?
924 }, function (error) {
925 alert('Failed to associate the bug: ' + error);