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
6114f63d
Commit
6114f63d
authored
Oct 20, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graphite: auto detect version
parent
89aea278
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
public/app/core/utils/version.ts
+7
-1
public/app/plugins/datasource/graphite/config_ctrl.ts
+15
-1
public/app/plugins/datasource/graphite/datasource.ts
+18
-1
No files found.
public/app/core/utils/version.ts
View file @
6114f63d
const
versionPattern
=
/
(\d
+
)(?:\.(\d
+
))?(?:\.(\d
+
))?(?:
-
([
0-9A-Za-z
\.]
+
))?
/
;
import
_
from
'lodash'
;
const
versionPattern
=
/^
(\d
+
)(?:\.(\d
+
))?(?:\.(\d
+
))?(?:
-
([
0-9A-Za-z
\.]
+
))?
/
;
export
class
SemVersion
{
major
:
number
;
...
...
@@ -20,6 +22,10 @@ export class SemVersion {
let
compared
=
new
SemVersion
(
version
);
return
!
(
this
.
major
<
compared
.
major
||
this
.
minor
<
compared
.
minor
||
this
.
patch
<
compared
.
patch
);
}
isValid
():
boolean
{
return
_
.
isNumber
(
this
.
major
);
}
}
export
function
isVersionGtOrEq
(
a
:
string
,
b
:
string
):
boolean
{
...
...
public/app/plugins/datasource/graphite/config_ctrl.ts
View file @
6114f63d
...
...
@@ -2,12 +2,26 @@
export
class
GraphiteConfigCtrl
{
static
templateUrl
=
'public/app/plugins/datasource/graphite/partials/config.html'
;
datasourceSrv
:
any
;
current
:
any
;
/** @ngInject */
constructor
(
$scope
)
{
constructor
(
$scope
,
datasourceSrv
)
{
this
.
datasourceSrv
=
datasourceSrv
;
this
.
current
.
jsonData
=
this
.
current
.
jsonData
||
{};
this
.
current
.
jsonData
.
graphiteVersion
=
this
.
current
.
jsonData
.
graphiteVersion
||
'0.9'
;
this
.
autoDetectGraphiteVersion
();
}
autoDetectGraphiteVersion
()
{
this
.
datasourceSrv
.
loadDatasource
(
this
.
current
.
name
)
.
then
((
ds
)
=>
{
return
ds
.
getVersion
();
}).
then
((
version
)
=>
{
this
.
graphiteVersions
.
push
({
name
:
version
,
value
:
version
});
this
.
current
.
jsonData
.
graphiteVersion
=
version
;
});
}
graphiteVersions
=
[
...
...
public/app/plugins/datasource/graphite/datasource.ts
View file @
6114f63d
...
...
@@ -2,7 +2,7 @@
import
_
from
'lodash'
;
import
*
as
dateMath
from
'app/core/utils/datemath'
;
import
{
isVersionGtOrEq
}
from
'app/core/utils/version'
;
import
{
isVersionGtOrEq
,
SemVersion
}
from
'app/core/utils/version'
;
/** @ngInject */
export
function
GraphiteDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
...
...
@@ -273,6 +273,23 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
});
};
this
.
getVersion
=
function
()
{
let
httpOptions
=
{
method
:
'GET'
,
url
:
'/version/_'
,
// Prevent last / trimming
};
return
this
.
doGraphiteRequest
(
httpOptions
).
then
(
results
=>
{
if
(
results
.
data
)
{
let
semver
=
new
SemVersion
(
results
.
data
);
return
semver
.
isValid
()
?
results
.
data
:
''
;
}
return
''
;
}).
catch
(()
=>
{
return
''
;
});
};
this
.
testDatasource
=
function
()
{
return
this
.
metricFindQuery
(
'*'
).
then
(
function
()
{
return
{
status
:
"success"
,
message
:
"Data source is working"
};
...
...
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