Skip to content

Commit

Permalink
Refactor table into a component
Browse files Browse the repository at this point in the history
  • Loading branch information
mansurpasha committed Apr 29, 2020
1 parent 047dfc1 commit 49bd28e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/components/resourceTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { lambdaStatisticsModal } from "../modals/lambdaStatisticsModal";
import { lambdaInvokeModal } from "../modals/lambdaInvokeModal";
import { getFunctionMemoryAndTimeout } from "../services/awsLambda";
import { padString } from "../utils/padString";
import { Table } from "../components/table";

const contrib = require("blessed-contrib");
const open = require("open");
Expand All @@ -34,7 +35,7 @@ class resourceTable {
this.latestLambdaFunctionsUpdateTimestamp = -1;
this.program = program;
this.cloudformation = cloudformation;
this.table = this.generateLambdaTable();
this.table = new Table(application).table;
this.funcName = null;
this.fullFuncName = null;
this.table.rows.on("select", (item) => {
Expand Down Expand Up @@ -158,21 +159,6 @@ class resourceTable {
return this.updateData();
}

generateLambdaTable() {
return this.application.layoutGrid.set(0, 6, 4, 6, contrib.table, {
keys: true,
fg: "green",
label: "<- Lambda Functions ->",
columnSpacing: 1,
columnWidth: [35, 40, 10, 10, 20],
style: {
border: {
fg: "yellow",
},
},
});
}

getCurrentlyOnHoverLambdaName() {
const onHoverRow = this.table.rows.selected;
const [onHoverLambdaName] = this.table.rows.items[onHoverRow].data;
Expand Down
27 changes: 27 additions & 0 deletions src/components/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const contrib = require("blessed-contrib");

class Table {
constructor(application) {
this.application = application;
this.table = this.generateTable();
}

generateTable() {
return this.application.layoutGrid.set(0, 6, 4, 6, contrib.table, {
keys: true,
fg: "green",
label: "<- Lambda Functions ->",
columnSpacing: 1,
columnWidth: [35, 40, 10, 10, 20],
style: {
border: {
fg: "yellow",
},
},
});
}
}

module.exports = {
Table,
};

0 comments on commit 49bd28e

Please sign in to comment.