function showChainCurrentStatusData()

in ignite-tc-helper-web/src/main/webapp/js/testfails-2.2.js [145:378]


function showChainCurrentStatusData(chain, settings) {
    if(!isDefinedAndFilled(chain))
        return;

    if(isDefinedAndFilled(chain.buildNotFound) && chain.buildNotFound ) {
        return "<tr><td><b>Error: Build not found for branch [" + chain.branchName + "]</b>" +
            "<br><br><span style='color:grey; font-size:12px;'>Perhaps, more than 2 weeks have passed since the last build " +
            "run. <br>There is no data on the TC server</span></td></tr>";
    }

    var res = "";

    res += "<table style='width: 100%;' border='0px'>";
    res += "<tr bgcolor='#F5F5FF'><td colspan='3' width='75%'>";
    res += "<table style='width: 40%'>";
    res += "<tr><td><b> Server: </b></td><td>[" + chain.serverCode +"] TC: ["+  chain.tcServerCode + "]</td></tr>";

    if (isDefinedAndFilled(chain.prNum)) {
        res += "<tr><td><b> PR: </b></td><td>";

        if (isDefinedAndFilled(chain.webToPr))
            res += "<a href='" + chain.webToPr + "'>[#" + chain.prNum + "]</a>";
        else
            res += "[#" + chain.prNum + "]";

        res += "</td></tr>";
    }

    if (isDefinedAndFilled(chain.webToTicket) && isDefinedAndFilled(chain.ticketFullName)) {
        res += "<tr><td><b> Ticket: </b></td><td>";
        res += "<a href='" + chain.webToTicket + "'>[" + chain.ticketFullName + "]</a>";
        res += "</td></tr>";
    }

    let parentSuitId;

    if (isDefinedAndFilled(findGetParameter("suiteId")))
        parentSuitId = findGetParameter("suiteId");
    else if (isDefinedAndFilled(chain.suiteId))
        parentSuitId = chain.suiteId;

    if (isDefinedAndFilled(parentSuitId) || isDefinedAndFilled(chain.webToHist)) {
        res += "<tr><td>";
        if (isDefinedAndFilled(parentSuitId)) {
            res += "<b> Suite: </b></td>" +
                "<td>[" + parentSuitId + "] ";
        }
        if (isDefinedAndFilled(chain.webToHist)) {
            res += " <a href='" + chain.webToHist + "' title='Chain history'>[TC history]</a>";
        }
        if (isDefinedAndFilled(chain.webToBuild)) {
            res += " <a href='" + chain.webToBuild + "' title='Build without applying re-runs'>[Build]</a>";
        }
        res += "</td></tr>";
    }

    res += "</table>";
    res += "</br>";

    if (isDefinedAndFilled(chain.chainName)) {
        res += chain.chainName + " ";
    }

    res += "<b>Chain result: </b>";

    if (isDefinedAndFilled(chain.failedToFinish) && isDefinedAndFilled(chain.failedTests))
        res += chain.failedToFinish + " suites and " + chain.failedTests + " tests failed";
    else
        res += "empty";

    res += " ";

    var moreInfoTxt = "";

    var cntFailed = 0;
    var suitesFailedList = "";
    for (var i = 0; i < chain.suites.length; i++) {
        var suite = chain.suites[i];

        if (!isDefinedAndFilled(suite.suiteId))
            continue;

        //may check failure here in case mode show all

        if (suitesFailedList.length !== 0)
            suitesFailedList += ",";

        suitesFailedList += suite.suiteId;
        cntFailed++;
    }

    //chain.tcServerCode can represent reference to a service generated using alias.
    let srvCodeForTriggering = chain.serverCode;

    if (suitesFailedList.length !== 0 && isDefinedAndFilled(srvCodeForTriggering) && isDefinedAndFilled(chain.branchName)) {
        moreInfoTxt += "Trigger failed " + cntFailed + " builds";
        moreInfoTxt += " <a href='javascript:void(0);' ";
        moreInfoTxt += " onClick='triggerBuilds(\"" + srvCodeForTriggering + "\", \"" + parentSuitId + "\", " +
            "\"" + suitesFailedList + "\", \"" + chain.branchName + "\", false, false, null, \"" + chain.prNum + "\", null, false)' ";
        moreInfoTxt += " title='trigger builds'>in queue</a> ";

        moreInfoTxt += " <a href='javascript:void(0);' ";
        moreInfoTxt += " onClick='triggerBuilds(\"" + srvCodeForTriggering + "\", \"" + parentSuitId + "\", " +
            "\"" + suitesFailedList + "\", \"" + chain.branchName + "\", true, false, null, \"" + chain.prNum + "\", null, false)' ";
        moreInfoTxt += " title='trigger builds'>on top</a><br>";
    }

    moreInfoTxt += "Duration: " + chain.durationPrintable + " " +
        "(Net Time: " + chain.durationNetTimePrintable + "," +
        " Tests: " + chain.testsDurationPrintable + "," +
        " Src. Update: " + chain.sourceUpdateDurationPrintable + "," +
        " Artifacts Publishing: " + chain.artifcactPublishingDurationPrintable + "," +
        " Dependecies Resolving: " + chain.dependeciesResolvingDurationPrintable + "," +
        " Timeouts: " + chain.lostInTimeouts + ")<br>";

    if(isDefinedAndFilled(chain.totalTests))
        moreInfoTxt += " <span title='Not muted and not ignored tests'>Total tests: " + chain.totalTests + "</span>";

    if(isDefinedAndFilled(chain.trustedTests))
        moreInfoTxt += " <span title='Tests which not filtered out because of flakyness'>Trusted tests: " + chain.trustedTests + "</span>";

    moreInfoTxt += "<br>";

    if (isDefinedAndFilled(chain.topLongRunning) && chain.topLongRunning.length > 0) {
        moreInfoTxt += "Top long running:<br>";

        moreInfoTxt += "<table>";
        for (var j = 0; j < chain.topLongRunning.length; j++) {
            moreInfoTxt += showTestFailData(chain.topLongRunning[j], false, settings);
        }
        moreInfoTxt += "</table>";
    }


    if (isDefinedAndFilled(chain.logConsumers) && chain.logConsumers.length > 0) {
        moreInfoTxt += "Top Log Consumers:<br>";

        moreInfoTxt += "<table>";
        for (var k = 0; k < chain.logConsumers.length; k++) {
            moreInfoTxt += showTestFailData(chain.logConsumers[k], false, settings);
        }
        moreInfoTxt += "</table>";
    }

    if(!isDefinedAndFilled(findGetParameter("reportMode"))) {
        res += "<span class='container'>";
        res += " <a href='javascript:void(0);' class='header'>" + more + "</a>";
        res += "<div class='content'>" + moreInfoTxt + "</div></span>";
    }

    res += "</td><td>";

    // if (settings.isGithubAvailable()) {
    //     g_srv_to_notify_git = server;
    //     res += "<button onclick='notifyGit()'>Update PR status</button>";
    // }

    let baseBranchForTc = chain.baseBranchForTc;
    if (settings.isJiraAvailable() && isDefinedAndFilled(srvCodeForTriggering)) {
        res += "<button onclick='commentJira(\"" + srvCodeForTriggering + "\", " +
            "\"" + chain.branchName + "\", " +
            "\"" + parentSuitId + "\", " +
            "\"\", " + // ticket id
            "\"" + baseBranchForTc + "\")'>Comment JIRA</button><br>";

        var blockersList = "";

        for (var l = 0; l < chain.suites.length; l++) {
            var suite0 = chain.suites[l];

            var suiteOrNull = filterPossibleBlocker(suite0);

            if (suiteOrNull != null) {
                if (blockersList.length !== 0)
                    blockersList += ",";

                blockersList += suite0.suiteId;
            }
        }

        res += "<label for='cleanRebuild'><input id='cleanRebuild' type='checkbox'>Delete all files in checkout directory before each snapshot dependency build</label><br>"

        res += "<button onclick='triggerBuilds(" +
            "\"" + srvCodeForTriggering + "\", " +
            "\"" + parentSuitId + "\", " +
            "\"" + blockersList + "\", " +
            "\"" + chain.branchName + "\", " +
            "false, " + //top
            "false, " + //observe
            "null, " + // ticketId
            "\"" + + chain.prNum + "\", " +
            "\"" + baseBranchForTc + "\", " +
            "document.getElementById(\"cleanRebuild\").checked" +
            ")'> " +
            "Re-run possible blockers</button><br>";

        res += "<button onclick='triggerBuilds(" +
            "\"" + srvCodeForTriggering + "\", " +
            "\"" + parentSuitId + "\", " +
            "\"" + blockersList + "\", " +
            "\"" + chain.branchName + "\", " +
            "true, " + //top
            "false, " + //observe
            "null, " + // ticketId
            "\"" + chain.prNum + "\", " + //prNum
            "\"" + baseBranchForTc + "\", " +
            "document.getElementById(\"cleanRebuild\").checked" +
            ")'> " +
            "Re-run possible blockers (top queue)</button><br>";
    }

    if (isDefinedAndFilled(baseBranchForTc)) {
        // if (settings.isGithubAvailable())
        //     res+="<br>";

        if (settings.isJiraAvailable())
            res += "<br>";

        res += "Base branch";
        res += ": " + baseBranchForTc.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    }

    res += "&nbsp;</td></tr>";

    res += addBlockersData(chain, settings);

    for (var m = 0; m < chain.suites.length; m++) {
        var subSuite = chain.suites[m];

        res += showSuiteData(subSuite, settings, chain.prNum);
    }

    return res;
}