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
b5112aee
Commit
b5112aee
authored
Apr 07, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Data source proxy, and session timeout fix for influxdb, #1667
parent
22adf0d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
78 deletions
+8
-78
public/app/plugins/datasource/elasticsearch/datasource.js
+2
-2
public/app/plugins/datasource/influxdb_08/datasource.js
+3
-75
public/test/specs/influxdb-datasource-specs.js
+3
-1
No files found.
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
b5112aee
...
...
@@ -10,7 +10,7 @@ function (angular, _, config, kbn, moment) {
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'ElasticDatasource'
,
function
(
$q
,
$http
,
templateSrv
)
{
module
.
factory
(
'ElasticDatasource'
,
function
(
$q
,
backendSrv
,
templateSrv
)
{
function
ElasticDatasource
(
datasource
)
{
this
.
type
=
'elasticsearch'
;
...
...
@@ -38,7 +38,7 @@ function (angular, _, config, kbn, moment) {
};
}
return
$http
(
options
);
return
backendSrv
.
datasourceRequest
(
options
);
};
ElasticDatasource
.
prototype
.
_get
=
function
(
url
)
{
...
...
public/app/plugins/datasource/influxdb_08/datasource.js
View file @
b5112aee
...
...
@@ -12,7 +12,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'InfluxDatasource_08'
,
function
(
$q
,
$http
,
templateSrv
)
{
module
.
factory
(
'InfluxDatasource_08'
,
function
(
$q
,
backendSrv
,
templateSrv
)
{
function
InfluxDatasource
(
datasource
)
{
this
.
urls
=
_
.
map
(
datasource
.
url
.
split
(
','
),
function
(
url
)
{
...
...
@@ -172,86 +172,14 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
options
.
headers
.
Authorization
=
'Basic '
+
_this
.
basicAuth
;
}
return
$http
(
options
).
success
(
function
(
data
)
{
deferred
.
resolve
(
data
);
return
backendSrv
.
datasourceRequest
(
options
).
then
(
function
(
response
)
{
deferred
.
resolve
(
response
.
data
);
});
},
10
);
return
deferred
.
promise
;
};
InfluxDatasource
.
prototype
.
saveDashboard
=
function
(
dashboard
)
{
var
tags
=
dashboard
.
tags
.
join
(
','
);
var
title
=
dashboard
.
title
;
var
temp
=
dashboard
.
temp
;
var
id
=
kbn
.
slugifyForUrl
(
title
);
if
(
temp
)
{
delete
dashboard
.
temp
;
}
var
data
=
[{
name
:
'grafana.dashboard_'
+
btoa
(
id
),
columns
:
[
'time'
,
'sequence_number'
,
'title'
,
'tags'
,
'dashboard'
,
'id'
],
points
:
[[
1000000000000
,
1
,
title
,
tags
,
angular
.
toJson
(
dashboard
),
id
]]
}];
if
(
temp
)
{
return
this
.
_saveDashboardTemp
(
data
,
title
,
id
);
}
else
{
var
self
=
this
;
return
this
.
_influxRequest
(
'POST'
,
'/series'
,
data
).
then
(
function
()
{
self
.
_removeUnslugifiedDashboard
(
id
,
title
,
false
);
return
{
title
:
title
,
url
:
'/dashboard/db/'
+
id
};
},
function
(
err
)
{
throw
'Failed to save dashboard to InfluxDB: '
+
err
.
data
;
});
}
};
InfluxDatasource
.
prototype
.
_removeUnslugifiedDashboard
=
function
(
id
,
title
,
isTemp
)
{
if
(
id
===
title
)
{
return
;
}
var
self
=
this
;
self
.
_getDashboardInternal
(
title
,
isTemp
).
then
(
function
(
dashboard
)
{
if
(
dashboard
!==
null
)
{
self
.
deleteDashboard
(
title
);
}
});
};
InfluxDatasource
.
prototype
.
_saveDashboardTemp
=
function
(
data
,
title
,
id
)
{
data
[
0
].
name
=
'grafana.temp_dashboard_'
+
btoa
(
id
);
data
[
0
].
columns
.
push
(
'expires'
);
data
[
0
].
points
[
0
].
push
(
this
.
_getTempDashboardExpiresDate
());
return
this
.
_influxRequest
(
'POST'
,
'/series'
,
data
).
then
(
function
()
{
var
baseUrl
=
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
''
);
var
url
=
baseUrl
+
"#dashboard/temp/"
+
id
;
return
{
title
:
title
,
url
:
url
};
},
function
(
err
)
{
throw
'Failed to save shared dashboard to InfluxDB: '
+
err
.
data
;
});
};
InfluxDatasource
.
prototype
.
_getTempDashboardExpiresDate
=
function
()
{
var
ttlLength
=
this
.
saveTempTTL
.
substring
(
0
,
this
.
saveTempTTL
.
length
-
1
);
var
ttlTerm
=
this
.
saveTempTTL
.
substring
(
this
.
saveTempTTL
.
length
-
1
,
this
.
saveTempTTL
.
length
).
toLowerCase
();
var
expires
=
Date
.
now
();
switch
(
ttlTerm
)
{
case
"m"
:
expires
+=
ttlLength
*
60000
;
break
;
case
"d"
:
expires
+=
ttlLength
*
86400000
;
break
;
case
"w"
:
expires
+=
ttlLength
*
604800000
;
break
;
default
:
throw
"Unknown ttl duration format"
;
}
return
expires
;
};
InfluxDatasource
.
prototype
.
_getDashboardInternal
=
function
(
id
,
isTemp
)
{
var
queryString
=
'select dashboard from "grafana.dashboard_'
+
btoa
(
id
)
+
'"'
;
...
...
public/test/specs/influxdb-datasource-specs.js
View file @
b5112aee
define
([
'helpers'
,
'plugins/datasource/influxdb_08/datasource'
'plugins/datasource/influxdb_08/datasource'
,
'services/backendSrv'
,
'services/alertSrv'
],
function
(
helpers
)
{
'use strict'
;
...
...
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