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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
85 deletions
+77
-85
src/app/controllers/dash.js
+0
-1
src/app/controllers/dashLoader.js
+12
-6
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, _) {
...
@@ -45,7 +45,6 @@ function (angular, $, config, _) {
$scope
.
setupDashboard
=
function
(
event
,
dashboardData
)
{
$scope
.
setupDashboard
=
function
(
event
,
dashboardData
)
{
timer
.
cancel_all
();
timer
.
cancel_all
();
alertSrv
.
clearAll
();
$rootScope
.
fullscreen
=
false
;
$rootScope
.
fullscreen
=
false
;
...
...
src/app/controllers/dashLoader.js
View file @
99d2f537
...
@@ -64,17 +64,23 @@ function (angular, _, moment) {
...
@@ -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
)
elastic
.
saveDashboard
(
$scope
.
dashboard
,
$scope
.
dashboard
.
title
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
alertSrv
.
set
(
'Dashboard Saved'
,
'Dashboard has been saved to Elasticsearch as "'
+
result
.
title
+
'"'
,
'success'
,
5000
);
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
);
$rootScope
.
$emit
(
'dashboard-saved'
,
$scope
.
dashboard
);
...
...
src/app/controllers/search.js
View file @
99d2f537
...
@@ -48,6 +48,15 @@ function (angular, _, config, $) {
...
@@ -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
)
{
$scope
.
searchDasboards
=
function
(
queryString
)
{
var
tagsOnly
=
queryString
.
indexOf
(
'tags!:'
)
===
0
;
var
tagsOnly
=
queryString
.
indexOf
(
'tags!:'
)
===
0
;
if
(
tagsOnly
)
{
if
(
tagsOnly
)
{
...
@@ -71,7 +80,7 @@ function (angular, _, config, $) {
...
@@ -71,7 +80,7 @@ function (angular, _, config, $) {
sort
:
[
"_uid"
]
sort
:
[
"_uid"
]
};
};
return
elastic
.
post
(
'dashboard/_search'
,
query
)
return
elastic
.
post
(
'
/
dashboard/_search'
,
query
)
.
then
(
function
(
results
)
{
.
then
(
function
(
results
)
{
if
(
_
.
isUndefined
(
results
.
hits
))
{
if
(
_
.
isUndefined
(
results
.
hits
))
{
$scope
.
results
.
dashboards
=
[];
$scope
.
results
.
dashboards
=
[];
...
...
src/app/partials/dashLoader.html
View file @
99d2f537
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
<li
ng-show=
"dashboard.loader.save_elasticsearch"
>
<li
ng-show=
"dashboard.loader.save_elasticsearch"
>
<form
class=
"input-prepend nomargin save-dashboard-dropdown-save-form"
>
<form
class=
"input-prepend nomargin save-dashboard-dropdown-save-form"
>
<input
class=
'input-medium'
ng-model=
"dashboard.title"
type=
"text"
ng-model=
"elasticsearch.title"
/>
<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>
</form>
</li>
</li>
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
<li
ng-show=
"dashboard.loader.save_local"
>
<li
ng-show=
"dashboard.loader.save_local"
>
<a
class=
"link"
ng-click=
"dashboard.to_file()"
>
Export dashboard
</a>
<a
class=
"link"
ng-click=
"dashboard.to_file()"
>
Export dashboard
</a>
</li>
</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"
>
<li
ng-show=
"dashboard.loader.save_gist"
style=
"margin:10px"
>
<h6>
Gist
</h6>
<h6>
Gist
</h6>
...
...
src/app/partials/dashLoaderShare.html
View file @
99d2f537
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<label>
Share this dashboard with this URL
</label>
<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>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-success"
ng-click=
"dismiss();$broadcast('render')"
>
Close
</button>
<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 @@
...
@@ -86,7 +86,7 @@
{{tag}}
{{tag}}
</a>
</a>
</td>
</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>
</tr>
</table>
</table>
</div>
</div>
...
...
src/app/routes/dashboard-from-es.js
View file @
99d2f537
...
@@ -13,36 +13,31 @@ function (angular, $, config) {
...
@@ -13,36 +13,31 @@ function (angular, $, config) {
.
when
(
'/dashboard/elasticsearch/:id'
,
{
.
when
(
'/dashboard/elasticsearch/:id'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
templateUrl
:
'app/partials/dashboard.html'
,
controller
:
'DashFromElasticProvider'
,
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
elasticsearch_load
=
function
(
id
)
{
var
url
=
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/dashboard/"
+
id
;
var
url
=
'/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
);
}
else
{
return
false
;
}
}
};
if
(
config
.
elasticsearchBasicAuth
)
{
// hack to check if it is a temp dashboard
options
.
withCredentials
=
true
;
if
(
window
.
location
.
href
.
indexOf
(
'dashboard/temp'
)
>
0
)
{
options
.
headers
=
{
url
=
'/temp/'
+
id
;
"Authorization"
:
"Basic "
+
config
.
elasticsearchBasicAuth
};
}
}
return
$http
(
options
)
return
elastic
.
get
(
url
)
.
error
(
function
(
data
,
status
)
{
.
then
(
function
(
result
)
{
if
(
result
.
_source
&&
result
.
_source
.
dashboard
)
{
return
angular
.
fromJson
(
result
.
_source
.
dashboard
);
}
else
{
return
false
;
}
},
function
(
data
,
status
)
{
if
(
status
===
0
)
{
if
(
status
===
0
)
{
alertSrv
.
set
(
'Error'
,
"Could not contact Elasticsearch at "
+
alertSrv
.
set
(
'Error'
,
"Could not contact Elasticsearch at "
+
config
.
elasticsearch
+
". Please ensure that Elasticsearch is reachable from your browser."
,
'error'
);
config
.
elasticsearch
+
". Please ensure that Elasticsearch is reachable from your browser."
,
'error'
);
...
@@ -53,8 +48,8 @@ function (angular, $, config) {
...
@@ -53,8 +48,8 @@ function (angular, $, config) {
});
});
};
};
elasticsearch_load
(
$routeParams
.
id
).
then
(
function
(
result
)
{
elasticsearch_load
(
$routeParams
.
id
).
then
(
function
(
dashboard
)
{
$scope
.
emitAppEvent
(
'setup-dashboard'
,
result
.
data
);
$scope
.
emitAppEvent
(
'setup-dashboard'
,
dashboard
);
});
});
});
});
...
...
src/app/services/elasticsearch/es-client.js
View file @
99d2f537
...
@@ -11,7 +11,7 @@ function(angular, config) {
...
@@ -11,7 +11,7 @@ function(angular, config) {
this
.
_request
=
function
(
method
,
url
,
data
)
{
this
.
_request
=
function
(
method
,
url
,
data
)
{
var
options
=
{
var
options
=
{
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/"
+
url
,
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
url
,
method
:
method
,
method
:
method
,
data
:
data
data
:
data
};
};
...
@@ -25,16 +25,45 @@ function(angular, config) {
...
@@ -25,16 +25,45 @@ function(angular, config) {
return
$http
(
options
);
return
$http
(
options
);
};
};
this
.
get
=
function
(
url
)
{
return
this
.
_request
(
'GET'
,
url
)
.
then
(
function
(
results
)
{
return
results
.
data
;
});
};
this
.
post
=
function
(
url
,
data
)
{
this
.
post
=
function
(
url
,
data
)
{
return
this
.
_request
(
'POST'
,
url
,
data
)
return
this
.
_request
(
'POST'
,
url
,
data
)
.
then
(
function
(
results
)
{
.
then
(
function
(
results
)
{
return
results
.
data
;
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
)
{
},
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
);
var
dashboardClone
=
angular
.
copy
(
dashboard
);
title
=
dashboardClone
.
title
=
title
?
title
:
dashboard
.
title
;
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