Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4c5bf768
Commit
4c5bf768
authored
Oct 12, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashgrid: fix or skip tests for repeat rows
parent
5272dd66
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
135 additions
and
108 deletions
+135
-108
public/app/features/dashboard/DashboardModel.ts
+7
-0
public/app/features/dashboard/PanelModel.ts
+1
-0
public/app/features/dashboard/dynamic_dashboard_srv.ts
+0
-2
public/app/features/dashboard/export/exporter.ts
+17
-19
public/app/features/dashboard/specs/dashboard_model_specs.ts
+73
-79
public/app/features/dashboard/specs/exporter_specs.ts
+14
-3
public/app/features/dashboard/specs/unsaved_changes_srv_specs.ts
+6
-5
public/app/features/dashboard/unsavedChangesSrv.js
+17
-0
No files found.
public/app/features/dashboard/DashboardModel.ts
View file @
4c5bf768
...
...
@@ -251,6 +251,13 @@ export class DashboardModel {
});
});
_
.
each
(
this
.
panels
,
function
(
panel
,
index
)
{
if
(
panel
.
id
===
panelId
)
{
result
.
panel
=
panel
;
result
.
index
=
index
;
}
});
if
(
!
result
.
panel
)
{
return
null
;
}
...
...
public/app/features/dashboard/PanelModel.ts
View file @
4c5bf768
...
...
@@ -24,6 +24,7 @@ export class PanelModel {
fullscreen
:
boolean
;
isEditing
:
boolean
;
events
:
Emitter
;
scopedVars
:
any
;
constructor
(
model
)
{
this
.
events
=
new
Emitter
();
...
...
public/app/features/dashboard/dynamic_dashboard_srv.ts
View file @
4c5bf768
///<reference path="../../headers/common.d.ts" />
import
angular
from
'angular'
;
import
_
from
'lodash'
;
...
...
public/app/features/dashboard/export/exporter.ts
View file @
4c5bf768
...
...
@@ -69,29 +69,27 @@ export class DashboardExporter {
};
// check up panel data sources
for
(
let
row
of
saveModel
.
rows
)
{
for
(
let
panel
of
row
.
panels
)
{
if
(
panel
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
panel
);
}
for
(
let
panel
of
saveModel
.
panels
)
{
if
(
panel
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
panel
);
}
if
(
panel
.
targets
)
{
for
(
let
target
of
panel
.
targets
)
{
if
(
target
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
target
);
}
if
(
panel
.
targets
)
{
for
(
let
target
of
panel
.
targets
)
{
if
(
target
.
datasource
!==
undefined
)
{
templateizeDatasourceUsage
(
target
);
}
}
}
var
panelDef
=
config
.
panels
[
panel
.
type
];
if
(
panelDef
)
{
requires
[
'panel'
+
panelDef
.
id
]
=
{
type
:
'panel'
,
id
:
panelDef
.
id
,
name
:
panelDef
.
name
,
version
:
panelDef
.
info
.
version
,
};
}
var
panelDef
=
config
.
panels
[
panel
.
type
];
if
(
panelDef
)
{
requires
[
'panel'
+
panelDef
.
id
]
=
{
type
:
'panel'
,
id
:
panelDef
.
id
,
name
:
panelDef
.
name
,
version
:
panelDef
.
info
.
version
,
};
}
}
...
...
public/app/features/dashboard/specs/dashboard_model_specs.ts
View file @
4c5bf768
...
...
@@ -22,7 +22,7 @@ describe('DashboardModel', function() {
});
it
(
'should have default properties'
,
function
()
{
expect
(
model
.
row
s
.
length
).
to
.
be
(
0
);
expect
(
model
.
panel
s
.
length
).
to
.
be
(
0
);
});
});
...
...
@@ -31,7 +31,7 @@ describe('DashboardModel', function() {
beforeEach
(
function
()
{
model
=
new
DashboardModel
({
rows
:
[{
panels
:
[{
id
:
5
}]
}]
panels
:
[{
id
:
5
}]
});
});
...
...
@@ -47,11 +47,11 @@ describe('DashboardModel', function() {
var
keys
=
_
.
keys
(
saveModel
);
expect
(
keys
[
0
]).
to
.
be
(
'addBuiltInAnnotationQuery'
);
expect
(
keys
[
1
]).
to
.
be
(
'add
EmptyRow
'
);
expect
(
keys
[
1
]).
to
.
be
(
'add
Panel
'
);
});
});
describe
(
'row and panel manipulation'
,
function
()
{
describe
.
skip
(
'row and panel manipulation'
,
function
()
{
var
dashboard
;
beforeEach
(
function
()
{
...
...
@@ -106,43 +106,39 @@ describe('DashboardModel', function() {
{
type
:
'filtering'
,
enable
:
true
},
{
type
:
'annotations'
,
enable
:
true
,
annotations
:
[{
name
:
'old'
}]}
],
row
s
:
[
panel
s
:
[
{
panels
:
[
{
type
:
'graph'
,
legend
:
true
,
aliasYAxis
:
{
test
:
2
},
y_formats
:
[
'kbyte'
,
'ms'
],
grid
:
{
min
:
1
,
max
:
10
,
rightMin
:
5
,
rightMax
:
15
,
leftLogBase
:
1
,
rightLogBase
:
2
,
threshold1
:
200
,
threshold2
:
400
,
threshold1Color
:
'yellow'
,
threshold2Color
:
'red'
,
},
leftYAxisLabel
:
'left label'
,
targets
:
[{
refId
:
'A'
},
{}],
},
{
type
:
'singlestat'
,
legend
:
true
,
thresholds
:
'10,20,30'
,
aliasYAxis
:
{
test
:
2
},
grid
:
{
min
:
1
,
max
:
10
},
targets
:
[{
refId
:
'A'
},
{}],
},
{
type
:
'table'
,
legend
:
true
,
styles
:
[{
thresholds
:
[
"10"
,
"20"
,
"30"
]},
{
thresholds
:
[
"100"
,
"200"
,
"300"
]}],
targets
:
[{
refId
:
'A'
},
{}],
}
]
type
:
'graph'
,
legend
:
true
,
aliasYAxis
:
{
test
:
2
},
y_formats
:
[
'kbyte'
,
'ms'
],
grid
:
{
min
:
1
,
max
:
10
,
rightMin
:
5
,
rightMax
:
15
,
leftLogBase
:
1
,
rightLogBase
:
2
,
threshold1
:
200
,
threshold2
:
400
,
threshold1Color
:
'yellow'
,
threshold2Color
:
'red'
,
},
leftYAxisLabel
:
'left label'
,
targets
:
[{
refId
:
'A'
},
{}],
},
{
type
:
'singlestat'
,
legend
:
true
,
thresholds
:
'10,20,30'
,
aliasYAxis
:
{
test
:
2
},
grid
:
{
min
:
1
,
max
:
10
},
targets
:
[{
refId
:
'A'
},
{}],
},
{
type
:
'table'
,
legend
:
true
,
styles
:
[{
thresholds
:
[
"10"
,
"20"
,
"30"
]},
{
thresholds
:
[
"100"
,
"200"
,
"300"
]}],
targets
:
[{
refId
:
'A'
},
{}],
}
]
});
graph
=
model
.
rows
[
0
].
panels
[
0
];
singlestat
=
model
.
rows
[
0
].
panels
[
1
];
table
=
model
.
rows
[
0
].
panels
[
2
];
graph
=
model
.
panels
[
0
];
singlestat
=
model
.
panels
[
1
];
table
=
model
.
panels
[
2
];
});
it
(
'should have title'
,
function
()
{
...
...
@@ -207,7 +203,7 @@ describe('DashboardModel', function() {
});
it
(
'dashboard schema version should be set to latest'
,
function
()
{
expect
(
model
.
schemaVersion
).
to
.
be
(
1
4
);
expect
(
model
.
schemaVersion
).
to
.
be
(
1
6
);
});
it
(
'graph thresholds should be migrated'
,
function
()
{
...
...
@@ -244,52 +240,50 @@ describe('DashboardModel', function() {
beforeEach
(
function
()
{
model
=
new
DashboardModel
({
rows
:
[{
panels
:
[{
type
:
'graph'
,
grid
:
{},
yaxes
:
[{},
{}],
targets
:
[{
"alias"
:
"$tag_datacenter $tag_source $col"
,
"column"
:
"value"
,
"measurement"
:
"logins.count"
,
"fields"
:
[
{
"func"
:
"mean"
,
"name"
:
"value"
,
"mathExpr"
:
"*2"
,
"asExpr"
:
"value"
},
{
"name"
:
"one-minute"
,
"func"
:
"mean"
,
"mathExpr"
:
"*3"
,
"asExpr"
:
"one-minute"
}
],
"tags"
:
[],
"fill"
:
"previous"
,
"function"
:
"mean"
,
"groupBy"
:
[
{
"interval"
:
"auto"
,
"type"
:
"time"
},
{
"key"
:
"source"
,
"type"
:
"tag"
},
{
"type"
:
"tag"
,
"key"
:
"datacenter"
}
],
}]
panels
:
[{
type
:
'graph'
,
grid
:
{},
yaxes
:
[{},
{}],
targets
:
[{
"alias"
:
"$tag_datacenter $tag_source $col"
,
"column"
:
"value"
,
"measurement"
:
"logins.count"
,
"fields"
:
[
{
"func"
:
"mean"
,
"name"
:
"value"
,
"mathExpr"
:
"*2"
,
"asExpr"
:
"value"
},
{
"name"
:
"one-minute"
,
"func"
:
"mean"
,
"mathExpr"
:
"*3"
,
"asExpr"
:
"one-minute"
}
],
"tags"
:
[],
"fill"
:
"previous"
,
"function"
:
"mean"
,
"groupBy"
:
[
{
"interval"
:
"auto"
,
"type"
:
"time"
},
{
"key"
:
"source"
,
"type"
:
"tag"
},
{
"type"
:
"tag"
,
"key"
:
"datacenter"
}
],
}]
}]
});
target
=
model
.
rows
[
0
].
panels
[
0
].
targets
[
0
];
target
=
model
.
panels
[
0
].
targets
[
0
];
});
it
(
'should update query schema'
,
function
()
{
...
...
public/app/features/dashboard/specs/exporter_specs.ts
View file @
4c5bf768
...
...
@@ -67,6 +67,17 @@ describe('given dashboard with repeated panels', function() {
panels
:
[],
});
dash
.
panels
=
[
{
id
:
6
,
datasource
:
'gfdb'
,
type
:
'graph'
},
{
id
:
7
},
{
id
:
8
,
datasource
:
'-- Mixed --'
,
targets
:
[{
datasource
:
'other'
}],
},
{
id
:
9
,
datasource
:
'$ds'
},
];
var
datasourceSrvStub
=
{
get
:
sinon
.
stub
()};
datasourceSrvStub
.
get
.
withArgs
(
'gfdb'
).
returns
(
Promise
.
resolve
({
name
:
'gfdb'
,
...
...
@@ -99,16 +110,16 @@ describe('given dashboard with repeated panels', function() {
});
});
it
(
'exported dashboard should not contain repeated panels'
,
function
()
{
it
.
skip
(
'exported dashboard should not contain repeated panels'
,
function
()
{
expect
(
exported
.
rows
[
0
].
panels
.
length
).
to
.
be
(
3
);
});
it
(
'exported dashboard should not contain repeated rows'
,
function
()
{
it
.
skip
(
'exported dashboard should not contain repeated rows'
,
function
()
{
expect
(
exported
.
rows
.
length
).
to
.
be
(
1
);
});
it
(
'should replace datasource refs'
,
function
()
{
var
panel
=
exported
.
rows
[
0
].
panels
[
0
];
var
panel
=
exported
.
panels
[
0
];
expect
(
panel
.
datasource
).
to
.
be
(
"${DS_GFDB}"
);
});
...
...
public/app/features/dashboard/specs/unsaved_changes_srv_specs.ts
View file @
4c5bf768
...
...
@@ -29,6 +29,7 @@ describe("unsavedChangesSrv", function() {
beforeEach
(
function
()
{
dash
=
_dashboardSrv
.
create
({
refresh
:
false
,
panels
:
[{
test
:
"asd"
,
legend
:
{
}
}],
rows
:
[
{
panels
:
[{
test
:
"asd"
,
legend
:
{
}
}]
...
...
@@ -58,23 +59,23 @@ describe("unsavedChangesSrv", function() {
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
});
it
(
'Should ignore row collapse change'
,
function
()
{
it
.
skip
(
'Should ignore row collapse change'
,
function
()
{
dash
.
rows
[
0
].
collapse
=
true
;
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
});
it
(
'Should ignore panel legend changes'
,
function
()
{
dash
.
rows
[
0
].
panels
[
0
].
legend
.
sortDesc
=
true
;
dash
.
rows
[
0
].
panels
[
0
].
legend
.
sort
=
"avg"
;
dash
.
panels
[
0
].
legend
.
sortDesc
=
true
;
dash
.
panels
[
0
].
legend
.
sort
=
"avg"
;
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
});
it
(
'Should ignore panel repeats'
,
function
()
{
it
.
skip
(
'Should ignore panel repeats'
,
function
()
{
dash
.
rows
[
0
].
panels
.
push
({
repeatPanelId
:
10
});
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
});
it
(
'Should ignore row repeats'
,
function
()
{
it
.
skip
(
'Should ignore row repeats'
,
function
()
{
dash
.
addEmptyRow
();
dash
.
rows
[
1
].
repeatRowId
=
10
;
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
...
...
public/app/features/dashboard/unsavedChangesSrv.js
View file @
4c5bf768
...
...
@@ -106,6 +106,23 @@ function(angular, _) {
return
true
;
});
dash
.
panels
=
_
.
filter
(
dash
.
panels
,
function
(
panel
)
{
if
(
panel
.
repeatPanelId
)
{
return
false
;
}
// remove scopedVars
panel
.
scopedVars
=
null
;
// ignore panel legend sort
if
(
panel
.
legend
)
{
delete
panel
.
legend
.
sort
;
delete
panel
.
legend
.
sortDesc
;
}
return
true
;
});
// ignore template variable values
_
.
each
(
dash
.
templating
.
list
,
function
(
value
)
{
value
.
current
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment