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
2d128011
Commit
2d128011
authored
Aug 15, 2018
by
Sven Klemm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
detect postgres version for saved datasources
parent
2606f6e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
19 deletions
+55
-19
public/app/plugins/datasource/postgres/config_ctrl.ts
+50
-0
public/app/plugins/datasource/postgres/datasource.ts
+4
-0
public/app/plugins/datasource/postgres/module.ts
+1
-19
No files found.
public/app/plugins/datasource/postgres/config_ctrl.ts
0 → 100644
View file @
2d128011
import
_
from
'lodash'
;
export
class
PostgresConfigCtrl
{
static
templateUrl
=
'partials/config.html'
;
current
:
any
;
datasourceSrv
:
any
;
/** @ngInject **/
constructor
(
$scope
,
datasourceSrv
)
{
this
.
datasourceSrv
=
datasourceSrv
;
this
.
current
.
jsonData
.
sslmode
=
this
.
current
.
jsonData
.
sslmode
||
'verify-full'
;
this
.
current
.
jsonData
.
postgresVersion
=
this
.
current
.
jsonData
.
postgresVersion
||
903
;
this
.
autoDetectPostgresVersion
();
}
autoDetectPostgresVersion
()
{
if
(
!
this
.
current
.
id
)
{
return
;
}
this
.
datasourceSrv
.
loadDatasource
(
this
.
current
.
name
)
.
then
(
ds
=>
{
return
ds
.
getVersion
();
})
.
then
(
version
=>
{
version
=
Number
(
version
[
0
].
text
);
let
major
=
Math
.
trunc
(
version
/
100
);
let
minor
=
version
%
100
;
let
name
=
String
(
major
);
if
(
version
<
1000
)
{
name
=
String
(
major
)
+
'.'
+
String
(
minor
);
}
if
(
!
_
.
find
(
this
.
postgresVersions
,
(
p
:
any
)
=>
p
.
value
===
version
))
{
this
.
postgresVersions
.
push
({
name
:
name
,
value
:
version
});
}
this
.
current
.
jsonData
.
postgresVersion
=
version
;
});
}
// the value portion is derived from postgres server_version_num/100
postgresVersions
=
[
{
name
:
'9.3'
,
value
:
903
},
{
name
:
'9.4'
,
value
:
904
},
{
name
:
'9.5'
,
value
:
905
},
{
name
:
'9.6'
,
value
:
906
},
{
name
:
'10'
,
value
:
1000
},
];
}
public/app/plugins/datasource/postgres/datasource.ts
View file @
2d128011
...
...
@@ -124,6 +124,10 @@ export class PostgresDatasource {
.
then
(
data
=>
this
.
responseParser
.
parseMetricFindQueryResult
(
refId
,
data
));
}
getVersion
()
{
return
this
.
metricFindQuery
(
"SELECT current_setting('server_version_num')::int/100"
,
{});
}
testDatasource
()
{
return
this
.
metricFindQuery
(
'SELECT 1'
,
{})
.
then
(
res
=>
{
...
...
public/app/plugins/datasource/postgres/module.ts
View file @
2d128011
import
{
PostgresDatasource
}
from
'./datasource'
;
import
{
PostgresQueryCtrl
}
from
'./query_ctrl'
;
class
PostgresConfigCtrl
{
static
templateUrl
=
'partials/config.html'
;
current
:
any
;
/** @ngInject **/
constructor
(
$scope
)
{
this
.
current
.
jsonData
.
sslmode
=
this
.
current
.
jsonData
.
sslmode
||
'verify-full'
;
}
// the value portion is derived from postgres server_version_num/100
postgresVersions
=
[
{
name
:
'9.3.x'
,
value
:
903
},
{
name
:
'9.4.x'
,
value
:
904
},
{
name
:
'9.5.x'
,
value
:
905
},
{
name
:
'9.6.x'
,
value
:
906
},
];
}
import
{
PostgresConfigCtrl
}
from
'./config_ctrl'
;
const
defaultQuery
=
`SELECT
extract(epoch from time_column) AS time,
...
...
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