How to use @hpcc-js/comms - 10 common examples

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 / tests / test-comms / src / clienttools / eclcc.spec.ts View on Github external
it("basic", function () {
            expect(locateClientTools).to.be.a("function");
            return locateClientTools().then(clienttools => {
            }).catch(e => {
                //  No eclcc on travis...
            });
        });
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 / Graph7Widget.ts View on Github external
fetchScopeGraph(wuid: string, graphID: string, refresh: boolean = false): Promise {
        this.graphStatus.innerText = this.i18n.FetchingData;
        const hash = hashSum({
            wuid,
            graphID
        });
        if (!this._prevScopeGraph || refresh || this._prevHashSum !== hash) {
            this._prevHashSum = hash;
            this._gc.clear();
            const wu = Workunit.attach({ baseUrl: "" }, wuid);
            this._prevScopeGraph = wu.fetchScopeGraphs(graphID ? [graphID] : []).then(scopedGraph => {
                this.graphStatus.innerText = this.i18n.Loading;
                return new Promise((resolve, reject) => {
                    setTimeout(() => {
                        this._gc.set(scopedGraph);
                        resolve(scopedGraph);
                    }, 0);
                });
            });
        }
        return this._prevScopeGraph;
    }
    //  --- ---
github hpcc-systems / Visualization / demos / dashy / src / index.ts View on Github external
this._dashy = new Dashy()
                .target(placeholder)
                .render()
                ;
        }

        this._dashy.element()
            .on("drop", () => this.dropHandler(this.event()))
            .on("dragover", () => this.dragOverHandler(this.event()))
            ;

        if (_url.param("Wuid")) {
            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);
                }
github hpcc-systems / Visualization / demos / dashy / lib-umd / index.js View on Github external
App.prototype.parseUrl = function () {
            var _this = this;
            var _url = new other_1.Comms.ESPUrl().url(document.URL);
            if (_url.param("Wuid")) {
                logger.debug("WU Params:  " + _url.params());
                var baseUrl_1 = _url.param("Protocol") + "://" + _url.param("Hostname") + ":" + _url.param("Port");
                logger.debug(baseUrl_1);
                var result = new comms_1.Result({ baseUrl: baseUrl_1 }, _url.param("Wuid"), _url.param("ResultName"));
                result.fetchRows().then(function (response) { return __awaiter(_this, void 0, void 0, function () {
                    var ddlStr, ddl;
                    return __generator(this, function (_a) {
                        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";
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 / clienttools / eclcc.spec.ts View on Github external
function test(build: string, prefix: string, major: number, minor: number, patch: number, postfix: string): boolean {
    const version = new Version(build);
    return version.prefix === prefix && version.major === major && version.minor === minor && version.patch === patch && version.postfix === postfix;
}
github hpcc-systems / Visualization / tests / test-comms / src / clienttools / eclcc.spec.ts View on Github external
it("version compare", function () {
                const version5_6_8 = new Version("5.6.8");
                const version6_6_8 = new Version("6.6.8");
                expect(version5_6_8.compare(version6_6_8)).to.be.lessThan(0);
                expect(version6_6_8.compare(version5_6_8)).to.be.greaterThan(0);
                expect(version6_6_8.compare(version6_6_8)).to.equal(0);
                const version6_6_8rc1 = new Version("6.6.8-rc1");
                expect(version6_6_8.compare(version6_6_8rc1)).to.greaterThan(0);
                const version5_6_8rc1 = new Version("5.6.8-rc1");
                const version5_6_8rc2 = new Version("5.6.8-rc2");
                expect(version5_6_8rc1.compare(version5_6_8rc2)).to.lessThan(0);
            });
github hpcc-systems / Visualization / tests / test-comms / src / clienttools / eclcc.spec.ts View on Github external
it("version compare", function () {
                const version5_6_8 = new Version("5.6.8");
                const version6_6_8 = new Version("6.6.8");
                expect(version5_6_8.compare(version6_6_8)).to.be.lessThan(0);
                expect(version6_6_8.compare(version5_6_8)).to.be.greaterThan(0);
                expect(version6_6_8.compare(version6_6_8)).to.equal(0);
                const version6_6_8rc1 = new Version("6.6.8-rc1");
                expect(version6_6_8.compare(version6_6_8rc1)).to.greaterThan(0);
                const version5_6_8rc1 = new Version("5.6.8-rc1");
                const version5_6_8rc2 = new Version("5.6.8-rc2");
                expect(version5_6_8rc1.compare(version5_6_8rc2)).to.lessThan(0);
            });