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
605888bb
Commit
605888bb
authored
Feb 25, 2014
by
Torkel Odegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished refactoring of GraphiteDatasource to angular service and fixed jshint errors
parent
ef69d692
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
src/app/services/datasourceSrv.js
+2
-2
src/app/services/graphite/graphiteDatasource.js
+8
-11
No files found.
src/app/services/datasourceSrv.js
View file @
605888bb
...
@@ -12,14 +12,14 @@ function (angular, _, config) {
...
@@ -12,14 +12,14 @@ function (angular, _, config) {
var
defaultDatasource
=
_
.
findWhere
(
_
.
values
(
config
.
datasources
),
{
default
:
true
}
);
var
defaultDatasource
=
_
.
findWhere
(
_
.
values
(
config
.
datasources
),
{
default
:
true
}
);
this
.
default
=
new
GraphiteDatasource
(
defaultDatasource
,
$q
,
filterSrv
,
$http
);
this
.
default
=
new
GraphiteDatasource
(
defaultDatasource
);
this
.
get
=
function
(
name
)
{
this
.
get
=
function
(
name
)
{
if
(
!
name
)
{
if
(
!
name
)
{
return
this
.
default
;
return
this
.
default
;
}
}
return
new
GraphiteDatasource
(
config
.
datasources
[
name
]
,
$q
,
filterSrv
,
$http
);
return
new
GraphiteDatasource
(
config
.
datasources
[
name
]);
};
};
this
.
listOptions
=
function
()
{
this
.
listOptions
=
function
()
{
...
...
src/app/services/graphite/graphiteDatasource.js
View file @
605888bb
...
@@ -13,13 +13,10 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -13,13 +13,10 @@ function (angular, _, $, config, kbn, moment) {
module
.
factory
(
'GraphiteDatasource'
,
function
(
dashboard
,
$q
,
filterSrv
,
$http
)
{
module
.
factory
(
'GraphiteDatasource'
,
function
(
dashboard
,
$q
,
filterSrv
,
$http
)
{
function
GraphiteDatasource
(
datasource
,
$q
,
filterSrv
,
$http
)
{
function
GraphiteDatasource
(
datasource
)
{
this
.
url
=
datasource
.
url
;
this
.
url
=
datasource
.
url
;
this
.
type
=
'graphite'
;
this
.
type
=
'graphite'
;
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
$q
=
$q
;
this
.
filterSrv
=
filterSrv
;
this
.
$http
=
$http
;
}
}
GraphiteDatasource
.
prototype
.
query
=
function
(
options
)
{
GraphiteDatasource
.
prototype
.
query
=
function
(
options
)
{
...
@@ -35,7 +32,7 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -35,7 +32,7 @@ function (angular, _, $, config, kbn, moment) {
var
params
=
this
.
buildGraphiteParams
(
graphOptions
);
var
params
=
this
.
buildGraphiteParams
(
graphOptions
);
if
(
options
.
format
===
'png'
)
{
if
(
options
.
format
===
'png'
)
{
return
this
.
$q
.
when
(
this
.
url
+
'/render'
+
'?'
+
params
.
join
(
'&'
));
return
$q
.
when
(
this
.
url
+
'/render'
+
'?'
+
params
.
join
(
'&'
));
}
}
return
this
.
doGraphiteRequest
({
return
this
.
doGraphiteRequest
({
...
@@ -48,7 +45,7 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -48,7 +45,7 @@ function (angular, _, $, config, kbn, moment) {
});
});
}
}
catch
(
err
)
{
catch
(
err
)
{
return
this
.
$q
.
reject
(
err
);
return
$q
.
reject
(
err
);
}
}
};
};
...
@@ -65,7 +62,7 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -65,7 +62,7 @@ function (angular, _, $, config, kbn, moment) {
});
});
}
}
catch
(
err
)
{
catch
(
err
)
{
return
this
.
$q
.
reject
(
err
);
return
$q
.
reject
(
err
);
}
}
};
};
...
@@ -100,10 +97,10 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -100,10 +97,10 @@ function (angular, _, $, config, kbn, moment) {
GraphiteDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
GraphiteDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
var
interpolated
;
var
interpolated
;
try
{
try
{
interpolated
=
this
.
filterSrv
.
applyFilterToTarget
(
query
);
interpolated
=
filterSrv
.
applyFilterToTarget
(
query
);
}
}
catch
(
err
)
{
catch
(
err
)
{
return
this
.
$q
.
reject
(
err
);
return
$q
.
reject
(
err
);
}
}
return
this
.
doGraphiteRequest
({
method
:
'GET'
,
url
:
'/metrics/find/?query='
+
interpolated
})
return
this
.
doGraphiteRequest
({
method
:
'GET'
,
url
:
'/metrics/find/?query='
+
interpolated
})
...
@@ -137,7 +134,7 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -137,7 +134,7 @@ function (angular, _, $, config, kbn, moment) {
options
.
url
=
this
.
url
+
options
.
url
;
options
.
url
=
this
.
url
+
options
.
url
;
return
this
.
$http
(
options
);
return
$http
(
options
);
};
};
GraphiteDatasource
.
prototype
.
buildGraphiteParams
=
function
(
options
)
{
GraphiteDatasource
.
prototype
.
buildGraphiteParams
=
function
(
options
)
{
...
@@ -156,7 +153,7 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -156,7 +153,7 @@ function (angular, _, $, config, kbn, moment) {
if
(
key
===
"targets"
)
{
if
(
key
===
"targets"
)
{
_
.
each
(
value
,
function
(
value
)
{
_
.
each
(
value
,
function
(
value
)
{
if
(
!
value
.
hide
)
{
if
(
!
value
.
hide
)
{
var
targetValue
=
this
.
filterSrv
.
applyFilterToTarget
(
value
.
target
);
var
targetValue
=
filterSrv
.
applyFilterToTarget
(
value
.
target
);
clean_options
.
push
(
"target="
+
encodeURIComponent
(
targetValue
));
clean_options
.
push
(
"target="
+
encodeURIComponent
(
targetValue
));
}
}
},
this
);
},
this
);
...
...
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