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
99d2f537
Commit
99d2f537
authored
Jun 11, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sharing temp dashboard is now working again
parent
6c32365e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
86 deletions
+78
-86
src/app/controllers/dash.js
+0
-1
src/app/controllers/dashLoader.js
+13
-7
src/app/controllers/search.js
+10
-1
src/app/partials/dashLoader.html
+2
-2
src/app/partials/dashLoaderShare.html
+1
-1
src/app/partials/search.html
+1
-1
src/app/routes/dashboard-from-es.js
+19
-24
src/app/services/elasticsearch/es-client.js
+32
-3
src/app/services/elasticsearch/es-client2.js
+0
-46
No files found.
src/app/controllers/dash.js
View file @
99d2f537
...
...
@@ -45,7 +45,6 @@ function (angular, $, config, _) {
$scope
.
setupDashboard
=
function
(
event
,
dashboardData
)
{
timer
.
cancel_all
();
alertSrv
.
clearAll
();
$rootScope
.
fullscreen
=
false
;
...
...
src/app/controllers/dashLoader.js
View file @
99d2f537
...
...
@@ -64,17 +64,23 @@ function (angular, _, moment) {
}
};
$scope
.
elasticsearch_save
=
function
(
type
,
ttl
)
{
$scope
.
saveForSharing
=
function
()
{
elastic
.
saveForSharing
(
$scope
.
dashboard
)
.
then
(
function
(
result
)
{
$scope
.
share
=
{
url
:
result
.
url
,
title
:
result
.
title
};
},
function
(
err
)
{
alertSrv
.
set
(
'Save for sharing failed'
,
err
,
'error'
,
5000
);
});
};
$scope
.
saveDashboard
=
function
()
{
elastic
.
saveDashboard
(
$scope
.
dashboard
,
$scope
.
dashboard
.
title
)
.
then
(
function
(
result
)
{
alertSrv
.
set
(
'Dashboard Saved'
,
'Dashboard has been saved to Elasticsearch as "'
+
result
.
title
+
'"'
,
'success'
,
5000
);
if
(
type
===
'temp'
)
{
$scope
.
share
=
$scope
.
dashboard
.
share_link
(
$scope
.
dashboard
.
title
,
'temp'
,
result
.
title
);
}
else
{
$location
.
path
(
result
.
url
);
}
$location
.
path
(
result
.
url
);
$rootScope
.
$emit
(
'dashboard-saved'
,
$scope
.
dashboard
);
...
...
src/app/controllers/search.js
View file @
99d2f537
...
...
@@ -48,6 +48,15 @@ function (angular, _, config, $) {
}
};
$scope
.
shareDashboard
=
function
(
title
,
id
)
{
var
baseUrl
=
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
''
);
$scope
.
share
=
{
title
:
title
,
url
:
baseUrl
+
'#dashboard/elasticsearch/'
+
encodeURIComponent
(
id
)
};
};
$scope
.
searchDasboards
=
function
(
queryString
)
{
var
tagsOnly
=
queryString
.
indexOf
(
'tags!:'
)
===
0
;
if
(
tagsOnly
)
{
...
...
@@ -71,7 +80,7 @@ function (angular, _, config, $) {
sort
:
[
"_uid"
]
};
return
elastic
.
post
(
'dashboard/_search'
,
query
)
return
elastic
.
post
(
'
/
dashboard/_search'
,
query
)
.
then
(
function
(
results
)
{
if
(
_
.
isUndefined
(
results
.
hits
))
{
$scope
.
results
.
dashboards
=
[];
...
...
src/app/partials/dashLoader.html
View file @
99d2f537
...
...
@@ -28,7 +28,7 @@
<li
ng-show=
"dashboard.loader.save_elasticsearch"
>
<form
class=
"input-prepend nomargin save-dashboard-dropdown-save-form"
>
<input
class=
'input-medium'
ng-model=
"dashboard.title"
type=
"text"
ng-model=
"elasticsearch.title"
/>
<button
class=
"btn"
ng-click=
"
elasticsearch_save('dashboard'
)"
><i
class=
"icon-save"
></i></button>
<button
class=
"btn"
ng-click=
"
saveDashboard(
)"
><i
class=
"icon-save"
></i></button>
</form>
</li>
...
...
@@ -47,7 +47,7 @@
<li
ng-show=
"dashboard.loader.save_local"
>
<a
class=
"link"
ng-click=
"dashboard.to_file()"
>
Export dashboard
</a>
</li>
<li
ng-show=
"showDropdown('share')"
><a
bs-tooltip=
"'Share'"
data-placement=
"bottom"
ng-click=
"
elasticsearch_save('temp',dashboard.loader.save_temp_ttl
)"
config-modal=
"app/partials/dashLoaderShare.html"
>
Share temp copy
</i></a></li>
<li
ng-show=
"showDropdown('share')"
><a
bs-tooltip=
"'Share'"
data-placement=
"bottom"
ng-click=
"
saveForSharing(
)"
config-modal=
"app/partials/dashLoaderShare.html"
>
Share temp copy
</i></a></li>
<li
ng-show=
"dashboard.loader.save_gist"
style=
"margin:10px"
>
<h6>
Gist
</h6>
...
...
src/app/partials/dashLoaderShare.html
View file @
99d2f537
...
...
@@ -4,7 +4,7 @@
</div>
<div
class=
"modal-body"
>
<label>
Share this dashboard with this URL
</label>
<input
ng-model=
'share.
link'
type=
"text"
style=
"width:90%"
onclick=
"this.select()"
onfocus=
"this.select()"
ng-change=
"share = dashboard.share_link(share.title,share.type,share.id
)"
>
<input
ng-model=
'share.
url'
type=
"text"
style=
"width:90%"
onclick=
"this.select()"
onfocus=
"this.select(
)"
>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-success"
ng-click=
"dismiss();$broadcast('render')"
>
Close
</button>
...
...
src/app/partials/search.html
View file @
99d2f537
...
...
@@ -86,7 +86,7 @@
{{tag}}
</a>
</td>
<td><a><i
class=
"icon-share"
ng-click=
"share
= dashboard.share_link(row._id,'elasticsearch',
row._id)"
config-modal=
"app/partials/dashLoaderShare.html"
></i></a></td>
<td><a><i
class=
"icon-share"
ng-click=
"share
Dashboard(row._id,
row._id)"
config-modal=
"app/partials/dashLoaderShare.html"
></i></a></td>
</tr>
</table>
</div>
...
...
src/app/routes/dashboard-from-es.js
View file @
99d2f537
...
...
@@ -13,36 +13,31 @@ function (angular, $, config) {
.
when
(
'/dashboard/elasticsearch/:id'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
controller
:
'DashFromElasticProvider'
,
})
.
when
(
'/dashboard/temp/:id'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
controller
:
'DashFromElasticProvider'
,
});
});
module
.
controller
(
'DashFromElasticProvider'
,
function
(
$scope
,
$rootScope
,
$http
,
$routeParams
,
alertSrv
)
{
module
.
controller
(
'DashFromElasticProvider'
,
function
(
$scope
,
$rootScope
,
elastic
,
$routeParams
,
alertSrv
)
{
var
elasticsearch_load
=
function
(
id
)
{
var
url
=
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/dashboard/"
+
id
;
var
options
=
{
url
:
url
+
'?'
+
new
Date
().
getTime
(),
method
:
"GET"
,
transformResponse
:
function
(
response
)
{
var
esResponse
=
angular
.
fromJson
(
response
);
if
(
esResponse
.
_source
&&
esResponse
.
_source
.
dashboard
)
{
return
angular
.
fromJson
(
esResponse
.
_source
.
dashboard
);
var
url
=
'/dashboard/'
+
id
;
// hack to check if it is a temp dashboard
if
(
window
.
location
.
href
.
indexOf
(
'dashboard/temp'
)
>
0
)
{
url
=
'/temp/'
+
id
;
}
return
elastic
.
get
(
url
)
.
then
(
function
(
result
)
{
if
(
result
.
_source
&&
result
.
_source
.
dashboard
)
{
return
angular
.
fromJson
(
result
.
_source
.
dashboard
);
}
else
{
return
false
;
}
}
};
if
(
config
.
elasticsearchBasicAuth
)
{
options
.
withCredentials
=
true
;
options
.
headers
=
{
"Authorization"
:
"Basic "
+
config
.
elasticsearchBasicAuth
};
}
return
$http
(
options
)
.
error
(
function
(
data
,
status
)
{
},
function
(
data
,
status
)
{
if
(
status
===
0
)
{
alertSrv
.
set
(
'Error'
,
"Could not contact Elasticsearch at "
+
config
.
elasticsearch
+
". Please ensure that Elasticsearch is reachable from your browser."
,
'error'
);
...
...
@@ -53,8 +48,8 @@ function (angular, $, config) {
});
};
elasticsearch_load
(
$routeParams
.
id
).
then
(
function
(
result
)
{
$scope
.
emitAppEvent
(
'setup-dashboard'
,
result
.
data
);
elasticsearch_load
(
$routeParams
.
id
).
then
(
function
(
dashboard
)
{
$scope
.
emitAppEvent
(
'setup-dashboard'
,
dashboard
);
});
});
...
...
src/app/services/elasticsearch/es-client.js
View file @
99d2f537
...
...
@@ -11,7 +11,7 @@ function(angular, config) {
this
.
_request
=
function
(
method
,
url
,
data
)
{
var
options
=
{
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/"
+
url
,
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
url
,
method
:
method
,
data
:
data
};
...
...
@@ -25,16 +25,45 @@ function(angular, config) {
return
$http
(
options
);
};
this
.
get
=
function
(
url
)
{
return
this
.
_request
(
'GET'
,
url
)
.
then
(
function
(
results
)
{
return
results
.
data
;
});
};
this
.
post
=
function
(
url
,
data
)
{
return
this
.
_request
(
'POST'
,
url
,
data
)
.
then
(
function
(
results
)
{
return
results
.
data
;
});
};
this
.
saveForSharing
=
function
(
dashboard
)
{
var
data
=
{
user
:
'guest'
,
group
:
'guest'
,
title
:
dashboard
.
title
,
tags
:
dashboard
.
tags
,
dashboard
:
angular
.
toJson
(
dashboard
)
};
var
ttl
=
dashboard
.
loader
.
save_temp_ttl
;
return
this
.
_request
(
'POST'
,
'/temp/?ttl='
+
ttl
,
data
)
.
then
(
function
(
result
)
{
var
baseUrl
=
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
''
);
var
url
=
baseUrl
+
"#dashboard/temp/"
+
result
.
data
.
_id
;
return
{
title
:
dashboard
.
title
,
url
:
url
};
},
function
(
err
)
{
return
err
.
data
;
throw
"Failed to save to temp dashboard to elasticsearch "
+
err
.
data
;
});
};
this
.
saveDashboard
=
function
(
dashboard
,
title
,
ttl
)
{
this
.
saveDashboard
=
function
(
dashboard
,
title
)
{
var
dashboardClone
=
angular
.
copy
(
dashboard
);
title
=
dashboardClone
.
title
=
title
?
title
:
dashboard
.
title
;
...
...
src/app/services/elasticsearch/es-client2.js
deleted
100644 → 0
View file @
6c32365e
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
;
});
};
});
});
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