From 3f84b3fe442b7ee3d99333520dc101cad00d7f51 Mon Sep 17 00:00:00 2001 From: William Lachance Date: Thu, 19 May 2016 16:27:53 -0400 Subject: [PATCH] Bug 1260791 - UI support for manually created performance alerts --- ui/js/controllers/perf/graphs.js | 27 ++++++++++++++++++++++++--- ui/js/models/perf/alerts.js | 16 +++++++++++++++- ui/js/perf.js | 1 + ui/partials/perf/alertsctrl.html | 10 ++++++++-- ui/partials/perf/graphsctrl.html | 15 ++++++++++++--- 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/ui/js/controllers/perf/graphs.js b/ui/js/controllers/perf/graphs.js index 3034b04ea15..dee7018ae49 100644 --- a/ui/js/controllers/perf/graphs.js +++ b/ui/js/controllers/perf/graphs.js @@ -21,6 +21,25 @@ perf.controller('GraphsCtrl', [ $scope.showToolTipTimeout = null; $scope.seriesList = []; + $scope.createAlert = function(dataPoint) { + $scope.creatingAlert = true; + PhAlerts.createAlert(dataPoint).then(function(alertSummaryId) { + PhAlerts.getAlertSummaries({ + seriesSignature: dataPoint.series.seriesSignature, + repository: dataPoint.project.id + }).then(function(alertSummaryData) { + $scope.creatingAlert = false; + + var alertSummary = _.find(alertSummaryData.results, + { id: alertSummaryId }); + $scope.tooltipContent.alertSummary = alertSummary; + + dataPoint.series.relatedAlertSummaries = alertSummaryData.results; + plotGraph(); + }); + }); + }; + function getSeriesDataPoint(flotItem) { // gets universal elements of a series given a flot item @@ -107,9 +126,10 @@ perf.controller('GraphsCtrl', [ project: _.findWhere($rootScope.repos, { name: phSeries.projectName }), revisionUrl: thServiceDomain + '#/jobs?repo=' + phSeries.projectName, + prevResultSetId: prevResultSetId, + resultSetId: dataPoint.resultSetId, jobId: phSeries.flotSeries.jobIdData[index], - test: phSeries.name, - platform: phSeries.platform, + series: phSeries, value: Math.round(v*1000)/1000, deltaValue: dv.toFixed(1), deltaPercentValue: (100 * dvp).toFixed(1), @@ -207,7 +227,8 @@ perf.controller('GraphsCtrl', [ // if we have a highlighted revision(s), highlight all points that // correspond to that $scope.seriesList.forEach(function(series, i) { - if (series.visible && series.highlightedPoints.length) { + if (series.visible && series.highlightedPoints && + series.highlightedPoints.length) { _.forEach(series.highlightedPoints, function(highlightedPoint) { $scope.plot.highlight(i, highlightedPoint); }); diff --git a/ui/js/models/perf/alerts.js b/ui/js/models/perf/alerts.js index 4c37cec65cf..46cb32076a0 100644 --- a/ui/js/models/perf/alerts.js +++ b/ui/js/models/perf/alerts.js @@ -208,7 +208,21 @@ treeherder.factory('PhAlerts', [ }); }); }, - changeAlertSummaryStatus: function(alertSummaryId, open) { + createAlert: function(data) { + return $http.post(thServiceDomain + '/api/performance/alertsummary/', { + repository_id: data.project.id, + framework_id: data.series.frameworkId, + result_set_id: data.resultSetId, + prev_result_set_id: data.prevResultSetId + }).then(function(response) { + var newAlertSummaryId = response.data.alert_summary_id; + return $http.post(thServiceDomain + '/api/performance/alert/', { + summary_id: newAlertSummaryId, + signature_id: data.series.id + }).then(function() { + return newAlertSummaryId; + }); + }); } }; }]); diff --git a/ui/js/perf.js b/ui/js/perf.js index fd855ee3102..013f45c47e3 100644 --- a/ui/js/perf.js +++ b/ui/js/perf.js @@ -43,6 +43,7 @@ treeherder.factory('PhSeries', ['$http', 'thServiceDomain', 'ThOptionCollectionM var options = _getSeriesOptions(signatureProps, optionCollectionMap); return { + id: signatureProps['id'], name: _getSeriesName(signatureProps, optionCollectionMap), testName: _getTestName(signatureProps), // unadorned with platform/option info suite: signatureProps['suite'], diff --git a/ui/partials/perf/alertsctrl.html b/ui/partials/perf/alertsctrl.html index 26f23fdf098..ff4d5070b78 100644 --- a/ui/partials/perf/alertsctrl.html +++ b/ui/partials/perf/alertsctrl.html @@ -162,10 +162,16 @@ - - {{alert.t_value}} + + {{alert.t_value}} + + + + diff --git a/ui/partials/perf/graphsctrl.html b/ui/partials/perf/graphsctrl.html index 8c3be7677fb..915876a3c37 100644 --- a/ui/partials/perf/graphsctrl.html +++ b/ui/partials/perf/graphsctrl.html @@ -56,9 +56,9 @@
-

+

()

-

+

@@ -75,11 +75,20 @@ compare)

-

+

Alert #{{tooltipContent.alertSummary.id}} ({{tooltipContent.alertSummary.getStatusText()}}) +

+

+ + No alert (create) + + + Creating alert... + +

Revision info unavailable Loading revision...