blob: 690ac597ccf57edee1c1ba21700b3884606309b2 [file] [log] [blame]
Steven Burrows37549ee2016-09-21 14:41:39 +01001/*
2* Copyright 2016-present Open Networking Laboratory
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17(function () {
18
19 // Injected Services
20 var ps;
21
22 var defaultPrefsState = {
23 insts: 1,
24 summary: 1,
25 detail: 1,
26 hosts: 0,
27 offdev: 1,
28 dlbls: 0,
29 porthl: 1,
30 bg: 0,
31 spr: 0,
32 ovidx: 1, // default to traffic overlay
33 toolbar: 0
34 };
35
36 function topo2Prefs() {
37 return ps.getPrefs('topo_prefs', defaultPrefsState);
38 }
39
40 function get(key) {
41 var preferences = topo2Prefs();
42 return preferences[key];
43 }
44
45 function set(key, value) {
46 var preferences = topo2Prefs();
47 preferences[key] = value;
48 ps.setPrefs('topo_prefs', preferences);
49 return preferences[key];
50 }
51
52 angular.module('ovTopo2')
Steven Burrowsaf96a212016-12-28 12:57:02 +000053 .factory('Topo2PrefsService', [
54 'PrefsService',
Steven Burrows37549ee2016-09-21 14:41:39 +010055 function (_ps_) {
56
57 ps = _ps_;
58
59 return {
60 get: get,
61 set: set
62 };
63 }
64 ]);
65})();