blob: 9d822c8fd951112cdd8af57ed05ea93a88bc2fc1 [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,
Simon Hunt10618f62017-06-15 19:30:52 -070029 hlbls: 0,
Steven Burrows37549ee2016-09-21 14:41:39 +010030 porthl: 1,
31 bg: 0,
32 spr: 0,
Simon Huntfc5c5842017-02-01 23:32:18 -080033 ovid: 'traffic', // default to traffic overlay
Steven Burrows37549ee2016-09-21 14:41:39 +010034 toolbar: 0
35 };
36
37 function topo2Prefs() {
Simon Hunt95f4b422017-03-03 13:49:05 -080038 return ps.getPrefs('topo2_prefs', defaultPrefsState);
Steven Burrows37549ee2016-09-21 14:41:39 +010039 }
40
41 function get(key) {
42 var preferences = topo2Prefs();
43 return preferences[key];
44 }
45
46 function set(key, value) {
47 var preferences = topo2Prefs();
48 preferences[key] = value;
Simon Hunt95f4b422017-03-03 13:49:05 -080049 ps.setPrefs('topo2_prefs', preferences);
Steven Burrows37549ee2016-09-21 14:41:39 +010050 return preferences[key];
51 }
52
53 angular.module('ovTopo2')
Steven Burrowsaf96a212016-12-28 12:57:02 +000054 .factory('Topo2PrefsService', [
55 'PrefsService',
Steven Burrows37549ee2016-09-21 14:41:39 +010056 function (_ps_) {
57
58 ps = _ps_;
59
60 return {
61 get: get,
62 set: set
63 };
64 }
65 ]);
66})();