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
0a3d4a5a
Commit
0a3d4a5a
authored
Jun 10, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
elasticsearch saving does now work, still have to do ttl and temp dashboard
parent
2328c60d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
17 deletions
+67
-17
src/app/controllers/dashLoader.js
+13
-11
src/app/services/all.js
+2
-0
src/app/services/elasticsearch/es-client2.js
+46
-0
src/app/services/playlistSrv.js
+6
-6
No files found.
src/app/controllers/dashLoader.js
View file @
0a3d4a5a
...
@@ -8,7 +8,7 @@ function (angular, _, moment) {
...
@@ -8,7 +8,7 @@ function (angular, _, moment) {
var
module
=
angular
.
module
(
'kibana.controllers'
);
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'dashLoader'
,
function
(
$scope
,
$rootScope
,
$http
,
alertSrv
,
$location
,
playlistSrv
)
{
module
.
controller
(
'dashLoader'
,
function
(
$scope
,
$rootScope
,
$http
,
alertSrv
,
$location
,
playlistSrv
,
elastic
)
{
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
$scope
.
gist_pattern
=
/
(
^
\d{5,}
$
)
|
(
^
[
a-z0-9
]{10,}
$
)
|
(
gist.github.com
(\/
*.*
)\/[
a-z0-9
]{5,}\/
*$
)
/
;
$scope
.
gist_pattern
=
/
(
^
\d{5,}
$
)
|
(
^
[
a-z0-9
]{10,}
$
)
|
(
gist.github.com
(\/
*.*
)\/[
a-z0-9
]{5,}\/
*$
)
/
;
...
@@ -64,20 +64,22 @@ function (angular, _, moment) {
...
@@ -64,20 +64,22 @@ function (angular, _, moment) {
}
}
};
};
$scope
.
elasticsearch_save
=
function
(
type
,
ttl
)
{
$scope
.
elasticsearch_save
=
function
(
type
,
ttl
)
{
$scope
.
dashboard
.
elasticsearch_save
(
type
,
$scope
.
dashboard
.
title
,
ttl
)
elastic
.
saveDashboard
(
$scope
.
dashboard
,
$scope
.
dashboard
.
title
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
if
(
_
.
isUndefined
(
result
.
_id
))
{
alertSrv
.
set
(
'Dashboard Saved'
,
'Dashboard has been saved to Elasticsearch as "'
+
result
.
title
+
'"'
,
'success'
,
5000
);
alertSrv
.
set
(
'Save failed'
,
'Dashboard could not be saved to Elasticsearch'
,
'error'
,
5000
);
return
;
}
alertSrv
.
set
(
'Dashboard Saved'
,
'Dashboard has been saved to Elasticsearch as "'
+
result
.
_id
+
'"'
,
'success'
,
5000
);
if
(
type
===
'temp'
)
{
if
(
type
===
'temp'
)
{
$scope
.
share
=
$scope
.
dashboard
.
share_link
(
$scope
.
dashboard
.
title
,
'temp'
,
result
.
_id
);
$scope
.
share
=
$scope
.
dashboard
.
share_link
(
$scope
.
dashboard
.
title
,
'temp'
,
result
.
title
);
}
else
{
$location
.
path
(
result
.
url
);
}
}
$rootScope
.
$emit
(
'dashboard-saved'
,
$scope
.
dashboard
);
$rootScope
.
$emit
(
'dashboard-saved'
,
$scope
.
dashboard
);
},
function
(
err
)
{
alertSrv
.
set
(
'Save failed'
,
err
,
'error'
,
5000
);
});
});
};
};
...
@@ -150,11 +152,11 @@ function (angular, _, moment) {
...
@@ -150,11 +152,11 @@ function (angular, _, moment) {
};
};
$scope
.
openSaveDropdown
=
function
()
{
$scope
.
openSaveDropdown
=
function
()
{
$scope
.
isFavorite
=
playlistSrv
.
isCurrentFavorite
();
$scope
.
isFavorite
=
playlistSrv
.
isCurrentFavorite
(
$scope
.
dashboard
);
};
};
$scope
.
markAsFavorite
=
function
()
{
$scope
.
markAsFavorite
=
function
()
{
playlistSrv
.
markAsFavorite
();
playlistSrv
.
markAsFavorite
(
$scope
.
dashboard
);
$scope
.
isFavorite
=
true
;
$scope
.
isFavorite
=
true
;
};
};
...
...
src/app/services/all.js
View file @
0a3d4a5a
...
@@ -9,5 +9,6 @@ define([
...
@@ -9,5 +9,6 @@ define([
'./annotationsSrv'
,
'./annotationsSrv'
,
'./playlistSrv'
,
'./playlistSrv'
,
'./unsavedChangesSrv'
,
'./unsavedChangesSrv'
,
'./elasticsearch/es-client2'
,
],
],
function
()
{});
function
()
{});
\ No newline at end of file
src/app/services/elasticsearch/es-client2.js
0 → 100644
View file @
0a3d4a5a
define
([
'angular'
,
'config'
],
function
(
angular
,
config
)
{
"use strict"
;
var
module
=
angular
.
module
(
'kibana.services'
);
module
.
service
(
'elastic'
,
function
(
$http
)
{
this
.
put
=
function
(
url
,
data
)
{
url
=
config
.
elasticsearch
+
'/'
+
config
.
grafana_index
+
url
;
var
options
=
{
url
:
url
,
method
:
'PUT'
,
data
:
data
};
return
$http
(
options
);
};
this
.
saveDashboard
=
function
(
dashboard
,
title
,
ttl
)
{
var
dashboardClone
=
angular
.
copy
(
dashboard
);
title
=
dashboardClone
.
title
=
title
?
title
:
dashboard
.
title
;
var
data
=
{
user
:
'guest'
,
group
:
'guest'
,
title
:
title
,
tags
:
dashboardClone
.
tags
,
dashboard
:
angular
.
toJson
(
dashboardClone
)
};
return
this
.
put
(
'/dashboard/'
+
encodeURIComponent
(
title
),
data
)
.
then
(
function
()
{
return
{
title
:
title
,
url
:
'/dashboard/elasticsearch/'
+
title
};
},
function
(
err
)
{
throw
'Failed to save to elasticsearch '
+
err
.
data
;
});
};
});
});
src/app/services/playlistSrv.js
View file @
0a3d4a5a
...
@@ -8,7 +8,7 @@ function (angular, _, kbn) {
...
@@ -8,7 +8,7 @@ function (angular, _, kbn) {
var
module
=
angular
.
module
(
'kibana.services'
);
var
module
=
angular
.
module
(
'kibana.services'
);
module
.
service
(
'playlistSrv'
,
function
(
dashboard
,
$location
,
$rootScope
)
{
module
.
service
(
'playlistSrv'
,
function
(
$location
,
$rootScope
)
{
var
timerInstance
;
var
timerInstance
;
var
favorites
=
{
dashboards
:
[]
};
var
favorites
=
{
dashboards
:
[]
};
...
@@ -33,17 +33,17 @@ function (angular, _, kbn) {
...
@@ -33,17 +33,17 @@ function (angular, _, kbn) {
}
}
};
};
this
.
isCurrentFavorite
=
function
()
{
this
.
isCurrentFavorite
=
function
(
dashboard
)
{
return
this
.
_find
(
dashboard
.
current
.
title
)
?
true
:
false
;
return
this
.
_find
(
dashboard
.
title
)
?
true
:
false
;
};
};
this
.
markAsFavorite
=
function
()
{
this
.
markAsFavorite
=
function
(
dashboard
)
{
var
existing
=
this
.
_find
(
dashboard
.
current
.
title
);
var
existing
=
this
.
_find
(
dashboard
.
title
);
this
.
_remove
(
existing
);
this
.
_remove
(
existing
);
favorites
.
dashboards
.
push
({
favorites
.
dashboards
.
push
({
url
:
$location
.
path
(),
url
:
$location
.
path
(),
title
:
dashboard
.
current
.
title
title
:
dashboard
.
title
});
});
this
.
_save
();
this
.
_save
();
...
...
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