From f52b39f483e28f2bb238dea03b45e8ea874894b3 Mon Sep 17 00:00:00 2001 From: apoorvad Date: Fri, 13 Nov 2015 10:09:44 -0800 Subject: [PATCH] Add highlight Jenkins +1 functionality Currently ciwatch highlights Jenkins -1 votes, but many third party CIs pick up Gerrit events only when Jenkins has voted +1. Hence it is important to highlight vendor CI failures when Jenkins has verified the change set. Closes-Bug: #1516110 Change-Id: I5635d344404c21206d7cae049f81fb1f2067ec09 --- ciwatch/events.py | 4 ++-- ciwatch/static/verified.js | 24 +++++++++++++++++------- ciwatch/templates/project.html.jinja | 7 ++++--- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ciwatch/events.py b/ciwatch/events.py index ec1f3be..a748cd1 100644 --- a/ciwatch/events.py +++ b/ciwatch/events.py @@ -48,7 +48,7 @@ def _process_event(event): def _is_ci_user(name): - return 'CI' in name or 'Jenkins' in name + return 'CI' in name or 'Jenkins' in name or 'Bot' in name # Check if this is a third party CI event @@ -139,7 +139,7 @@ def add_event_to_db(event, commit_=True): trusted = (event["author"]["username"] == "jenkins") if trusted and "approvals" in event: - if event["approvals"][0]["value"] in ("+1", "+2"): + if event["approvals"][0]["value"] in ("1", "2"): patch_set.verified = True elif event["approvals"][0]["value"] in ("-1", "-2"): patch_set.verified = False diff --git a/ciwatch/static/verified.js b/ciwatch/static/verified.js index ee3eaf9..c5e2486 100644 --- a/ciwatch/static/verified.js +++ b/ciwatch/static/verified.js @@ -13,21 +13,31 @@ * under the License. */ -var toggle1 = function () { - $(".verified-1").css("background-color", "#FAA"); - $(this).one("click", toggle2); +var toggle_verified_plus = function () { + var color = "#BFA"; + if ($(this).hasClass("active")){ + color = ""; + } + $(".verified1").css("background-color", color); } -var toggle2 = function () { - $(".verified-1").css("background-color", ""); - $(this).one("click", toggle1); +var toggle_verified_minus = function () { + var color = "#FAA"; + if ($(this).hasClass("active")){ + color = ""; + } + $(".verified-1").css("background-color", color); } + $(document).ready(function () { $("colgroup").each(function (i, elem) { if ($(elem).hasClass("verified-1")) { $("#results").find("td").filter(":nth-child(" + (i + 1) + ")").addClass("verified-1"); + } else if ($(elem).hasClass("verified1")) { + $("#results").find("td").filter(":nth-child(" + (i + 1) + ")").addClass("verified1"); } }); - $("#verified-1-button").one("click", toggle1); + $("#verified1-button").on("click", toggle_verified_plus); + $("#verified-1-button").on("click", toggle_verified_minus); }); diff --git a/ciwatch/templates/project.html.jinja b/ciwatch/templates/project.html.jinja index 911b6c2..96a0cc6 100644 --- a/ciwatch/templates/project.html.jinja +++ b/ciwatch/templates/project.html.jinja @@ -39,16 +39,17 @@ + -
-
{% for patch_set in patch_sets %} - {% if patch_set.verified is not none and not patch_set.verfied %} + {% if patch_set.verified %} + + {% elif patch_set.verified is not none and not patch_set.verfied %} {% else %}