This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-9800
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/ignite-9800 by this push:
     new 232a54e  IGNITE-9800: skeleton of page for PRs
232a54e is described below

commit 232a54e22f33a4bd9c434772c4895a19e760f0ff
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Fri Oct 5 15:18:12 2018 +0300

    IGNITE-9800: skeleton of page for PRs
---
 ignite-tc-helper-web/src/main/webapp/guard.html |  75 ++++++++
 ignite-tc-helper-web/src/main/webapp/prs.html   | 238 ++++++++++++++++++++++++
 ignite-tc-helper-web/src/main/webapp/user.html  |   6 +-
 3 files changed, 317 insertions(+), 2 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/webapp/guard.html 
b/ignite-tc-helper-web/src/main/webapp/guard.html
new file mode 100644
index 0000000..cf9b78e
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/webapp/guard.html
@@ -0,0 +1,75 @@
+<html>
+<head>
+    <title>Ignite Teamcity Helper - Tracked Branches status</title>
+    <link rel="icon" href="img/leaf-icon-png-7066.png">
+
+    <link rel="stylesheet" 
href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css";>
+
+    <link rel="stylesheet" href="css/style-1.5.css">
+
+    <script src="https://code.jquery.com/jquery-1.12.4.js";></script>
+    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js";></script>
+
+    <script src="js/common-1.6.js"></script>
+    <script>
+$(document).ready(function() {
+    $.getScript("js/common-1.6.js", function(data, textStatus, jqxhr){ });
+
+    $( document ).tooltip();
+    loadData();
+});
+
+function loadData() {
+    $("#loadStatus").html("<img 
src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px 
height=20px> Please wait");
+
+    $.ajax({
+        url: "rest/branches/version",
+        success: showVersionInfo,
+        error: showErrInLoadStatus
+    });
+
+    $.ajax({
+        url: "rest/branches/getIds",
+        success: function(result) {
+            $("#loadStatus").html("");
+            showTrackedBranchesLinks(result);
+        },
+        error: showErrInLoadStatus
+    });
+
+
+}
+
+function showTrackedBranchesLinks(result) {
+    var res = "";
+    for (var i = 0; i < result.length; i++) {
+        var id = result[i];
+       //  res += "<div class='formgroup'>";
+        res += id + ":";
+        res += "<a href='current.html?branch=" + id + "'><button>Latest (" + 
id + ")</button></a>";
+        res += " &nbsp;&nbsp;<a href='current.html?branch=" + id + 
"&checkAllLogs=true' title='With logs processing'><button>Latest (" + id + " + 
logs)</button></a>";
+        res += " &nbsp;&nbsp;<a href='all.html?branch=" + id + "'><button 
title='Failures from last 10 runs merged'>History (" + id + ")</button></a>";
+        //  res += "</div>";
+        res += "<br>";
+    }
+
+    res += "</table>";
+
+
+    $("#branchesStatus").html(res);
+}
+
+</script>
+</head>
+<body>
+<div class="formgroup">
+    Monitoring. Current Failed Tests: <br>
+    <div id="branchesStatus"></div>
+</div>
+<br>
+
+<div id="loadStatus"></div>
+<div id="version"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/ignite-tc-helper-web/src/main/webapp/prs.html 
b/ignite-tc-helper-web/src/main/webapp/prs.html
new file mode 100644
index 0000000..327296c
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/webapp/prs.html
@@ -0,0 +1,238 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Services</title>
+    <link rel="icon" href="img/leaf-icon-png-7066.png">
+
+    <link rel="stylesheet" 
href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css";>
+    <link rel="stylesheet" 
href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css";>
+
+    <link rel="stylesheet" href="css/style-1.5.css">
+
+    <script src="https://code.jquery.com/jquery-1.12.4.js";></script>
+    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js";></script>
+    <script 
src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js";></script>
+    <script 
src="https://cdn.datatables.net/1.10.16/js/dataTables.jqueryui.js";></script>
+
+    <script src="js/common-1.6.js"></script>
+    <script src="js/testfails-2.1.js"></script>
+
+    <style>
+
+    </style>
+    <script>
+$(document).ready(function() {
+    $.getScript("js/common-1.6.js", function(data, textStatus, jqxhr){ });
+
+    $( document ).tooltip();
+    $( "#accordion" ).accordion({
+        heightStyle: "fill"
+    });
+    loadData();
+});
+
+function loadData() {
+    $("#loadStatus").html("<img 
src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px 
height=20px> Please wait");
+
+    $.ajax({
+        url: "rest/branches/version",
+        success: showVersionInfo,
+        error: showErrInLoadStatus
+    });
+
+    $.ajax({
+        url: "rest/branches/suites",
+        success: function(result) {
+            $("#loadStatus").html("");
+            showSuitesForTeamCityRunData(result);
+            showFormAndSuitesForPrCheck(result);
+            tryToFillAutocompleteLists();
+            showCommentJiraForm(result);
+        },
+        error: showErrInLoadStatus
+    });
+
+    $.ajax({
+        url: "rest/branches/getServerIds",
+        success: setupAutocompleteList
+    });
+}
+
+function showSuitesForTeamCityRunData(result) {
+    var res = "";
+
+    for (var i = 0; i < result.length; i++) {
+        var chainAtServer = result[i];
+
+        // TODO multiple servers
+        if (chainAtServer.serverId != "apache")
+            continue;
+
+        res += "Server: <input type='text' name='serverId' value='" + 
chainAtServer.serverId + "' readonly>";
+        res += "Chain: <input type='text' name='suiteId' value='" + 
chainAtServer.suiteId + "' readonly>";
+        res += "Branch: <input type='text' name='branchForTc' 
class='branchForTc" + chainAtServer.serverId +
+            "' required> ";
+        res += "Ticket: <input type='text' name='ticketId'>";
+        res += "<button name='jira' type='button' 
onclick='trigBuild(\"tests\")'>Start tests</button>";
+        res += "<button name='jira' onclick='trigBuild(\"tests+jira\")'>Start 
tests and comment JIRA ticket on ready</button>";
+        //res += "<button name='git' onclick='trigBuild(\"tests+jira\")'>Start 
tests and comment GitHub PR on ready</button>";
+        /*
+        res+="Server: <input type='text' name='serverId' value=" + serverId +" 
readonly>" ;
+        res+="Pull Request #<input type='text' name='prId' onkeypress='return 
trigBuild(event)'> ";
+        res+="<button onclick='trigBuild()'>Run All</button><br>";
+        */
+    }
+
+    $("#suitesForRunAll").html(res);
+}
+
+/**
+ * This form allows user to startIgnite TeamCity Run All build.
+ */
+function showCommentJiraForm(result) {
+    var res = "";
+
+    for (var i = 0; i < result.length; i++) {
+        var chainAtServer = result[i];
+
+        // TODO multiple servers
+        if (chainAtServer.serverId != "apache")
+            continue;
+
+        res += "Server: <input type='text' name='serverId' value=" + 
chainAtServer.serverId +" readonly>" ;
+        res += "Chain: <input type='text' name='suiteId' value='" + 
chainAtServer.suiteId + "' readonly>";
+        res += "Branch: <input type='text' name='branchForTc' 
class='branchForTc" + chainAtServer.serverId +
+            "' required> ";
+        res += "Ticket: <input type='text' name='ticketId'> ";
+        res += "<button name='action' onclick='notifyJira()'>Notify</button>";
+    }
+
+    $("#notifyJira").html(res);
+}
+
+/**
+ * Start Run All build on TeamCity and comment in JIRA ticket when build will 
be finished.
+ */
+function trigBuild(trigCase) {
+    var fields = document.getElementById("suitesForRunAll").children;
+
+    var srvId = fields.namedItem("serverId").value;
+    var suiteId = fields.namedItem("suiteId").value;
+    var branchName = branchForTc(fields.namedItem("branchForTc").value);
+    var ticketId = jiraTicketNumber(fields.namedItem("ticketId").value);
+
+    triggerBuild(srvId, suiteId, branchName, false, trigCase !== "tests", 
ticketId)
+}
+
+/**
+ * Comment in JIRA ticket with results for the given PR.
+ */
+function notifyJira() {
+    var fields = document.getElementById("notifyJira").children;
+
+    var srvId = fields.namedItem("serverId").value;
+    var suiteId = fields.namedItem("suiteId").value;
+    var branchName = branchForTc(fields.namedItem("branchForTc").value);
+    var ticketId = jiraTicketNumber(fields.namedItem("ticketId").value);
+
+    commentJira(srvId, suiteId, branchName, ticketId)
+}
+
+/**
+ * Converts PR number to branch for TeamCity.
+ *
+ * @param pr - Pull Request number.
+ * @returns {String} Branch for TeamCity.
+ */
+function branchForTc(pr) {
+    var regExpr = /(\d*)/i;
+
+    if (regExpr.exec(pr)[0] === pr)
+        return "pull/" + regExpr.exec(pr)[0] + "/head";
+
+    return pr;
+}
+
+/**
+ * Converts JIRA ticket full name to the tickets number.
+ *
+ * @param ticket - JIRA ticket.
+ * @returns {string} JIRA ticket number.
+ */
+function jiraTicketNumber(ticket) {
+    var regExpr = /(ignite-)?(\d*)/i;
+
+    return regExpr.exec(ticket)[2];
+}
+
+function showFormAndSuitesForPrCheck(result) {
+    var res = "";
+
+    for (var i = 0; i < result.length; i++) {
+        var chainAtServer = result[i];
+
+        res += "<form action='pr.html'>";
+        res += "Server: <input type='text' name='serverId' value=" + 
chainAtServer.serverId + " readonly>";
+        res += "Chain: <input type='text' name='suiteId' value=" + 
chainAtServer.suiteId + ">";
+        res += "Base branch: <input class='branchForTc" + 
chainAtServer.serverId +
+            "' type='text' name='baseBranchForTc'  title='Etalon branch to 
take base data from, e.g refs/heads/master'> ";
+        res += "<b>Branch:</b> <input class='branchForTc" + 
chainAtServer.serverId +
+            "' type='text' name='branchForTc' title='Tested branch, e.g. 
pull/4790/head or ignite-9349' required> ";
+        res += "<input type='submit' name='action' value='Latest' title='Show 
latest runs'>";
+        // res+="<input type='submit' name='action' value='Chain'>";
+        res += "<input type='submit' name='action' value='History' title='Show 
last 10 runs merged'>";
+        res += "</form>";
+    }
+
+    $("#suitesForPrCheck").html(res);
+}
+    </script>
+</head>
+<body>
+<div id="loadStatus"></div>
+
+
+<div id="accordion" style="height: 500px">
+    <h3>Select PR</h3>
+    <div>
+
+
+    </div>
+
+    <h3>I can enter branch data</h3>
+    <div>
+        <div class="formgroup">
+            Trigger new TeamCity Run All for a PR/Branch: <br>
+            <div id="suitesForRunAll"></div>
+        </div>
+        <br>
+
+        <div class="formgroup">
+            Notify JIRA (save TC Bot visa to a ticket comment): <br>
+            <div id="notifyJira"></div>
+        </div>
+        <br>
+
+        <br>Check results of branch/PR TeamCity Run All:
+        <div id="suitesForPrCheck"></div>
+
+
+        <!--Notify GitHub:   <br>
+        <div id="notifyGitHub">
+            <form>
+                Server: <input type='text' name='serverId' value="apache" 
readonly>
+                Branch: <input type='text' name='branchForTc' required>
+                <input type='submit' name='action' value='Notify'>
+            </form>
+        </div>
+        <br>-->
+    </div>
+</div>
+
+
+<div id="version"></div>
+
+<div style="visibility:hidden"><div id="triggerConfirm" title="Trigger 
Confirmation"></div><div id="triggerDialog" title="Trigger Result"></div></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/ignite-tc-helper-web/src/main/webapp/user.html 
b/ignite-tc-helper-web/src/main/webapp/user.html
index 5e8795d..4ce23cd 100644
--- a/ignite-tc-helper-web/src/main/webapp/user.html
+++ b/ignite-tc-helper-web/src/main/webapp/user.html
@@ -103,12 +103,14 @@ function addServiceCreds() {
         url: url,
         data: $("#addCred").serialize(),
         success: function(data) {
+            let addCredsStatus = $("#addCredsStatus");
+
             if(isDefinedAndFilled(data.result) && data.result.length>0) {
-                $("#addCredsStatus").html('Unable to add credentials [' + 
data.result + "]");
+                addCredsStatus.html('Unable to add credentials [' + 
data.result + "]");
 
                 return;
             }
-            $("#addCredsStatus").html("");
+            addCredsStatus.html("");
 
             dialog.dialog("close");
 

Reply via email to