smartlog-destination-local/dist/beautylog.classes.table.js

55 lines
6.2 KiB
JavaScript

"use strict";
require("typings-global");
var plugins = require("./beautylog.plugins");
var tableHelpers = {
makeRow: function (cellCounterArg, colorArg) {
if (cellCounterArg === void 0) { cellCounterArg = 2; }
if (colorArg === void 0) { colorArg = "cyan"; }
var rowArray = [];
for (var i = 0; i < (cellCounterArg); i++) {
rowArray.push(String(i + 1).cyan);
}
return rowArray;
}
};
var Table = (function () {
function Table(tableTypeArg, tableHeadArrayArg) {
if (tableHeadArrayArg === void 0) { tableHeadArrayArg = tableHelpers.makeRow(); }
switch (tableTypeArg) {
case "checks":
this.tableHead = ['Check Item:'.cyan, 'Status:'.cyan];
break;
case "custom":
this.tableHead = tableHeadArrayArg;
break;
default:
break;
}
this.rows = [];
this.type = tableTypeArg;
}
Table.prototype.push = function (row) {
this.rows.push(row);
};
Table.prototype.print = function () {
var table = new plugins.cliTable({
head: this.tableHead
});
for (var row in this.rows) {
if (this.rows[row][1] == "success") {
this.rows[row][1] = ' '.bgGreen + ' ' + this.rows[row][1];
}
else if (this.rows[row][1] == "error") {
this.rows[row][1] = ' '.bgRed + ' ' + this.rows[row][1];
}
table.push(this.rows[row]);
}
;
console.log(table.toString());
};
return Table;
}());
exports.Table = Table;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5jbGFzc2VzLnRhYmxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUUvQyxJQUFJLFlBQVksR0FBRztJQUNmLE9BQU8sRUFBRSxVQUFTLGNBQXlCLEVBQUMsUUFBd0I7UUFBbEQsOEJBQXlCLEdBQXpCLGtCQUF5QjtRQUFDLHdCQUF3QixHQUF4QixpQkFBd0I7UUFDaEUsSUFBSSxRQUFR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ICAgICAgICB0aGlzLnRhYmxlSGVhZCA9IHRhYmxlSGVhZEFycmF5QXJnO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJvd3MgPSBbXTtcbiAgICAgICAgdGhpcy50eXBlID0gdGFibGVUeXBlQXJnO1xuICAgIH1cbiAgICBwdXNoKHJvdzpzdHJpbmdbXSl7XG4gICAgICAgIHRoaXMucm93cy5wdXNoKHJvdyk7XG4gICAgfVxuICAgIHByaW50KCkge1xuICAgICAgICBsZXQgdGFibGUgPSBuZXcgcGx1Z2lucy5jbGlUYWJsZSh7XG4gICAgICAgICAgICBoZWFkOiB0aGlzLnRhYmxlSGVhZFxuICAgICAgICB9KTtcbiAgICAgICAgZm9yIChsZXQgcm93IGluIHRoaXMucm93cyl7XG4gICAgICAgICAgICBpZih0aGlzLnJvd3Nbcm93XVsxXSA9PSBcInN1Y2Nlc3NcIil7XG4gICAgICAgICAgICAgICAgdGhpcy5yb3dzW3Jvd11bMV0gPSAnICcuYmdHcmVlbiArICcgJyArIHRoaXMucm93c1tyb3ddWzFdO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLnJvd3Nbcm93XVsxXSA9PSBcImVycm9yXCIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnJvd3Nbcm93XVsxXSA9ICcgJy5iZ1JlZCArICcgJyArIHRoaXMucm93c1tyb3ddWzFdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGFibGUucHVzaCh0aGlzLnJvd3Nbcm93XSk7XG4gICAgICAgIH07XG4gICAgICAgIGNvbnNvbGUubG9nKHRhYmxlLnRvU3RyaW5nKCkpO1xuICAgIH1cbn0iXX0=