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

55 lines
6.3 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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AgICAgICAgICAgY2FzZSBcImN1c3RvbVwiOlxyXG4gICAgICAgICAgICAgICAgdGhpcy50YWJsZUhlYWQgPSB0YWJsZUhlYWRBcnJheUFyZztcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICBkZWZhdWx0OlxyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMucm93cyA9IFtdO1xyXG4gICAgICAgIHRoaXMudHlwZSA9IHRhYmxlVHlwZUFyZztcclxuICAgIH1cclxuICAgIHB1c2gocm93OnN0cmluZ1tdKXtcclxuICAgICAgICB0aGlzLnJvd3MucHVzaChyb3cpO1xyXG4gICAgfVxyXG4gICAgcHJpbnQoKSB7XHJcbiAgICAgICAgbGV0IHRhYmxlID0gbmV3IHBsdWdpbnMuY2xpVGFibGUoe1xyXG4gICAgICAgICAgICBoZWFkOiB0aGlzLnRhYmxlSGVhZFxyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIGZvciAobGV0IHJvdyBpbiB0aGlzLnJvd3Mpe1xyXG4gICAgICAgICAgICBpZih0aGlzLnJvd3Nbcm93XVsxXSA9PSBcInN1Y2Nlc3NcIil7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnJvd3Nbcm93XVsxXSA9ICcgJy5iZ0dyZWVuICsgJyAnICsgdGhpcy5yb3dzW3Jvd11bMV07XHJcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5yb3dzW3Jvd11bMV0gPT0gXCJlcnJvclwiKSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnJvd3Nbcm93XVsxXSA9ICcgJy5iZ1JlZCArICcgJyArIHRoaXMucm93c1tyb3ddWzFdO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRhYmxlLnB1c2godGhpcy5yb3dzW3Jvd10pO1xyXG4gICAgICAgIH07XHJcbiAgICAgICAgY29uc29sZS5sb2codGFibGUudG9TdHJpbmcoKSk7XHJcbiAgICB9XHJcbn0iXX0=