Skip to content

Commit b1de0fb

Browse files
authored
Merge pull request #16 from basicrum/12-improve-build-feedback-information
Improve build feedback information
2 parents 5220e36 + e21b05b commit b1de0fb

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

build.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ if (!fs.existsSync(dir)){
2121

2222
const dashboards = ['General', 'Metrics', 'Summary'];
2323

24+
var summaryList = [];
2425
for (const dashboard of dashboards) {
25-
builder.build(dashboard, options);
26+
var summary = builder.build(dashboard, options);
27+
summaryList.push(summary);
28+
}
29+
30+
console.log("");
31+
console.log("SUMMARY");
32+
console.log("");
33+
console.log("dashboards: " + summaryList.length);
34+
console.log("");
35+
for (const summary of summaryList) {
36+
console.log("dashboard: " + summary.name);
37+
console.log("panels: " + summary.panels);
38+
console.log("path: " + summary.path);
39+
console.log("");
2640
}

lib/DashboardBuilder.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ class DashboardBuilder {
1818
const dashboardDefinition = this.loadDashboardDefinition(dashboardName);
1919
this.addTitle(result, dashboardDefinition);
2020
this.addFilters(result, dashboardDefinition, options);
21-
this.addPanels(result, dashboardDefinition, options);
22-
23-
this.writeDashboard(dashboardName, result);
21+
this.addPanels(result, dashboardDefinition, options, dashboardName);
22+
23+
const path = `./build/dashboards/${dashboardName}.json`;
24+
this.writeDashboard(path, result);
25+
return {
26+
"name": dashboardName,
27+
"panels": result.panels.length,
28+
"path": path
29+
}
2430
}
2531

2632
loadDashboardDefinition(dashboardName) {
2733
return this.loadJSON(rootPath + `/dashboards/defs/${dashboardName}.json`);
2834
}
2935

30-
writeDashboard(dashboardName, result) {
31-
this.writeJSON(`./build/dashboards/${dashboardName}.json`, result);
36+
writeDashboard(path, result) {
37+
this.writeJSON(path, result);
3238
}
3339

3440
addTitle(result, dashboardDefinition) {
@@ -40,8 +46,8 @@ class DashboardBuilder {
4046
result['templating']['list'] = this.buildFilters(dashboardDefinition["filters"], options);
4147
}
4248

43-
addPanels(result, dashboardDefinition, options) {
44-
result["panels"] = this.buildPanels(dashboardDefinition["rows"], options);
49+
addPanels(result, dashboardDefinition, options, dashboardName) {
50+
result["panels"] = this.buildPanels(dashboardDefinition["rows"], options, dashboardName);
4551
}
4652

4753
buildFilters(filters, options) {
@@ -56,9 +62,10 @@ class DashboardBuilder {
5662
return result;
5763
}
5864

59-
buildPanels(rows, options) {
65+
buildPanels(rows, options, dashboardName) {
6066
let result = [];
6167

68+
console.log("")
6269
let currentY = 0;
6370
let currentID = 1;
6471
for(const row of rows) {
@@ -79,6 +86,7 @@ class DashboardBuilder {
7986
const panelHeight = this.makePanelHeight(builder, column);
8087
this.updatePanel(panel, column, currentID, panelX, panelY, panelWidth, panelHeight);
8188

89+
console.log(dashboardName + ": add panel " + panel.title)
8290
result.push(panel);
8391

8492
currentID++;

0 commit comments

Comments
 (0)