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
6c32365e
Commit
6c32365e
authored
Jun 11, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more work on refactoring ES usage
parent
95925aaf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
src/app/controllers/search.js
+2
-3
src/app/services/elasticsearch/es-client.js
+30
-7
No files found.
src/app/controllers/search.js
View file @
6c32365e
...
...
@@ -9,10 +9,9 @@ function (angular, _, config, $) {
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'SearchCtrl'
,
function
(
$scope
,
$rootScope
,
$element
,
$location
,
e
jsResource
,
elasticClient
)
{
module
.
controller
(
'SearchCtrl'
,
function
(
$scope
,
$rootScope
,
$element
,
$location
,
e
lastic
)
{
$scope
.
init
=
function
()
{
$scope
.
ejs
=
ejsResource
(
config
.
elasticsearch
,
config
.
elasticsearchBasicAuth
);
$scope
.
giveSearchFocus
=
0
;
$scope
.
selectedIndex
=
-
1
;
$scope
.
results
=
{
dashboards
:
[],
tags
:
[],
metrics
:
[]};
...
...
@@ -72,7 +71,7 @@ function (angular, _, config, $) {
sort
:
[
"_uid"
]
};
return
elastic
Client
.
post
(
'dashboard/_search'
,
query
)
return
elastic
.
post
(
'dashboard/_search'
,
query
)
.
then
(
function
(
results
)
{
if
(
_
.
isUndefined
(
results
.
hits
))
{
$scope
.
results
.
dashboards
=
[];
...
...
src/app/services/elasticsearch/es-client.js
View file @
6c32365e
...
...
@@ -7,13 +7,12 @@ function(angular, config) {
var
module
=
angular
.
module
(
'kibana.services'
);
module
.
service
(
'elasticClient'
,
function
(
$http
)
{
this
.
post
=
function
(
url
,
data
)
{
module
.
service
(
'elastic'
,
function
(
$http
)
{
this
.
_request
=
function
(
method
,
url
,
data
)
{
var
options
=
{
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/"
+
url
,
method
:
'POST'
,
method
:
method
,
data
:
data
};
...
...
@@ -23,11 +22,35 @@ function(angular, config) {
};
}
return
$http
(
options
)
return
$http
(
options
);
};
this
.
post
=
function
(
url
,
data
)
{
return
this
.
_request
(
'POST'
,
url
,
data
)
.
then
(
function
(
results
)
{
return
results
.
data
;
},
function
(
results
)
{
return
results
.
data
;
},
function
(
err
)
{
return
err
.
data
;
});
};
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
.
_request
(
'PUT'
,
'/dashboard/'
+
encodeURIComponent
(
title
),
data
)
.
then
(
function
()
{
return
{
title
:
title
,
url
:
'/dashboard/elasticsearch/'
+
title
};
},
function
(
err
)
{
throw
'Failed to save to elasticsearch '
+
err
.
data
;
});
};
...
...
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