@hpcc-js/comms
Version:
hpcc-js - Communications
234 lines • 8.74 kB
JavaScript
import { __extends } from "tslib";
import { StateObject } from "@hpcc-js/util";
var Attribute = /** @class */ (function (_super) {
__extends(Attribute, _super);
function Attribute(scope, attribute) {
var _this = _super.call(this) || this;
_this.scope = scope;
_this.set(attribute);
return _this;
}
Object.defineProperty(Attribute.prototype, "properties", {
get: function () { return this.get(); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "Name", {
get: function () { return this.get("Name"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "RawValue", {
get: function () { return this.get("RawValue"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "Formatted", {
get: function () { return this.get("Formatted"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "FormattedEnd", {
get: function () { return this.get("FormattedEnd"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "Measure", {
get: function () { return this.get("Measure"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "Creator", {
get: function () { return this.get("Creator"); },
enumerable: false,
configurable: true
});
Object.defineProperty(Attribute.prototype, "CreatorType", {
get: function () { return this.get("CreatorType"); },
enumerable: false,
configurable: true
});
return Attribute;
}(StateObject));
export { Attribute };
var BaseScope = /** @class */ (function (_super) {
__extends(BaseScope, _super);
function BaseScope(scope) {
var _this = _super.call(this) || this;
_this._attributeMap = {};
_this._children = [];
_this.update(scope);
return _this;
}
Object.defineProperty(BaseScope.prototype, "properties", {
get: function () { return this.get(); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "ScopeName", {
get: function () { return this.get("ScopeName"); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "Id", {
get: function () { return this.get("Id"); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "ScopeType", {
get: function () { return this.get("ScopeType"); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "Properties", {
get: function () { return this.get("Properties", { Property: [] }); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "Notes", {
get: function () { return this.get("Notes", { Note: [] }); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "SinkActivity", {
get: function () { return this.get("SinkActivity"); },
enumerable: false,
configurable: true
});
Object.defineProperty(BaseScope.prototype, "CAttributes", {
get: function () {
var _this = this;
// Match "started" and time elapsed
var retVal = [];
var timeElapsed = {
start: null,
end: null
};
this.Properties.Property.forEach(function (scopeAttr) {
if (scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Started") >= 0) {
timeElapsed.start = scopeAttr;
}
else if (_this.ScopeName && scopeAttr.Measure === "ts" && scopeAttr.Name.indexOf("Finished") >= 0) {
timeElapsed.end = scopeAttr;
}
else {
retVal.push(new Attribute(_this, scopeAttr));
}
});
if (timeElapsed.start && timeElapsed.end) {
// const endTime = parser(timeElapsed.start.Formatted);
// endTime!.setMilliseconds(endTime!.getMilliseconds() + (+timeElapsed.elapsed.RawValue) / 1000000);
// timeElapsed.start.FormattedEnd = formatter(endTime!);
timeElapsed.start.FormattedEnd = timeElapsed.end.Formatted;
retVal.push(new Attribute(this, timeElapsed.start));
}
else if (timeElapsed.start) {
retVal.push(new Attribute(this, timeElapsed.start));
}
else if (timeElapsed.end) {
retVal.push(new Attribute(this, timeElapsed.end)); // Should not happen?
}
return retVal;
},
enumerable: false,
configurable: true
});
BaseScope.prototype.update = function (scope) {
var _this = this;
this.set(scope);
this.CAttributes.forEach(function (attr) {
_this._attributeMap[attr.Name] = attr;
});
this.Properties.Property = [];
for (var key in this._attributeMap) {
if (this._attributeMap.hasOwnProperty(key)) {
this.Properties.Property.push(this._attributeMap[key].properties);
}
}
};
BaseScope.prototype.parentScope = function () {
var scopeParts = this.ScopeName.split(":");
scopeParts.pop();
return scopeParts.join(":");
};
BaseScope.prototype.children = function (_) {
if (!arguments.length)
return this._children;
this._children = _;
return this;
};
BaseScope.prototype.walk = function (visitor) {
if (visitor.start(this))
return true;
for (var _i = 0, _a = this.children(); _i < _a.length; _i++) {
var scope = _a[_i];
if (scope.walk(visitor)) {
return true;
}
}
return visitor.end(this);
};
BaseScope.prototype.formattedAttrs = function () {
var retVal = {};
for (var attr in this._attributeMap) {
retVal[attr] = this._attributeMap[attr].Formatted || this._attributeMap[attr].RawValue;
}
return retVal;
};
BaseScope.prototype.rawAttrs = function () {
var retVal = {};
for (var attr in this._attributeMap) {
retVal[attr] = this._attributeMap[attr].RawValue;
}
return retVal;
};
BaseScope.prototype.hasAttr = function (name) {
return this._attributeMap[name] !== undefined;
};
BaseScope.prototype.attr = function (name) {
return this._attributeMap[name] || new Attribute(this, {
Creator: "",
CreatorType: "",
Formatted: "",
Measure: "",
Name: "",
RawValue: ""
});
};
BaseScope.prototype.attrMeasure = function (name) {
return this._attributeMap[name].Measure;
};
BaseScope.prototype.calcTooltip = function (parentScope) {
var label = "";
var rows = [];
label = this.Id;
rows.push("<tr><td class=\"key\">ID:</td><td class=\"value\">".concat(this.Id, "</td></tr>"));
if (parentScope) {
rows.push("<tr><td class=\"key\">Parent ID:</td><td class=\"value\">".concat(parentScope.Id, "</td></tr>"));
}
rows.push("<tr><td class=\"key\">Scope:</td><td class=\"value\">".concat(this.ScopeName, "</td></tr>"));
var attrs = this.formattedAttrs();
for (var key in attrs) {
if (key === "Label") {
label = attrs[key];
}
else {
rows.push("<tr><td class=\"key\">".concat(key, "</td><td class=\"value\">").concat(attrs[key], "</td></tr>"));
}
}
return "<div class=\"eclwatch_WUGraph_Tooltip\" style=\"max-width:480px\">\n <h4 align=\"center\">".concat(label, "</h4>\n <table>\n ").concat(rows.join(""), "\n </table>\n </div>");
};
return BaseScope;
}(StateObject));
export { BaseScope };
var Scope = /** @class */ (function (_super) {
__extends(Scope, _super);
function Scope(wu, scope) {
var _this = _super.call(this, scope) || this;
_this.wu = wu;
return _this;
}
return Scope;
}(BaseScope));
export { Scope };
//# sourceMappingURL=scope.js.map