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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
27 deletions
+46
-27
src/app/components/lodash.extended.js
+0
-0
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
src/app/components/require.config.js
View file @
b89480a2
...
@@ -8,6 +8,7 @@ require.config({
...
@@ -8,6 +8,7 @@ require.config({
config
:
[
'../config'
,
'../config.sample'
],
config
:
[
'../config'
,
'../config.sample'
],
settings
:
'components/settings'
,
settings
:
'components/settings'
,
kbn
:
'components/kbn'
,
kbn
:
'components/kbn'
,
store
:
'components/store'
,
css
:
'../vendor/require/css'
,
css
:
'../vendor/require/css'
,
text
:
'../vendor/require/text'
,
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([
...
@@ -2,12 +2,13 @@ define([
'angular'
,
'angular'
,
'lodash'
,
'lodash'
,
'moment'
,
'moment'
,
'store'
],
],
function
(
angular
,
_
,
moment
)
{
function
(
angular
,
_
,
moment
,
store
)
{
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
consoleEnabled
=
window
.
localStorage
&&
window
.
localStorage
.
grafanaConsole
===
'true'
;
var
consoleEnabled
=
store
.
getBool
(
'grafanaConsole'
)
;
if
(
!
consoleEnabled
)
{
if
(
!
consoleEnabled
)
{
return
;
return
;
...
...
src/app/controllers/dashboardNavCtrl.js
View file @
b89480a2
...
@@ -3,9 +3,10 @@ define([
...
@@ -3,9 +3,10 @@ define([
'lodash'
,
'lodash'
,
'moment'
,
'moment'
,
'config'
,
'config'
,
'store'
,
'filesaver'
'filesaver'
],
],
function
(
angular
,
_
,
moment
,
config
)
{
function
(
angular
,
_
,
moment
,
config
,
store
)
{
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
module
=
angular
.
module
(
'grafana.controllers'
);
...
@@ -26,12 +27,12 @@ function (angular, _, moment, config) {
...
@@ -26,12 +27,12 @@ function (angular, _, moment, config) {
};
};
$scope
.
set_default
=
function
()
{
$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
);
alertSrv
.
set
(
'Home Set'
,
'This page has been set as your default dashboard'
,
'success'
,
5000
);
};
};
$scope
.
purge_default
=
function
()
{
$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
);
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([
...
@@ -3,8 +3,9 @@ define([
'config'
,
'config'
,
'lodash'
,
'lodash'
,
'jquery'
,
'jquery'
,
'store'
,
],
],
function
(
angular
,
config
,
_
,
$
)
{
function
(
angular
,
config
,
_
,
$
,
store
)
{
"use strict"
;
"use strict"
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
module
=
angular
.
module
(
'grafana.controllers'
);
...
@@ -12,26 +13,23 @@ function (angular, config, _, $) {
...
@@ -12,26 +13,23 @@ function (angular, config, _, $) {
module
.
controller
(
'GrafanaCtrl'
,
function
(
$scope
,
alertSrv
,
grafanaVersion
,
$rootScope
)
{
module
.
controller
(
'GrafanaCtrl'
,
function
(
$scope
,
alertSrv
,
grafanaVersion
,
$rootScope
)
{
$scope
.
grafanaVersion
=
grafanaVersion
[
0
]
===
'@'
?
'master'
:
grafanaVersion
;
$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
()
};
$rootScope
.
performance
=
{
loadStart
:
new
Date
().
getTime
()
};
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
$scope
.
_
=
_
;
$scope
.
_
=
_
;
if
(
$rootScope
.
profilingEnabled
)
{
$scope
.
initProfiling
();
if
(
$rootScope
.
profilingEnabled
)
{
$scope
.
initProfiling
();
}
}
$scope
.
dashAlerts
=
alertSrv
;
$scope
.
dashAlerts
=
alertSrv
;
$scope
.
grafana
=
{
$scope
.
grafana
=
{
style
:
'dark'
};
style
:
'dark'
};
};
};
$scope
.
toggleConsole
=
function
()
{
$scope
.
toggleConsole
=
function
()
{
$scope
.
consoleEnabled
=
!
$scope
.
consoleEnabled
;
$scope
.
consoleEnabled
=
!
$scope
.
consoleEnabled
;
window
.
localStorage
.
grafanaConsole
=
$scope
.
consoleEnabled
?
'true'
:
'false'
;
store
.
set
(
'grafanaConsole'
,
$scope
.
consoleEnabled
)
;
};
};
$rootScope
.
onAppEvent
=
function
(
name
,
callback
)
{
$rootScope
.
onAppEvent
=
function
(
name
,
callback
)
{
...
...
src/app/routes/dashboard-default.js
View file @
b89480a2
define
([
define
([
'angular'
,
'angular'
,
'config'
'config'
,
'store'
],
],
function
(
angular
,
config
)
{
function
(
angular
,
config
,
store
)
{
"use strict"
;
"use strict"
;
var
module
=
angular
.
module
(
'grafana.routes'
);
var
module
=
angular
.
module
(
'grafana.routes'
);
...
@@ -11,12 +12,7 @@ function (angular, config) {
...
@@ -11,12 +12,7 @@ function (angular, config) {
$routeProvider
$routeProvider
.
when
(
'/'
,
{
.
when
(
'/'
,
{
redirectTo
:
function
()
{
redirectTo
:
function
()
{
if
(
window
.
localStorage
&&
window
.
localStorage
.
grafanaDashboardDefault
)
{
return
store
.
get
(
'grafanaDashboardDefault'
)
||
config
.
default_route
;
return
window
.
localStorage
.
grafanaDashboardDefault
;
}
else
{
return
config
.
default_route
;
}
}
}
});
});
});
});
...
...
src/app/services/playlistSrv.js
View file @
b89480a2
define
([
define
([
'angular'
,
'angular'
,
'lodash'
,
'lodash'
,
'kbn'
'kbn'
,
'store'
],
],
function
(
angular
,
_
,
kbn
)
{
function
(
angular
,
_
,
kbn
,
store
)
{
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
var
module
=
angular
.
module
(
'grafana.services'
);
...
@@ -13,14 +14,14 @@ function (angular, _, kbn) {
...
@@ -13,14 +14,14 @@ function (angular, _, kbn) {
var
favorites
=
{
dashboards
:
[]
};
var
favorites
=
{
dashboards
:
[]
};
this
.
init
=
function
()
{
this
.
init
=
function
()
{
var
existingJson
=
window
.
localStorage
[
"grafana-favorites"
]
;
var
existingJson
=
store
.
get
(
"grafana-favorites"
)
;
if
(
existingJson
)
{
if
(
existingJson
)
{
favorites
=
angular
.
fromJson
(
existingJson
);
favorites
=
angular
.
fromJson
(
existingJson
);
}
}
};
};
this
.
_save
=
function
()
{
this
.
_save
=
function
()
{
window
.
localStorage
[
"grafana-favorites"
]
=
angular
.
toJson
(
favorites
);
store
.
set
(
'grafana-favorites'
,
angular
.
toJson
(
favorites
)
);
};
};
this
.
_find
=
function
(
title
)
{
this
.
_find
=
function
(
title
)
{
...
...
src/test/test-main.js
View file @
b89480a2
...
@@ -6,6 +6,7 @@ require.config({
...
@@ -6,6 +6,7 @@ require.config({
mocks
:
'../test/mocks'
,
mocks
:
'../test/mocks'
,
config
:
'../config.sample'
,
config
:
'../config.sample'
,
kbn
:
'components/kbn'
,
kbn
:
'components/kbn'
,
store
:
'components/store'
,
settings
:
'components/settings'
,
settings
:
'components/settings'
,
lodash
:
'components/lodash.extended'
,
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