Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 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 Hunt | 10618f6 | 2017-06-15 19:30:52 -0700 | [diff] [blame] | 29 | hlbls: 0, |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 30 | porthl: 1, |
| 31 | bg: 0, |
| 32 | spr: 0, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 33 | ovid: 'traffic', // default to traffic overlay |
| 34 | toolbar: 0, |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | function topo2Prefs() { |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 38 | return ps.getPrefs('topo2_prefs', defaultPrefsState); |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 39 | } |
| 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 Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 49 | ps.setPrefs('topo2_prefs', preferences); |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 50 | return preferences[key]; |
| 51 | } |
| 52 | |
| 53 | angular.module('ovTopo2') |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 54 | .factory('Topo2PrefsService', [ |
| 55 | 'PrefsService', |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 56 | function (_ps_) { |
| 57 | |
| 58 | ps = _ps_; |
| 59 | |
| 60 | return { |
| 61 | get: get, |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 62 | set: set, |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 63 | }; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 64 | }, |
Steven Burrows | 37549ee | 2016-09-21 14:41:39 +0100 | [diff] [blame] | 65 | ]); |
| 66 | })(); |