How to use the @hpcc-js/comms.Connection function in @hpcc-js/comms

To help you get started, we’ve selected a few @hpcc-js/comms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcc-systems / Visualization / demos / dashy / src / index.ts View on Github external
logger.debug(`WU Params:  ${_url.params()}`);
            const baseUrl = `${_url.param("Protocol")}://${_url.param("Hostname")}:${_url.param("Port")}`;
            logger.debug(baseUrl);
            const result = new Result({ baseUrl }, _url.param("Wuid"), _url.param("ResultName"));
            result.fetchRows().then(async (response: any[]) => {
                this.importDDL(response[0][_url.param("ResultName")], baseUrl, _url.param("Wuid"), layoutJson);
            });
        } else if (_url.param("QueryID")) {
            // http://10.241.100.159:8002/WsEcl/submit/query/roxie/prichajx_govottocustomerstats.ins109_service_1/json
            // ?Protocol=http&Hostname=10.241.100.159&Port=8002&QuerySet=roxie&QueryID=prichajx_govottocustomerstats.ins109_service_1
            logger.debug(`Roxie Params:  ${JSON.stringify(_url.params())}`);
            const baseUrl = `${_url.param("Protocol") || "http"}://${_url.param("Hostname")}:${_url.param("Port")}`;
            const action = `WsEcl/submit/query/${_url.param("QuerySet")}/${_url.param("QueryID")}/json`;
            const responseID = `${_url.param("QueryID")}Response`;
            logger.debug(action);
            const connection = new Connection({ baseUrl });
            connection.send(action, {}).then(response => {
                if (exists("Results.HIPIE_DDL.Row", response[responseID]) && response[responseID].Results.HIPIE_DDL.Row.length) {
                    this.importDDL(response[responseID].Results.HIPIE_DDL.Row[0].HIPIE_DDL, baseUrl, _url.param("Wuid"), layoutJson);
                }
            });
        } else if (_url.param("dsp")) {
            const dsp = document.URL.split("dsp=")[1].split("&")[0].split("%26").join("&");
            fetch(dsp)
                .then(resp => resp.json())
                .then(json => {
                    const protocol = json.response.LayoutText.__properties.ddlUrl.split("://")[0];
                    const hostname = json.response.LayoutText.__properties.ddlUrl.split(":")[1].slice(2);
                    const port = json.response.LayoutText.__properties.ddlUrl.split(":")[2].split("/")[0];
                    const urlStr = json.response.LayoutText.__properties.ddlUrl + `&Protocol=${protocol}&Hostname=${hostname}&Port=${port}`;
                    this.init(placeholder, urlStr, json.response.LayoutText);
                })
github hpcc-systems / HPCC-Platform / esp / src / src / ESPRequest.ts View on Github external
rawxml_: true
        });

        var handleAs = params.handleAs ? params.handleAs : "json";
        var postfix = "";
        if (handleAs === "json") {
            postfix = ".json";
        }
        // var method = params.method ? params.method : "get";

        var retVal = null;
        if (this.isCrossSite()) {
            var transport = new hpccComms.Connection({ baseUrl: this.getBaseURL(service), timeoutSecs: params.request.timeOutSeconds || this.timeOutSeconds, type: "jsonp" });
            retVal = transport.send(action + postfix, params.request, handleAs === "text" ? "text" : "json");
        } else {
            var transport = new hpccComms.Connection({ baseUrl: this.getBaseURL(service), timeoutSecs: params.request.timeOutSeconds || this.timeOutSeconds});
            retVal = transport.send(action + postfix, params.request, handleAs === "text" ? "text" : "json");
        }

        return retVal.then(function (response) {
            if (lang.exists("Exceptions.Exception", response)) {
                if (response.Exceptions.Exception.Code === "401") {
                    if (cookie("Status") === "Unlocked") {
                        topic.publish("hpcc/session_management_status", {
                            status: "DoIdle"
                        });
                    }
                    cookie("Status", "Locked");
                    ESPUtil.LocalStorage.removeItem("Status");
                }
            }
            params.load(response);
github hpcc-systems / Visualization / demos / dashy / lib-umd / index.js View on Github external
ddlStr = response[0][_url.param("ResultName")];
                        ddl = JSON.parse(ddlStr);
                        this._dashy.importDDL(ddl, baseUrl_1, _url.param("Wuid"));
                        return [2 /*return*/];
                    });
                }); });
            }
            else if (_url.param("QueryID")) {
                // http://10.241.100.159:8002/WsEcl/submit/query/roxie/prichajx_govottocustomerstats.ins109_service_1/json
                // ?Protocol=http&Hostname=10.241.100.159&Port=8002&QuerySet=roxie&QueryID=prichajx_govottocustomerstats.ins109_service_1
                logger.debug("Roxie Params:  " + JSON.stringify(_url.params()));
                var baseUrl_2 = (_url.param("Protocol") || "http") + "://" + _url.param("Hostname") + ":" + _url.param("Port");
                var action = "WsEcl/submit/query/" + _url.param("QuerySet") + "/" + _url.param("QueryID") + "/json";
                var responseID_1 = _url.param("QueryID") + "Response";
                logger.debug(action);
                var connection = new comms_1.Connection({ baseUrl: baseUrl_2 });
                connection.send(action, {}).then(function (response) {
                    if (util_1.exists("Results.HIPIE_DDL.Row", response[responseID_1]) && response[responseID_1].Results.HIPIE_DDL.Row.length) {
                        var ddl = JSON.parse(response[responseID_1].Results.HIPIE_DDL.Row[0].HIPIE_DDL);
                        _this._dashy.importDDL(ddl, baseUrl_2, _url.param("Wuid"));
                    }
                });
            }
            else {
            }
        };
        App.prototype.doResize = function (width, height) {
github hpcc-systems / Visualization / tests / test-comms / src / connection.spec.ts View on Github external
it("authentication", function () {
        const transport = new Connection({
            baseUrl: "http://10.240.32.125:8010/",
            userID: "gosmith",
            password: "ch@ng3m3",
            type: "post"
        });
        return transport.send("WsWorkunits/WUQuery.json", {}).then((response) => {
            expect(true).to.be.true;
            return response;
        }).catch((e) => {
            expect(false).to.be.true;
        });
    });
});
github hpcc-systems / Visualization / tests / test-comms / src / services / wsWorkunits.spec.ts View on Github external
describe("GET", function () {
        const wsWorkunits = new WorkunitsService(new Connection({ baseUrl: ESP_URL, type: "get" }));
        doTest(wsWorkunits);
    });
    if (isBrowser) {