File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
import Ember from 'ember' ;
2
+ import config from '../config/environment' ;
2
3
import heimdallGraph from 'heimdalljs-graph' ;
3
4
4
5
const {
5
6
getOwner
6
7
} = Ember ;
7
8
9
+ const STORAGE_KEY = `${ config . storageVersion } _graph-data` ;
10
+
8
11
export default Ember . Service . extend ( {
12
+ init ( ) {
13
+ this . _super ( ...arguments ) ;
14
+
15
+ let data = sessionStorage . getItem ( STORAGE_KEY ) ;
16
+ if ( data ) {
17
+ this . setGraph ( JSON . parse ( data ) ) ;
18
+ }
19
+ } ,
20
+
9
21
setGraph ( data ) {
10
22
let graph = heimdallGraph . loadFromJSON ( data ) ;
11
23
24
+ sessionStorage . setItem ( STORAGE_KEY , JSON . stringify ( data ) ) ;
25
+
12
26
this . set ( 'data' , data ) ;
13
27
this . set ( 'graph' , graph ) ;
14
28
} ,
Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ module.exports = function(environment) {
20
20
APP : {
21
21
// Here you can pass flags/options to your application instance
22
22
// when it is created
23
- }
23
+ } ,
24
+
25
+ // bump this when making incompatible changes in
26
+ // localstorage / sessionStorage data formats
27
+ storageVersion : 2
24
28
} ;
25
29
26
30
if ( environment === 'development' ) {
You can’t perform that action at this time.
0 commit comments