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
de1de852
Commit
de1de852
authored
Oct 01, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
worked on solo panel
parent
c34d2f91
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
14 deletions
+89
-14
src/app/partials/pro/solo-panel.html
+1
-1
src/app/routes/p_all.js
+1
-1
src/app/routes/pro/solo-panel.js
+22
-11
src/test/specs/SoloPanelCtrl-specs.js
+0
-0
src/test/specs/helpers.js
+6
-1
src/test/specs/pro/soloPanelCtrl-specs.js
+57
-0
src/test/test-main.js
+2
-0
No files found.
src/app/partials/pro/solo-panel.html
View file @
de1de852
<div
class=
"container-fluid main"
>
<div
class=
"row-fluid"
>
<div
class=
"span12"
>
<div
class=
"panel nospace"
ng-if=
"panel"
style=
"
display:block;
"
>
<div
class=
"panel nospace"
ng-if=
"panel"
style=
"
width: 100%
"
>
<grafana-panel
type=
"panel.type"
ng-cloak
></kibana-panel>
</div>
</div>
...
...
src/app/routes/p_all.js
View file @
de1de852
define
([
'./p_dashboard'
,
'./p
_
solo-panel'
,
'./p
ro/
solo-panel'
,
'./p_admin'
,
'./p_login'
,
],
...
...
src/app/routes/p
_
solo-panel.js
→
src/app/routes/p
ro/
solo-panel.js
View file @
de1de852
...
...
@@ -14,17 +14,20 @@ function (angular) {
});
});
module
.
controller
(
'SoloPanelCtrl'
,
function
(
$scope
,
$rootScope
,
datasourceSrv
,
$routeParams
,
alertSrv
,
dashboardSrv
,
filterSrv
)
{
module
.
controller
(
'SoloPanelCtrl'
,
function
(
$scope
,
$rootScope
,
datasourceSrv
,
$routeParams
,
dashboardSrv
,
timeSrv
)
{
var
panelId
;
var
db
=
datasourceSrv
.
getGrafanaDB
();
var
panelId
=
parseInt
(
$routeParams
.
panelId
);
$scope
.
init
=
function
()
{
var
db
=
datasourceSrv
.
getGrafanaDB
();
panelId
=
parseInt
(
$routeParams
.
panelId
);
db
.
getDashboard
(
$routeParams
.
id
,
false
)
.
then
(
function
(
dashboardData
)
{
$scope
.
initPanelScope
(
dashboardData
);
}).
then
(
null
,
function
(
error
)
{
alertSrv
.
set
(
'Error'
,
error
,
'error'
);
});
db
.
getDashboard
(
$routeParams
.
id
,
false
)
.
then
(
function
(
dashboardData
)
{
$scope
.
initPanelScope
(
dashboardData
);
}).
then
(
null
,
function
(
error
)
{
$scope
.
appEvent
(
'alert-error'
,
[
'Load panel error'
,
error
]);
});
};
$scope
.
initPanelScope
=
function
(
dashboardData
)
{
$scope
.
dashboard
=
dashboardSrv
.
create
(
dashboardData
);
...
...
@@ -36,14 +39,18 @@ function (angular) {
$scope
.
$index
=
0
;
$scope
.
panel
=
$scope
.
getPanelById
(
panelId
);
if
(
!
$scope
.
panel
)
{
$scope
.
appEvent
(
'alert-error'
,
[
'Panel not found'
,
''
]);
return
;
}
$scope
.
panel
.
span
=
12
;
$scope
.
dashboardViewState
=
{
registerPanel
:
function
()
{
}
};
$scope
.
filter
=
filterSrv
;
$scope
.
filter
.
init
(
$scope
.
dashboard
);
timeSrv
.
init
(
$scope
.
dashboard
);
};
$scope
.
getPanelById
=
function
(
id
)
{
...
...
@@ -60,6 +67,10 @@ function (angular) {
return
null
;
};
if
(
!
$scope
.
skipAutoInit
)
{
$scope
.
init
();
}
});
});
src/test/specs/SoloPanelCtrl-specs.js
0 → 100644
View file @
de1de852
src/test/specs/helpers.js
View file @
de1de852
...
...
@@ -24,7 +24,7 @@ define([
$provide
.
value
(
'timeSrv'
,
self
.
timeSrv
);
$provide
.
value
(
'templateSrv'
,
self
.
templateSrv
);
$provide
.
value
(
'$element'
,
self
.
$element
);
_
.
each
(
mocks
,
function
(
key
,
value
)
{
_
.
each
(
mocks
,
function
(
value
,
key
)
{
$provide
.
value
(
key
,
value
);
});
});
...
...
@@ -34,16 +34,20 @@ define([
return
inject
(
function
(
$controller
,
$rootScope
,
$q
,
$location
)
{
self
.
scope
=
$rootScope
.
$new
();
self
.
$location
=
$location
;
self
.
scope
.
grafana
=
{};
self
.
scope
.
panel
=
{};
self
.
scope
.
row
=
{
panels
:[]
};
self
.
scope
.
dashboard
=
{};
self
.
scope
.
dashboardViewState
=
new
DashboardViewStateStub
();
self
.
scope
.
appEvent
=
sinon
.
spy
();
self
.
scope
.
onAppEvent
=
sinon
.
spy
();
$rootScope
.
colors
=
[];
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
self
.
$q
=
$q
;
self
.
scope
.
skipDataOnInit
=
true
;
self
.
scope
.
skipAutoInit
=
true
;
self
.
controller
=
$controller
(
controllerName
,
{
$scope
:
self
.
scope
});
...
...
@@ -87,6 +91,7 @@ define([
}
function
TimeSrvStub
()
{
this
.
init
=
sinon
.
spy
();
this
.
time
=
{
from
:
'now-1h'
,
to
:
'now'
};
this
.
timeRange
=
function
(
parse
)
{
if
(
parse
===
false
)
{
...
...
src/test/specs/pro/soloPanelCtrl-specs.js
0 → 100644
View file @
de1de852
define
([
'../helpers'
,
'routes/pro/solo-panel'
,
'services/dashboard/dashboardSrv'
,
],
function
(
helpers
)
{
'use strict'
;
describe
(
'SoloPanelCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
var
datasource
=
{};
var
routeParams
=
{};
beforeEach
(
module
(
'grafana.routes'
));
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
({
$routeParams
:
routeParams
,
datasourceSrv
:
{
getGrafanaDB
:
sinon
.
stub
().
returns
(
datasource
)
}
}));
beforeEach
(
ctx
.
createControllerPhase
(
'SoloPanelCtrl'
));
describe
(
'setting up solo panel scope'
,
function
()
{
beforeEach
(
function
()
{
var
dashboard
=
{
rows
:
[
{
panels
:
[
{
id
:
23
,
some
:
'prop'
}
]
}
]
};
routeParams
.
id
=
1
;
routeParams
.
panelId
=
23
;
datasource
.
getDashboard
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
(
dashboard
));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
});
it
(
'should load dashboard and extract panel and setup panel scope'
,
function
()
{
expect
(
ctx
.
scope
.
panel
.
id
).
to
.
be
(
23
);
expect
(
ctx
.
scope
.
panel
.
some
).
to
.
be
(
'prop'
);
});
});
});
});
src/test/test-main.js
View file @
de1de852
...
...
@@ -114,6 +114,7 @@ require([
angular
.
module
(
'grafana'
,
[
'ngRoute'
]);
angular
.
module
(
'grafana.services'
,
[
'ngRoute'
,
'$strap.directives'
]);
angular
.
module
(
'grafana.panels'
,
[]);
angular
.
module
(
'grafana.routes'
,
[
'ngRoute'
]);
angular
.
module
(
'grafana.filters'
,
[]);
require
([
...
...
@@ -140,6 +141,7 @@ require([
'specs/dashboardSrv-specs'
,
'specs/dashboardViewStateSrv-specs'
,
'specs/overview-ctrl-specs'
,
'specs/pro/soloPanelCtrl-specs'
,
],
function
()
{
window
.
__karma__
.
start
();
});
...
...
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