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
7914f65f
Commit
7914f65f
authored
Jun 13, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed redundant load/save options
parent
d0b79ad3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
160 deletions
+14
-160
src/app/controllers/dashLoader.js
+9
-6
src/app/dashboards/default.json
+0
-3
src/app/dashboards/empty.json
+0
-2
src/app/partials/dashLoader.html
+1
-1
src/app/partials/dasheditor.html
+2
-13
src/app/services/dashboard/dashboardModel.js
+2
-135
No files found.
src/app/controllers/dashLoader.js
View file @
7914f65f
define
([
'angular'
,
'underscore'
,
'moment'
'moment'
,
'filesaver'
],
function
(
angular
,
_
,
moment
)
{
'use strict'
;
...
...
@@ -36,13 +37,10 @@ function (angular, _, moment) {
var
_l
=
$scope
.
dashboard
.
loader
;
if
(
type
===
'load'
)
{
return
(
_l
.
load_elasticsearch
||
_l
.
load_gist
||
_l
.
load_local
);
return
(
_l
.
load_elasticsearch
||
_l
.
load_gist
);
}
if
(
type
===
'save'
)
{
return
(
_l
.
save_elasticsearch
||
_l
.
save_gist
||
_l
.
save_local
||
_l
.
save_default
);
}
if
(
type
===
'share'
)
{
return
(
_l
.
save_temp
);
return
(
_l
.
save_elasticsearch
||
_l
.
save_gist
);
}
return
false
;
};
...
...
@@ -94,6 +92,11 @@ function (angular, _, moment) {
});
};
$scope
.
exportDashboard
=
function
()
{
var
blob
=
new
Blob
([
angular
.
toJson
(
$scope
.
dashboard
,
true
)],
{
type
:
"application/json;charset=utf-8"
});
window
.
saveAs
(
blob
,
$scope
.
dashboard
.
title
+
'-'
+
new
Date
().
getTime
());
};
$scope
.
save_gist
=
function
()
{
$scope
.
dashboard
.
save_gist
(
$scope
.
gist
.
title
).
then
(
function
(
link
)
{
if
(
!
_
.
isUndefined
(
link
))
{
...
...
src/app/dashboards/default.json
View file @
7914f65f
...
...
@@ -137,15 +137,12 @@
"loader"
:
{
"save_gist"
:
false
,
"save_elasticsearch"
:
true
,
"save_local"
:
true
,
"save_default"
:
true
,
"save_temp"
:
true
,
"save_temp_ttl_enable"
:
true
,
"save_temp_ttl"
:
"30d"
,
"load_gist"
:
false
,
"load_elasticsearch"
:
true
,
"load_elasticsearch_size"
:
20
,
"load_local"
:
false
,
"hide"
:
false
},
"refresh"
:
false
...
...
src/app/dashboards/empty.json
View file @
7914f65f
...
...
@@ -68,7 +68,6 @@
"loader"
:
{
"save_gist"
:
false
,
"save_elasticsearch"
:
true
,
"save_local"
:
true
,
"save_default"
:
true
,
"save_temp"
:
true
,
"save_temp_ttl_enable"
:
true
,
...
...
@@ -76,7 +75,6 @@
"load_gist"
:
false
,
"load_elasticsearch"
:
true
,
"load_elasticsearch_size"
:
20
,
"load_local"
:
false
,
"hide"
:
false
},
"refresh"
:
false
...
...
src/app/partials/dashLoader.html
View file @
7914f65f
...
...
@@ -45,7 +45,7 @@
<a
class=
"link"
ng-click=
"removeAsFavorite()"
>
Remove as favorite
</a>
</li>
<li
ng-show=
"dashboard.loader.save_local"
>
<a
class=
"link"
ng-click=
"
dashboard.to_file
()"
>
Export dashboard
</a>
<a
class=
"link"
ng-click=
"
exportDashboard
()"
>
Export dashboard
</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>
...
...
src/app/partials/dasheditor.html
View file @
7914f65f
...
...
@@ -73,12 +73,6 @@
<div
class=
"section"
>
<h5>
Save to
</h5>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Export
</label><input
type=
"checkbox"
ng-model=
"dashboard.loader.save_local"
ng-checked=
"dashboard.loader.save_local"
>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Browser
</label><input
type=
"checkbox"
ng-model=
"dashboard.loader.save_default"
ng-checked=
"dashboard.loader.save_default"
>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Gist
<tip>
Requires your domain to be OAUTH registered with Github
<tip></label><input
type=
"checkbox"
ng-model=
"dashboard.loader.save_gist"
ng-checked=
"dashboard.loader.save_gist"
>
</div>
<div
class=
"editor-option"
>
...
...
@@ -88,17 +82,11 @@
<div
class=
"section"
>
<h5>
Load from
</h5>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Local file
</label><input
type=
"checkbox"
ng-model=
"dashboard.loader.load_local"
ng-checked=
"dashboard.loader.load_local"
>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Gist
</label><input
type=
"checkbox"
ng-model=
"dashboard.loader.load_gist"
ng-checked=
"dashboard.loader.load_gist"
>
</div>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Elasticsearch
</label><input
type=
"checkbox"
ng-model=
"dashboard.loader.load_elasticsearch"
ng-checked=
"dashboard.loader.load_elasticsearch"
>
</div>
<div
class=
"editor-option"
ng-show=
"dashboard.loader.load.elasticsearch"
>
<label
class=
"small"
>
ES list size
</label><input
class=
"input-mini"
type=
"number"
ng-model=
"dashboard.loader.load_elasticsearch_size"
>
</div>
</div>
<div
class=
"section"
>
<h5>
Sharing
</h5>
...
...
@@ -154,5 +142,5 @@
</div>
<button
ng-click=
"add_row(dashboard,row); reset_row();"
class=
"btn btn-success"
ng-show=
"editor.index == 1"
>
Create Row
</button>
<button
type=
"button"
class=
"btn btn-info"
ng-click=
"editor.index=0;dismiss();reset_panel();dashboard.refresh()"
>
Close
</button>
<button
type=
"button"
class=
"btn btn-info"
ng-click=
"editor.index=0;dismiss();reset_panel();dashboard.
emit_
refresh()"
>
Close
</button>
</div>
\ No newline at end of file
src/app/services/dashboard/dashboardModel.js
View file @
7914f65f
...
...
@@ -2,11 +2,7 @@ define([
'angular'
,
'jquery'
,
'kbn'
,
'underscore'
,
'config'
,
'moment'
,
'modernizr'
,
'filesaver'
'underscore'
],
function
(
angular
,
$
,
kbn
,
_
)
{
'use strict'
;
...
...
@@ -41,7 +37,6 @@ function (angular, $, kbn, _) {
save_temp_ttl
:
'30d'
,
load_gist
:
false
,
load_elasticsearch
:
true
,
load_elasticsearch_size
:
20
,
hide
:
false
});
...
...
@@ -96,137 +91,9 @@ function (angular, $, kbn, _) {
}
};
/*// A hash of defaults to use when loading a dashboard
var _dash = {
};
// An elasticJS client to use
var ejs = ejsResource(config.elasticsearch, config.elasticsearchBasicAuth);
/*
var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
// Store a reference to this
var self = this;
this.current = _.clone(_dash);
this.last = {};
this.availablePanels = [];
$rootScope.$on('$routeChangeSuccess',function() {
// Clear the current dashboard to prevent reloading
self.current = {};
self.indices = [];
route();
});
var route = function() {
// Is there a dashboard type and id in the URL?
if(!(_.isUndefined($routeParams.kbnType)) && !(_.isUndefined($routeParams.kbnId))) {
var _type = $routeParams.kbnType;
var _id = $routeParams.kbnId;
switch(_type) {
case ('elasticsearch'):
self.elasticsearch_load('dashboard',_id);
break;
case ('temp'):
self.elasticsearch_load('temp',_id);
break;
case ('file'):
self.file_load(_id);
break;
case('script'):
self.script_load(_id);
break;
case('local'):
self.local_load();
break;
default:
$location.path(config.default_route);
}
// No dashboard in the URL
} else {
// Check if browser supports localstorage, and if there's an old dashboard. If there is,
// inform the user that they should save their dashboard to Elasticsearch and then set that
// as their default
if (Modernizr.localstorage) {
if(!(_.isUndefined(window.localStorage['dashboard'])) && window.localStorage['dashboard'] !== '') {
$location.path(config.default_route);
alertSrv.set('Saving to browser storage has been replaced',' with saving to Elasticsearch.'+
' Click <a href="#/dashboard/local/deprecated">here</a> to load your old dashboard anyway.');
} else if(!(_.isUndefined(window.localStorage.grafanaDashboardDefault))) {
$location.path(window.localStorage.grafanaDashboardDefault);
} else {
$location.path(config.default_route);
}
// No? Ok, grab the default route, its all we have now
} else {
$location.path(config.default_route);
}
}
};
this.refresh = function() {
$rootScope.$broadcast('refresh');
};
var dash_defaults = function(dashboard) {
_.defaults(dashboard, _dash);
_.defaults(dashboard.loader,_dash.loader);
var filtering = _.findWhere(dashboard.pulldowns, {type: 'filtering'});
if (!filtering) {
dashboard.pulldowns.push({
type: 'filtering',
enable: false
});
}
var annotations = _.findWhere(dashboard.pulldowns, {type: 'annotations'});
if (!annotations) {
dashboard.pulldowns.push({
type: 'annotations',
enable: false
});
}
_.each(dashboard.rows, function(row) {
_.each(row.panels, function(panel) {
if (panel.type === 'graphite') {
panel.type = 'graph';
}
});
});
return dashboard;
};
this.dash_load = function(dashboard) {
// Cancel all timers
timer.cancel_all();
// reset fullscreen flag
$rootScope.fullscreen = false;
// Make sure the dashboard being loaded has everything required
dashboard = dash_defaults(dashboard);
window.document.title = 'Grafana - ' + dashboard.title;
// Set the current dashboard
self.current = angular.copy(dashboard);
if(dashboard.refresh) {
self.set_interval(dashboard.refresh);
}
self.availablePanels = config.panels;
$rootScope.$emit('dashboard-loaded', self.current);
return true;
};
this.gist_id = function(string) {
if(self.is_gist(string)) {
...
...
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