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
b89480a2
Commit
b89480a2
authored
Aug 16, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored use of localStorage
parent
5846c710
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
29 deletions
+47
-29
src/app/components/lodash.extended.js
+1
-2
src/app/components/require.config.js
+1
-0
src/app/components/store.js
+20
-0
src/app/controllers/console-ctrl.js
+3
-2
src/app/controllers/dashboardNavCtrl.js
+4
-3
src/app/controllers/grafanaCtrl.js
+8
-10
src/app/routes/dashboard-default.js
+4
-8
src/app/services/playlistSrv.js
+5
-4
src/test/test-main.js
+1
-0
No files found.
src/app/components/lodash.extended.js
View file @
b89480a2
...
...
@@ -33,4 +33,4 @@ function () {
});
return
_
;
});
\ No newline at end of file
});
src/app/components/require.config.js
View file @
b89480a2
...
...
@@ -8,6 +8,7 @@ require.config({
config
:
[
'../config'
,
'../config.sample'
],
settings
:
'components/settings'
,
kbn
:
'components/kbn'
,
store
:
'components/store'
,
css
:
'../vendor/require/css'
,
text
:
'../vendor/require/text'
,
...
...
src/app/components/store.js
0 → 100644
View file @
b89480a2
define
([],
function
()
{
'use strict'
;
return
{
get
:
function
(
key
)
{
return
window
.
localStorage
[
key
];
},
set
:
function
(
key
,
value
)
{
window
.
localStorage
[
key
]
=
value
;
},
getBool
:
function
(
key
)
{
return
window
.
localStorage
[
key
]
===
'true'
?
true
:
false
;
},
delete
:
function
(
key
)
{
window
.
localStorage
.
removeItem
(
key
);
}
};
});
src/app/controllers/console-ctrl.js
View file @
b89480a2
...
...
@@ -2,12 +2,13 @@ define([
'angular'
,
'lodash'
,
'moment'
,
'store'
],
function
(
angular
,
_
,
moment
)
{
function
(
angular
,
_
,
moment
,
store
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
consoleEnabled
=
window
.
localStorage
&&
window
.
localStorage
.
grafanaConsole
===
'true'
;
var
consoleEnabled
=
store
.
getBool
(
'grafanaConsole'
)
;
if
(
!
consoleEnabled
)
{
return
;
...
...
src/app/controllers/dashboardNavCtrl.js
View file @
b89480a2
...
...
@@ -3,9 +3,10 @@ define([
'lodash'
,
'moment'
,
'config'
,
'store'
,
'filesaver'
],
function
(
angular
,
_
,
moment
,
config
)
{
function
(
angular
,
_
,
moment
,
config
,
store
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
...
...
@@ -26,12 +27,12 @@ function (angular, _, moment, config) {
};
$scope
.
set_default
=
function
()
{
window
.
localStorage
.
grafanaDashboardDefault
=
$location
.
path
(
);
store
.
set
(
'grafanaDashboardDefault'
,
$location
.
path
()
);
alertSrv
.
set
(
'Home Set'
,
'This page has been set as your default dashboard'
,
'success'
,
5000
);
};
$scope
.
purge_default
=
function
()
{
delete
window
.
localStorage
.
grafanaDashboardDefault
;
store
.
delete
(
'grafanaDashboardDefault'
)
;
alertSrv
.
set
(
'Local Default Clear'
,
'Your default dashboard has been reset to the default'
,
'success'
,
5000
);
};
...
...
src/app/controllers/grafanaCtrl.js
View file @
b89480a2
...
...
@@ -3,8 +3,9 @@ define([
'config'
,
'lodash'
,
'jquery'
,
'store'
,
],
function
(
angular
,
config
,
_
,
$
)
{
function
(
angular
,
config
,
_
,
$
,
store
)
{
"use strict"
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
...
...
@@ -12,26 +13,23 @@ function (angular, config, _, $) {
module
.
controller
(
'GrafanaCtrl'
,
function
(
$scope
,
alertSrv
,
grafanaVersion
,
$rootScope
)
{
$scope
.
grafanaVersion
=
grafanaVersion
[
0
]
===
'@'
?
'master'
:
grafanaVersion
;
$scope
.
consoleEnabled
=
(
window
.
localStorage
&&
window
.
localStorage
.
grafanaConsole
===
'tru
e'
);
$scope
.
consoleEnabled
=
store
.
getBool
(
'grafanaConsol
e'
);
$rootScope
.
profilingEnabled
=
(
window
.
localStorage
&&
window
.
localStorage
.
profilingEnabled
===
'true
'
);
$rootScope
.
profilingEnabled
=
store
.
getBool
(
'profilingEnabled
'
);
$rootScope
.
performance
=
{
loadStart
:
new
Date
().
getTime
()
};
$scope
.
init
=
function
()
{
$scope
.
_
=
_
;
if
(
$rootScope
.
profilingEnabled
)
{
$scope
.
initProfiling
();
}
if
(
$rootScope
.
profilingEnabled
)
{
$scope
.
initProfiling
();
}
$scope
.
dashAlerts
=
alertSrv
;
$scope
.
grafana
=
{
style
:
'dark'
};
$scope
.
grafana
=
{
style
:
'dark'
};
};
$scope
.
toggleConsole
=
function
()
{
$scope
.
consoleEnabled
=
!
$scope
.
consoleEnabled
;
window
.
localStorage
.
grafanaConsole
=
$scope
.
consoleEnabled
?
'true'
:
'false'
;
store
.
set
(
'grafanaConsole'
,
$scope
.
consoleEnabled
)
;
};
$rootScope
.
onAppEvent
=
function
(
name
,
callback
)
{
...
...
src/app/routes/dashboard-default.js
View file @
b89480a2
define
([
'angular'
,
'config'
'config'
,
'store'
],
function
(
angular
,
config
)
{
function
(
angular
,
config
,
store
)
{
"use strict"
;
var
module
=
angular
.
module
(
'grafana.routes'
);
...
...
@@ -11,12 +12,7 @@ function (angular, config) {
$routeProvider
.
when
(
'/'
,
{
redirectTo
:
function
()
{
if
(
window
.
localStorage
&&
window
.
localStorage
.
grafanaDashboardDefault
)
{
return
window
.
localStorage
.
grafanaDashboardDefault
;
}
else
{
return
config
.
default_route
;
}
return
store
.
get
(
'grafanaDashboardDefault'
)
||
config
.
default_route
;
}
});
});
...
...
src/app/services/playlistSrv.js
View file @
b89480a2
define
([
'angular'
,
'lodash'
,
'kbn'
'kbn'
,
'store'
],
function
(
angular
,
_
,
kbn
)
{
function
(
angular
,
_
,
kbn
,
store
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
...
...
@@ -13,14 +14,14 @@ function (angular, _, kbn) {
var
favorites
=
{
dashboards
:
[]
};
this
.
init
=
function
()
{
var
existingJson
=
window
.
localStorage
[
"grafana-favorites"
]
;
var
existingJson
=
store
.
get
(
"grafana-favorites"
)
;
if
(
existingJson
)
{
favorites
=
angular
.
fromJson
(
existingJson
);
}
};
this
.
_save
=
function
()
{
window
.
localStorage
[
"grafana-favorites"
]
=
angular
.
toJson
(
favorites
);
store
.
set
(
'grafana-favorites'
,
angular
.
toJson
(
favorites
)
);
};
this
.
_find
=
function
(
title
)
{
...
...
src/test/test-main.js
View file @
b89480a2
...
...
@@ -6,6 +6,7 @@ require.config({
mocks
:
'../test/mocks'
,
config
:
'../config.sample'
,
kbn
:
'components/kbn'
,
store
:
'components/store'
,
settings
:
'components/settings'
,
lodash
:
'components/lodash.extended'
,
...
...
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