blob: 7c376a8dd235c7addb58029e1487d46e701999e6 [file] [log] [blame]
Steven Burrows37549ee2016-09-21 14:41:39 +01001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002* Copyright 2016-present Open Networking Foundation
Steven Burrows37549ee2016-09-21 14:41:39 +01003*
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,
Steven Burrows1c2a9682017-07-14 16:52:46 +010033 ovid: 'traffic', // default to traffic overlay
34 toolbar: 0,
Steven Burrows37549ee2016-09-21 14:41:39 +010035 };
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,
Steven Burrows1c2a9682017-07-14 16:52:46 +010062 set: set,
Steven Burrows37549ee2016-09-21 14:41:39 +010063 };
Steven Burrows1c2a9682017-07-14 16:52:46 +010064 },
Steven Burrows37549ee2016-09-21 14:41:39 +010065 ]);
66})();