File tree Expand file tree Collapse file tree 14 files changed +161
-410
lines changed Expand file tree Collapse file tree 14 files changed +161
-410
lines changed Original file line number Diff line number Diff line change @@ -22,5 +22,6 @@ define([
22
22
'./export/export_modal' ,
23
23
'./dash_list_ctrl' ,
24
24
'./ad_hoc_filters' ,
25
- './row/row' ,
25
+ './row/row_ctrl' ,
26
+ './repeat_option/repeat_option' ,
26
27
] , function ( ) { } ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import angular from 'angular';
5
5
import _ from 'lodash' ;
6
6
7
7
import coreModule from 'app/core/core_module' ;
8
+ import { DashboardRow } from './row/row_model' ;
8
9
9
10
export class DynamicDashboardSrv {
10
11
iteration : number ;
@@ -45,7 +46,7 @@ export class DynamicDashboardSrv {
45
46
}
46
47
} else if ( row . repeatRowId && row . repeatIteration !== this . iteration ) {
47
48
// clean up old left overs
48
- this . dashboard . rows . splice ( i , 1 ) ;
49
+ this . dashboard . removeRow ( row , true ) ;
49
50
i = i - 1 ;
50
51
continue ;
51
52
}
@@ -80,12 +81,14 @@ export class DynamicDashboardSrv {
80
81
row = this . dashboard . rows [ i ] ;
81
82
if ( row . repeatRowId === sourceRowId && row . repeatIteration !== this . iteration ) {
82
83
copy = row ;
84
+ copy . copyPropertiesFromRowSource ( sourceRow ) ;
83
85
break ;
84
86
}
85
87
}
86
88
87
89
if ( ! copy ) {
88
- copy = angular . copy ( sourceRow ) ;
90
+ var modelCopy = angular . copy ( sourceRow . getSaveModel ( ) ) ;
91
+ copy = new DashboardRow ( modelCopy ) ;
89
92
this . dashboard . rows . splice ( sourceRowIndex + repeatIndex , 0 , copy ) ;
90
93
91
94
// set new panel ids
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import moment from 'moment';
6
6
import _ from 'lodash' ;
7
7
import $ from 'jquery' ;
8
8
9
- import { Emitter , contextSrv } from 'app/core/core' ;
9
+ import { Emitter , contextSrv , appEvents } from 'app/core/core' ;
10
10
import { DashboardRow } from './row/row_model' ;
11
11
12
12
export class DashboardModel {
@@ -169,6 +169,27 @@ export class DashboardModel {
169
169
row . addPanel ( panel ) ;
170
170
}
171
171
172
+ removeRow ( row , force ?) {
173
+ var index = _ . indexOf ( this . rows , row ) ;
174
+
175
+ if ( ! row . panels . length || force ) {
176
+ this . rows . splice ( index , 1 ) ;
177
+ row . destroy ( ) ;
178
+ return ;
179
+ }
180
+
181
+ appEvents . emit ( 'confirm-modal' , {
182
+ title : 'Delete' ,
183
+ text : 'Are you sure you want to delete this row?' ,
184
+ icon : 'fa-trash' ,
185
+ yesText : 'Delete' ,
186
+ onConfirm : ( ) => {
187
+ this . rows . splice ( index , 1 ) ;
188
+ row . destroy ( ) ;
189
+ }
190
+ } ) ;
191
+ }
192
+
172
193
toggleEditMode ( ) {
173
194
this . editMode = ! this . editMode ;
174
195
this . updateSubmenuVisibility ( ) ;
@@ -234,7 +255,7 @@ export class DashboardModel {
234
255
destroy ( ) {
235
256
this . events . removeAllListeners ( ) ;
236
257
for ( let row of this . rows ) {
237
- row . events . removeAllListeners ( ) ;
258
+ row . destroy ( ) ;
238
259
}
239
260
}
240
261
Original file line number Diff line number Diff line change
1
+ ///<reference path="../../../headers/common.d.ts" />
2
+
3
+ import { coreModule } from 'app/core/core' ;
4
+
5
+ var template = `
6
+ <div class="gf-form-select-wrapper max-width-13">
7
+ <select class="gf-form-input" ng-model="model.repeat" ng-options="f.value as f.text for f in variables">
8
+ <option value=""></option>
9
+ </div>
10
+ ` ;
11
+
12
+ coreModule . directive ( 'dashRepeatOption' , function ( variableSrv ) {
13
+ return {
14
+ restrict : 'E' ,
15
+ template : template ,
16
+ scope : {
17
+ model : "=" ,
18
+ } ,
19
+ link : function ( scope , element ) {
20
+ element . css ( { display : 'block' , width : '100%' } ) ;
21
+
22
+ scope . variables = variableSrv . variables . map ( item => {
23
+ return { text : item . name , value : item . name } ;
24
+ } ) ;
25
+
26
+ if ( scope . variables . length === 0 ) {
27
+ scope . variables . unshift ( { text : 'No template variables found' , value : null } ) ;
28
+ }
29
+
30
+ scope . variables . unshift ( { text : 'Disabled' , value : null } ) ;
31
+ }
32
+ } ;
33
+ } ) ;
34
+
Original file line number Diff line number Diff line change 1
1
< div class ="dash-row-options ">
2
2
< div class ="gf-form section ">
3
- <!-- <h5 class="section-heading">Options</h5> -->
4
3
< div class ="gf-form-inline ">
5
4
< div class ="gf-form ">
6
5
< span class ="gf-form-label width-6 "> Row Title</ span >
24
23
</ div >
25
24
26
25
< div class ="gf-form section ">
27
- <!-- <h5 class="section-heading">Row Templating</h5> -->
28
-
29
26
< div class ="gf-form ">
30
27
< span class ="gf-form-label "> Repeat Row</ span >
31
- < div class ="gf-form-select-wrapper max-width-10 ">
32
- < select class ="gf-form-input " ng-model ="row.repeat " ng-options ="f.name as f.name for f in dashboard.templating.list ">
33
- < option value =""> </ option >
34
- </ div >
28
+ < dash-repeat-option model ="ctrl.row "> </ dash-repeat-option >
35
29
</ div >
36
30
</ div >
31
+
32
+ < div class ="clearfix "> </ div >
33
+
34
+ < div class ="pull-right ">
35
+ < button class ="btn btn-danger btn-small " ng-click ="ctrl.removeRow() ">
36
+ < i class ="fa fa-trash "> </ i >
37
+ Delete row
38
+ </ button >
39
+ </ div >
40
+
41
+ < div class ="clearfix "> </ div >
42
+
37
43
</ div >
38
44
Original file line number Diff line number Diff line change 3
3
import _ from 'lodash' ;
4
4
5
5
import config from 'app/core/config' ;
6
- import { coreModule , appEvents } from 'app/core/core' ;
6
+ import { coreModule } from 'app/core/core' ;
7
7
// import VirtualScroll from 'virtual-scroll';
8
8
// console.log(VirtualScroll);
9
9
@@ -20,23 +20,9 @@ export class RowOptionsCtrl {
20
20
this . row . titleSize = this . row . titleSize || 'h6' ;
21
21
}
22
22
23
- deleteRow ( ) {
24
- if ( ! this . row . panels . length ) {
25
- this . dashboard . rows = _ . without ( this . dashboard . rows , this . row ) ;
26
- return ;
27
- }
28
-
29
- appEvents . emit ( 'confirm-modal' , {
30
- title : 'Delete' ,
31
- text : 'Are you sure you want to delete this row?' ,
32
- icon : 'fa-trash' ,
33
- yesText : 'Delete' ,
34
- onConfirm : ( ) => {
35
- this . dashboard . rows = _ . without ( this . dashboard . rows , this . row ) ;
36
- }
37
- } ) ;
23
+ removeRow ( ) {
24
+ this . dashboard . removeRow ( this . row ) ;
38
25
}
39
-
40
26
}
41
27
42
28
export function rowOptionsDirective ( ) {
Original file line number Diff line number Diff line change 5
5
< i class ="fa fa-chevron-down " ng-show ="!ctrl.row.collapse "> </ i >
6
6
< i class ="fa fa-chevron-right " ng-show ="ctrl.row.collapse "> </ i >
7
7
</ span >
8
- < span ng-class ="ctrl.row.titleSize "> {{ctrl.row.title}}</ span >
8
+ < span ng-class ="ctrl.row.titleSize "> {{ctrl.row.title | interpolateTemplateVars:this }}</ span >
9
9
</ a >
10
10
11
11
< div class ="dash-row-header-spacer ">
22
22
< i class ="fa fa-cog " ng-hide ="ctrl.dropView===2 "> </ i >
23
23
< i class ="fa fa-remove " ng-show ="ctrl.dropView===2 "> </ i >
24
24
</ a >
25
- < a class ="pointer dash-row-header-actions--tight " bs-tooltip ="'Move row up' ">
25
+ < a class ="pointer dash-row-header-actions--tight " bs-tooltip ="'Move row up' " ng-click =" ctrl.moveRow(-1) " >
26
26
< i class ="fa fa-arrow-up "> </ i >
27
27
</ a >
28
- < a class ="pointer dash-row-header-actions--tight " bs-tooltip ="'Move row down' ">
28
+ < a class ="pointer dash-row-header-actions--tight " bs-tooltip ="'Move row down' " ng-click =" ctrl.moveRow(1) " >
29
29
< i class ="fa fa-arrow-down "> </ i >
30
30
</ a >
31
31
</ div >
47
47
< i class ="fa fa-chevron-down " ng-show ="!ctrl.row.collapse "> </ i >
48
48
< i class ="fa fa-chevron-right " ng-show ="ctrl.row.collapse "> </ i >
49
49
</ span >
50
- < span ng-class ="ctrl.row.titleSize "> {{ctrl.row.title}}</ span >
50
+ < span ng-class ="ctrl.row.titleSize "> {{ctrl.row.title | interpolateTemplateVars:this }}</ span >
51
51
</ a >
52
52
</ div >
53
53
</ div >
You can’t perform that action at this time.
0 commit comments