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
0e035f93
Commit
0e035f93
authored
Dec 06, 2013
by
Rashid Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed behavior of home saving. Added deprecation notice
parent
faa15d0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
18 deletions
+62
-18
src/app/app.js
+1
-1
src/app/controllers/dashLoader.js
+5
-4
src/app/services/dashboard.js
+56
-13
No files found.
src/app/app.js
View file @
0e035f93
...
...
@@ -26,7 +26,7 @@ function (angular, $, _, appLevelRequire) {
// features if we define them after boot time
register_fns
=
{};
app
.
constant
(
'
kibanaV
ersion'
,
"3.0.0pre5"
);
app
.
constant
(
'
v
ersion'
,
"3.0.0pre5"
);
// Use this for cache busting partials
app
.
constant
(
'cacheBust'
,
"cache-bust="
+
Date
.
now
());
...
...
src/app/controllers/dashLoader.js
View file @
0e035f93
...
...
@@ -7,7 +7,7 @@ function (angular, _) {
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'dashLoader'
,
function
(
$scope
,
$http
,
timer
,
dashboard
,
alertSrv
)
{
module
.
controller
(
'dashLoader'
,
function
(
$scope
,
$http
,
timer
,
dashboard
,
alertSrv
,
$location
)
{
$scope
.
loader
=
dashboard
.
current
.
loader
;
$scope
.
init
=
function
()
{
...
...
@@ -35,8 +35,8 @@ function (angular, _) {
};
$scope
.
set_default
=
function
()
{
if
(
dashboard
.
set_default
())
{
alertSrv
.
set
(
'
Local Default Set'
,
dashboard
.
current
.
title
+
' has been set as your local default
'
,
'success'
,
5000
);
if
(
dashboard
.
set_default
(
$location
.
path
()
))
{
alertSrv
.
set
(
'
Home Set'
,
'This page has been set as your default Kibana dashboard
'
,
'success'
,
5000
);
}
else
{
alertSrv
.
set
(
'Incompatible Browser'
,
'Sorry, your browser is too old for this feature'
,
'error'
,
5000
);
}
...
...
@@ -44,7 +44,8 @@ function (angular, _) {
$scope
.
purge_default
=
function
()
{
if
(
dashboard
.
purge_default
())
{
alertSrv
.
set
(
'Local Default Clear'
,
'Your local default dashboard has been cleared'
,
'success'
,
5000
);
alertSrv
.
set
(
'Local Default Clear'
,
'Your Kibana default dashboard has been reset to the default'
,
'success'
,
5000
);
}
else
{
alertSrv
.
set
(
'Incompatible Browser'
,
'Sorry, your browser is too old for this feature'
,
'error'
,
5000
);
}
...
...
src/app/services/dashboard.js
View file @
0e035f93
...
...
@@ -101,20 +101,29 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
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 a dashboard
if
(
Modernizr
.
localstorage
&&
!
(
_
.
isUndefined
(
window
.
localStorage
[
'dashboard'
]))
&&
window
.
localStorage
[
'dashboard'
]
!==
''
)
{
var
dashboard
=
JSON
.
parse
(
window
.
localStorage
[
'dashboard'
]);
self
.
dash_load
(
dashboard
);
// No? Ok, grab default.json, its all we have now
// 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'
]
!==
''
)
{
console
.
log
(
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
.
kibanaDashboardDefault
)))
{
$location
.
path
(
window
.
localStorage
.
kibanaDashboardDefault
);
}
else
{
$location
.
path
(
config
.
default_route
);
}
// No? Ok, grab the default route, its all we have now
}
else
{
$location
.
path
(
config
.
default_route
);
}
...
...
@@ -230,10 +239,14 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
return
true
;
};
this
.
set_default
=
function
(
dashboard
)
{
this
.
set_default
=
function
(
route
)
{
console
.
log
(
route
);
if
(
Modernizr
.
localstorage
)
{
window
.
localStorage
[
'dashboard'
]
=
angular
.
toJson
(
dashboard
||
self
.
current
);
$location
.
path
(
'/dashboard'
);
// Purge any old dashboards
if
(
!
_
.
isUndefined
(
window
.
localStorage
[
'dashboard'
]))
{
delete
window
.
localStorage
[
'dashboard'
];
}
window
.
localStorage
.
kibanaDashboardDefault
=
route
;
return
true
;
}
else
{
return
false
;
...
...
@@ -242,7 +255,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
this
.
purge_default
=
function
()
{
if
(
Modernizr
.
localstorage
)
{
window
.
localStorage
[
'dashboard'
]
=
''
;
// Purge any old dashboards
if
(
!
_
.
isUndefined
(
window
.
localStorage
[
'dashboard'
]))
{
delete
window
.
localStorage
[
'dashboard'
];
}
delete
window
.
localStorage
.
kibanaDashboardDefault
;
return
true
;
}
else
{
return
false
;
...
...
@@ -273,6 +291,31 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
return
_r
;
};
this
.
local_load
=
function
()
{
var
dashboard
=
JSON
.
parse
(
window
.
localStorage
[
'dashboard'
]);
dashboard
.
rows
.
unshift
({
height
:
"30"
,
title
:
"Deprecation Notice"
,
panels
:
[
{
title
:
'WARNING: Legacy dashboard'
,
type
:
'text'
,
span
:
12
,
mode
:
'html'
,
content
:
'This dashboard has been loaded from the browsers local cache. If you use '
+
'another brower or computer you will not be able to access it! '
+
'
\
n
\
n <h4>Good news!</h4> Kibana'
+
' now stores saved dashboards in Elasticsearch. Click the <i class="icon-save"></i> '
+
'button in the top left to save this dashboard. Then select "Set as Home" from'
+
' the "advanced" sub menu to automatically use the stored dashboard as your Kibana '
+
'landing page afterwards'
+
'<br><br><strong>Tip:</strong> You may with to remove this row before saving!'
}
]
});
self
.
dash_load
(
dashboard
);
};
this
.
file_load
=
function
(
file
)
{
return
$http
({
url
:
"app/dashboards/"
+
file
.
replace
(
/
\.(?!
json
)
/
,
"/"
)
+
'?'
+
new
Date
().
getTime
(),
...
...
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