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
e916f937
Commit
e916f937
authored
Aug 16, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(mixed datasource): fixed failing unit tests
parent
1332ddbc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
54 deletions
+11
-54
public/app/plugins/datasource/grafana/datasource.js
+6
-51
public/app/plugins/datasource/graphite/queryCtrl.js
+2
-0
public/app/plugins/datasource/influxdb/queryCtrl.js
+2
-0
public/test/specs/graphiteTargetCtrl-specs.js
+1
-3
No files found.
public/app/plugins/datasource/grafana/datasource.js
View file @
e916f937
...
...
@@ -8,68 +8,23 @@ function (angular, _, kbn) {
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'GrafanaDatasource'
,
function
(
$q
,
backendSrv
,
datasourceSrv
)
{
module
.
factory
(
'GrafanaDatasource'
,
function
(
$q
,
backendSrv
)
{
function
GrafanaDatasource
()
{
}
GrafanaDatasource
.
prototype
.
getDashboard
=
function
(
slug
,
isTemp
)
{
var
url
=
'/dashboards/'
+
slug
;
if
(
isTemp
)
{
url
=
'/temp/'
+
slug
;
}
return
backendSrv
.
get
(
'/api/dashboards/db/'
+
slug
);
};
GrafanaDatasource
.
prototype
.
query
=
function
(
options
)
{
return
datasourceSrv
.
get
(
options
.
targets
[
0
].
datasource
).
then
(
function
(
ds
)
{
options
.
targets
=
[
options
.
targets
[
0
]];
return
ds
.
query
(
options
);
});
// console.log(options.targets);
// // get from & to in seconds
// var from = kbn.parseDate(options.range.from).getTime();
// var to = kbn.parseDate(options.range.to).getTime();
//
// return backendSrv.get('/api/metrics/test', { from: from, to: to, maxDataPoints: options.maxDataPoints });
// get from & to in seconds
var
from
=
kbn
.
parseDate
(
options
.
range
.
from
).
getTime
();
var
to
=
kbn
.
parseDate
(
options
.
range
.
to
).
getTime
();
return
backendSrv
.
get
(
'/api/metrics/test'
,
{
from
:
from
,
to
:
to
,
maxDataPoints
:
options
.
maxDataPoints
});
};
GrafanaDatasource
.
prototype
.
metricFindQuery
=
function
()
{
return
$q
.
when
([]);
};
GrafanaDatasource
.
prototype
.
starDashboard
=
function
(
dashId
)
{
return
backendSrv
.
post
(
'/api/user/stars/dashboard/'
+
dashId
);
};
GrafanaDatasource
.
prototype
.
unstarDashboard
=
function
(
dashId
)
{
return
backendSrv
.
delete
(
'/api/user/stars/dashboard/'
+
dashId
);
};
GrafanaDatasource
.
prototype
.
saveDashboard
=
function
(
dashboard
)
{
return
backendSrv
.
post
(
'/api/dashboards/db/'
,
{
dashboard
:
dashboard
})
.
then
(
function
(
data
)
{
return
{
title
:
dashboard
.
title
,
url
:
'/dashboard/db/'
+
data
.
slug
};
},
function
(
err
)
{
err
.
isHandled
=
true
;
err
.
data
=
err
.
data
||
{};
throw
err
.
data
.
message
||
"Unknown error"
;
});
};
GrafanaDatasource
.
prototype
.
deleteDashboard
=
function
(
id
)
{
return
backendSrv
.
delete
(
'/api/dashboards/db/'
+
id
);
};
GrafanaDatasource
.
prototype
.
searchDashboards
=
function
(
query
)
{
return
backendSrv
.
get
(
'/api/search/'
,
query
)
.
then
(
function
(
data
)
{
return
data
;
});
};
return
GrafanaDatasource
;
});
...
...
public/app/plugins/datasource/graphite/queryCtrl.js
View file @
e916f937
...
...
@@ -26,8 +26,10 @@ function (angular, _, config, gfunc, Parser) {
module
.
controller
(
'GraphiteQueryCtrl'
,
function
(
$scope
,
$sce
,
templateSrv
)
{
$scope
.
init
=
function
()
{
if
(
$scope
.
target
)
{
$scope
.
target
.
target
=
$scope
.
target
.
target
||
''
;
parseTarget
();
}
};
$scope
.
toggleEditorMode
=
function
()
{
...
...
public/app/plugins/datasource/influxdb/queryCtrl.js
View file @
e916f937
...
...
@@ -24,6 +24,8 @@ function (angular, _, InfluxQueryBuilder) {
module
.
controller
(
'InfluxQueryCtrl'
,
function
(
$scope
,
$timeout
,
$sce
,
templateSrv
,
$q
)
{
$scope
.
init
=
function
()
{
if
(
!
$scope
.
target
)
{
return
;
}
var
target
=
$scope
.
target
;
target
.
tags
=
target
.
tags
||
[];
target
.
groupByTags
=
target
.
groupByTags
||
[];
...
...
public/test/specs/graphiteTargetCtrl-specs.js
View file @
e916f937
...
...
@@ -13,9 +13,7 @@ define([
beforeEach
(
ctx
.
createControllerPhase
(
'GraphiteQueryCtrl'
));
beforeEach
(
function
()
{
ctx
.
scope
.
target
=
{
target
:
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
};
ctx
.
scope
.
target
=
{
target
:
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
};
ctx
.
scope
.
datasource
=
ctx
.
datasource
;
ctx
.
scope
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
...
...
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