WH.checkAll = function()

in src/main/resources/buildServerResources/gh-webhook.js [326:384]


    WH.checkAll = function (element, projectId, recursive) {
        if (recursive === undefined) recursive = false;
        var parameters = {
            'action': 'check-all',
            'recursive': recursive
        };
        if (projectId) {
            parameters["projectId"] = projectId
        }
        BS.ProgressPopup.showProgress(element, "Rechecking all webhooks", {shift: {x: -65, y: 20}, zIndex: 100});
        BS.ajaxRequest(window.base_uri + WH.WEBHOOKS_CONTROLLER_PATH, {
            method: "post",
            parameters: parameters,
            onComplete: function (transport) {
                BS.ProgressPopup.hidePopup(0, true);
                if (transport.status != 200) {
                    BS.Log.error("Check all responded with " + transport.status);
                    return
                }
                var json = transport.responseJSON;
                if (json['error']) {
                    BS.Log.error("Sad :( Something went wrong: " + json['error']);
                } else if (json['data']) {
                    const table = $j('#webHooksTable');
                    var data = json['data'];
                    for (var i = 0; i < data.length; i++) {
                        var r = data[i];
                        const repo = r['repository'];
                        WH.data[repo] = r;
                        if (r['user_action_required']) {
                            WH.data[repo].warning = r['error'];
                            WH.forcePopup[getServerUrl(repo)] = true;
                            BS.Log.info("Some user action required to check '" + repo + "' repository.");
                            // TODO: Add link to manually check webhook (popup required)
                            // TODO: Prevent automatic updates, that would hide error (if any)
                            WH.data[repo] = r;
                            WH.data[repo]['manual'] = true;
                            WH.forcePopup[WH.getServerUrl(repo)] = true;
                        } else if (r['result']) {
                            // Operation succeed or failed, at least there's some connections/tokens
                            BS.Log.info("Action either succeed of failed for '" + repo + "'.");
                            WH.data[repo] = r;
                            // TODO: Prevent automatic updates, that would hide error (if any)
                            WH.data[repo]['manual'] = true;
                            // TODO: Do something
                        } else {
                            BS.Log.warn("Action done nothing to '" + repo + "'. Most probably there not connection for that server.");
                            // TODO: Do something
                        }
                        renderOne(r, table)
                    }
                    // TODO: Incremental update
                } else {
                    BS.Log.error("Unexpected response: " + json.toString())
                }
                WH.refreshReports();
            }
        })
    };