Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ if (!fs.existsSync(dir)){

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

var summaryList = [];
for (const dashboard of dashboards) {
builder.build(dashboard, options);
var summary = builder.build(dashboard, options);
summaryList.push(summary);
}

console.log("");
console.log("SUMMARY");
console.log("");
console.log("dashboards: " + summaryList.length);
console.log("");
for (const summary of summaryList) {
console.log("dashboard: " + summary.name);
console.log("panels: " + summary.panels);
console.log("path: " + summary.path);
console.log("");
}
24 changes: 16 additions & 8 deletions lib/DashboardBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ class DashboardBuilder {
const dashboardDefinition = this.loadDashboardDefinition(dashboardName);
this.addTitle(result, dashboardDefinition);
this.addFilters(result, dashboardDefinition, options);
this.addPanels(result, dashboardDefinition, options);

this.writeDashboard(dashboardName, result);
this.addPanels(result, dashboardDefinition, options, dashboardName);

const path = `./build/dashboards/${dashboardName}.json`;
this.writeDashboard(path, result);
return {
"name": dashboardName,
"panels": result.panels.length,
"path": path
}
}

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

writeDashboard(dashboardName, result) {
this.writeJSON(`./build/dashboards/${dashboardName}.json`, result);
writeDashboard(path, result) {
this.writeJSON(path, result);
}

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

addPanels(result, dashboardDefinition, options) {
result["panels"] = this.buildPanels(dashboardDefinition["rows"], options);
addPanels(result, dashboardDefinition, options, dashboardName) {
result["panels"] = this.buildPanels(dashboardDefinition["rows"], options, dashboardName);
}

buildFilters(filters, options) {
Expand All @@ -56,9 +62,10 @@ class DashboardBuilder {
return result;
}

buildPanels(rows, options) {
buildPanels(rows, options, dashboardName) {
let result = [];

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

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

currentID++;
Expand Down