@@ -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