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
18056e53
Commit
18056e53
authored
Nov 01, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ux(dashboard): Fixing broken unit test made by changes for dash edit mode, #6442
parent
786afda4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
65 deletions
+33
-65
public/app/features/dashboard/model.ts
+1
-6
public/app/features/dashboard/row/add_panel.ts
+2
-2
public/app/features/dashboard/row/row_ctrl.ts
+2
-2
public/app/features/dashboard/specs/dashboard_srv_specs.ts
+3
-8
public/app/features/dashboard/specs/exporter_specs.ts
+2
-0
public/app/features/dashboard/specs/row_model_specs.ts
+10
-0
public/app/features/dashboard/unsavedChangesSrv.js
+9
-5
public/app/features/panel/panel_directive.ts
+2
-7
public/test/specs/row-ctrl-specs.js
+0
-34
public/test/specs/unsavedChangesSrv-specs.js
+2
-1
No files found.
public/app/features/dashboard/model.ts
View file @
18056e53
...
...
@@ -158,12 +158,6 @@ export class DashboardModel {
return
null
;
}
rowSpan
(
row
)
{
return
_
.
reduce
(
row
.
panels
,
function
(
p
,
v
)
{
return
p
+
v
.
span
;
},
0
);
};
addPanel
(
panel
,
row
)
{
panel
.
id
=
this
.
getNextPanelId
();
row
.
addPanel
(
panel
);
...
...
@@ -540,6 +534,7 @@ export class DashboardModel {
// update graph yaxes changes
panelUpgrades
.
push
(
function
(
panel
)
{
if
(
panel
.
type
!==
'graph'
)
{
return
;
}
if
(
!
panel
.
grid
)
{
return
;
}
panel
.
thresholds
=
[];
var
t1
:
any
=
{},
t2
:
any
=
{};
...
...
public/app/features/dashboard/row/add_panel.ts
View file @
18056e53
...
...
@@ -81,13 +81,13 @@ export class AddPanelCtrl {
addPanel
(
panelPluginInfo
)
{
var
defaultSpan
=
12
;
var
_as
=
12
-
this
.
dashboard
.
rowSpan
(
this
.
row
)
;
var
span
=
12
-
this
.
row
.
span
;
var
panel
=
{
id
:
null
,
title
:
config
.
new_panel_title
,
error
:
false
,
span
:
_as
<
defaultSpan
&&
_as
>
0
?
_as
:
defaultSpan
,
span
:
span
<
defaultSpan
&&
span
>
0
?
span
:
defaultSpan
,
editable
:
true
,
type
:
panelPluginInfo
.
id
,
isNew
:
true
,
...
...
public/app/features/dashboard/row/row_ctrl.ts
View file @
18056e53
...
...
@@ -198,7 +198,7 @@ coreModule.directive('panelDropZone', function($timeout) {
return
showPanel
(
12
,
'Empty Space'
);
}
var
dropZoneSpan
=
12
-
scope
.
ctrl
.
dashboard
.
rowSpan
(
scope
.
ctrl
.
row
)
;
var
dropZoneSpan
=
12
-
row
.
span
;
if
(
dropZoneSpan
>
0
)
{
if
(
indrag
)
{
return
showPanel
(
dropZoneSpan
,
'Drop Here'
);
...
...
@@ -209,7 +209,7 @@ coreModule.directive('panelDropZone', function($timeout) {
}
if
(
indrag
===
true
)
{
var
dropZoneSpan
=
12
-
scope
.
ctrl
.
dashboard
.
rowSpan
(
scope
.
ctrl
.
row
)
;
var
dropZoneSpan
=
12
-
row
.
span
;
if
(
dropZoneSpan
>
1
)
{
return
showPanel
(
dropZoneSpan
,
'Drop Here'
);
}
...
...
public/app/features/dashboard/specs/dashboard_srv_specs.ts
View file @
18056e53
...
...
@@ -51,18 +51,13 @@ describe('dashboardSrv', function() {
dashboard
=
_dashboardSrv
.
create
({});
});
it
(
'row span should sum spans'
,
function
()
{
var
spanLeft
=
dashboard
.
rowSpan
({
panels
:
[{
span
:
2
},
{
span
:
3
}]
});
expect
(
spanLeft
).
to
.
be
(
5
);
});
it
(
'adding default should split span in half'
,
function
()
{
dashboard
.
rows
=
[{
panels
:
[{
span
:
12
,
id
:
7
}]
}];
dashboard
.
addPanel
({
span
:
4
},
dashboard
.
rows
[
0
]);
dashboard
.
addEmptyRow
();
dashboard
.
rows
[
0
].
addPanel
({
span
:
12
});
dashboard
.
rows
[
0
].
addPanel
({
span
:
12
});
expect
(
dashboard
.
rows
[
0
].
panels
[
0
].
span
).
to
.
be
(
6
);
expect
(
dashboard
.
rows
[
0
].
panels
[
1
].
span
).
to
.
be
(
6
);
expect
(
dashboard
.
rows
[
0
].
panels
[
1
].
id
).
to
.
be
(
8
);
});
it
(
'duplicate panel should try to add it to same row'
,
function
()
{
...
...
public/app/features/dashboard/specs/exporter_specs.ts
View file @
18056e53
...
...
@@ -3,6 +3,7 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co
import
_
from
'lodash'
;
import
config
from
'app/core/config'
;
import
{
DashboardExporter
}
from
'../export/exporter'
;
import
{
DashboardModel
}
from
'../model'
;
describe
(
'given dashboard with repeated panels'
,
function
()
{
var
dash
,
exported
;
...
...
@@ -77,6 +78,7 @@ describe('given dashboard with repeated panels', function() {
info
:
{
version
:
"1.1.0"
}
};
dash
=
new
DashboardModel
(
dash
,
{});
var
exporter
=
new
DashboardExporter
(
datasourceSrvStub
);
exporter
.
makeExportable
(
dash
).
then
(
clean
=>
{
exported
=
clean
;
...
...
public/app/features/dashboard/specs/row_model_specs.ts
0 → 100644
View file @
18056e53
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
_
from
'lodash'
;
import
{
DashboardRow
}
from
'../row/row_model'
;
describe
(
'DashboardRow'
,
function
()
{
});
public/app/features/dashboard/unsavedChangesSrv.js
View file @
18056e53
...
...
@@ -9,7 +9,7 @@ function(angular, _) {
module
.
service
(
'unsavedChangesSrv'
,
function
(
$rootScope
,
$q
,
$location
,
$timeout
,
contextSrv
,
$window
)
{
function
Tracker
(
dashboard
,
scope
)
{
function
Tracker
(
dashboard
,
scope
,
originalCopyDelay
)
{
var
self
=
this
;
this
.
current
=
dashboard
;
...
...
@@ -44,10 +44,14 @@ function(angular, _) {
}
});
// wait for different services to patch the dashboard (missing properties)
$timeout
(
function
()
{
if
(
originalCopyDelay
)
{
$timeout
(
function
()
{
// wait for different services to patch the dashboard (missing properties)
self
.
original
=
dashboard
.
getSaveModelClone
();
},
originalCopyDelay
);
}
else
{
self
.
original
=
dashboard
.
getSaveModelClone
();
}
,
1000
);
}
}
var
p
=
Tracker
.
prototype
;
...
...
@@ -157,7 +161,7 @@ function(angular, _) {
this
.
Tracker
=
Tracker
;
this
.
init
=
function
(
dashboard
,
scope
)
{
new
Tracker
(
dashboard
,
scope
);
return
new
Tracker
(
dashboard
,
scope
,
1000
);
};
});
});
public/app/features/panel/panel_directive.ts
View file @
18056e53
...
...
@@ -143,7 +143,8 @@ module.directive('panelResizer', function($rootScope) {
ctrl
.
panel
.
span
=
originalWidth
+
(((
e
.
pageX
-
handleOffset
.
left
)
/
maxWidth
)
*
12
);
ctrl
.
panel
.
span
=
Math
.
min
(
Math
.
max
(
ctrl
.
panel
.
span
,
1
),
12
);
var
rowSpan
=
ctrl
.
dashboard
.
rowSpan
(
ctrl
.
row
);
ctrl
.
row
.
updateRowSpan
();
var
rowSpan
=
ctrl
.
row
.
span
;
// auto adjust other panels
if
(
Math
.
floor
(
rowSpan
)
<
14
)
{
...
...
@@ -170,12 +171,6 @@ module.directive('panelResizer', function($rootScope) {
lastPanel
.
span
=
Math
.
round
(
lastPanel
.
span
);
}
// if close to 12
var
rowSpan
=
ctrl
.
dashboard
.
rowSpan
(
ctrl
.
row
);
if
(
rowSpan
<
12
&&
rowSpan
>
11
)
{
lastPanel
.
span
+=
12
-
rowSpan
;
}
ctrl
.
row
.
panelSpanChanged
();
// first digest to propagate panel width change
...
...
public/test/specs/row-ctrl-specs.js
deleted
100644 → 0
View file @
786afda4
define
([
'./helpers'
,
'app/features/dashboard/rowCtrl'
],
function
(
helpers
)
{
'use strict'
;
describe
(
'RowCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
beforeEach
(
module
(
'grafana.controllers'
));
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
createControllerPhase
(
'RowCtrl'
));
describe
(
'delete_row'
,
function
()
{
describe
(
'when row is empty (has no panels)'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
dashboard
.
rows
=
[{
id
:
1
,
panels
:
[]}];
ctx
.
scope
.
row
=
ctx
.
scope
.
dashboard
.
rows
[
0
];
ctx
.
scope
.
appEvent
=
sinon
.
spy
();
ctx
.
scope
.
deleteRow
();
});
it
(
'should NOT ask for confirmation'
,
function
()
{
expect
(
ctx
.
scope
.
appEvent
.
called
).
to
.
be
(
false
);
});
it
(
'should delete row'
,
function
()
{
expect
(
ctx
.
scope
.
dashboard
.
rows
).
to
.
not
.
contain
(
ctx
.
scope
.
row
);
});
});
});
});
});
public/test/specs/unsavedChangesSrv-specs.js
View file @
18056e53
...
...
@@ -77,7 +77,8 @@ define([
});
it
(
'Should ignore row repeats'
,
function
()
{
dash
.
rows
.
push
({
repeatRowId
:
10
});
dash
.
addEmptyRow
();
dash
.
rows
[
1
].
repeatRowId
=
10
;
expect
(
tracker
.
hasChanges
()).
to
.
be
(
false
);
});
...
...
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