blob: 7b1735f0aacc936cd49fb5a2c003ed5cbea8a3f9 [file] [log] [blame]
Steven Burrowsc515e602017-04-13 11:17:40 -07001/*
2 * Copyright 2017-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/*
18 ONOS GUI -- Topology Mastership controller.
19 Controller that handles the state of the selected mastership
20 */
21
22(function () {
23
24 var instance;
25
26 angular.module('ovTopo2')
27 .factory('Topo2MastershipService', [
28
29 function () {
30
31 var MastershipController = function () {
32 instance = this;
33 this.region = null;
34 this.currentMastership = null;
35 };
36
37 MastershipController.prototype = {
38 displayMastership: function () {
39 var nodes = this.region.regionNodes(),
40 links = this.region.regionLinks();
41
42 _.each(nodes.concat(links), function (n) {
43 n.displayMastership(this.currentMastership);
44 });
45 },
46 mastership: function () {
47 return this.currentMastership;
48 },
49 setMastership: function (id) {
50 this.currentMastership = id;
51 this.displayMastership();
52 }
53 }
54
55 return instance || new MastershipController();
56 }
57 ]);
58})();