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
ed491b0c
Commit
ed491b0c
authored
Aug 01, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jordanrinke/grafana into jordanrinke-master
parents
d6814587
48c18ee8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
.gitignore
+1
-0
src/app/dashboards/default.json
+1
-1
src/app/services/influxdb/influxdbDatasource.js
+48
-1
No files found.
.gitignore
View file @
ed491b0c
...
...
@@ -9,3 +9,4 @@ config.js
# Editor junk
*.sublime-workspace
*.swp
.idea/
src/app/dashboards/default.json
View file @
ed491b0c
...
...
@@ -137,7 +137,7 @@
"loader"
:
{
"save_temp"
:
true
,
"save_temp_ttl_enable"
:
true
,
"save_temp_ttl"
:
"30d"
,
"save_temp_ttl"
:
"30d"
},
"refresh"
:
false
}
src/app/services/influxdb/influxdbDatasource.js
View file @
ed491b0c
...
...
@@ -249,11 +249,58 @@ function (angular, _, kbn, InfluxSeries) {
});
};
InfluxDatasource
.
prototype
.
saveDashboardTemp
=
function
(
dashboard
,
title
)
{
var
dashboardClone
=
angular
.
copy
(
dashboard
);
var
tags
=
dashboardClone
.
tags
.
join
(
','
);
title
=
dashboardClone
.
title
=
title
?
title
:
dashboard
.
title
;
var
ttl
=
dashboard
.
loader
.
save_temp_ttl
;
var
ttlLength
=
ttl
.
substring
(
0
,
ttl
.
length
-
1
);
var
ttlTerm
=
ttl
.
substring
(
ttl
.
length
-
1
,
ttl
.
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"
;
}
var
data
=
[{
name
:
'grafana.dashboard_'
+
btoa
(
title
),
columns
:
[
'time'
,
'sequence_number'
,
'title'
,
'tags'
,
'dashboard'
,
'expires'
],
points
:
[[
1
,
1
,
title
,
tags
,
angular
.
toJson
(
dashboardClone
),
expires
]]
}];
return
this
.
_influxRequest
(
'POST'
,
'/series'
,
data
).
then
(
function
()
{
var
baseUrl
=
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
''
);
var
url
=
baseUrl
+
"#dashboard/temp/"
+
title
;
return
{
title
:
title
,
url
:
url
};
},
function
(
err
)
{
throw
'Failed to save shared dashboard to InfluxDB: '
+
err
.
data
;
});
};
InfluxDatasource
.
prototype
.
getDashboard
=
function
(
id
)
{
return
this
.
_seriesQuery
(
'select dashboard from "grafana.dashboard_'
+
btoa
(
id
)
+
'"'
).
then
(
function
(
results
)
{
var
queryString
=
'select dashboard from "grafana.dashboard_'
+
btoa
(
id
)
+
'"'
;
// hack to check if it is a temp dashboard
if
(
window
.
location
.
href
.
indexOf
(
'dashboard/temp'
)
>
0
)
{
var
isTemp
=
true
;
queryString
=
'select dashboard, expires from "grafana.dashboard_'
+
btoa
(
id
)
+
'"'
;
}
return
this
.
_seriesQuery
(
queryString
).
then
(
function
(
results
)
{
if
(
!
results
||
!
results
.
length
)
{
throw
"Dashboard not found"
;
}
var
expiresCol
=
_
.
indexOf
(
results
[
0
].
columns
,
'expires'
);
var
expiresTime
=
results
[
0
].
points
[
0
][
expiresCol
];
if
(
Date
.
now
()
>
expiresTime
&&
isTemp
)
{
throw
"Dashboard has expired"
;
}
var
dashCol
=
_
.
indexOf
(
results
[
0
].
columns
,
'dashboard'
);
var
dashJson
=
results
[
0
].
points
[
0
][
dashCol
];
return
angular
.
fromJson
(
dashJson
);
...
...
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