Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 1 | /* |
| 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 | /* |
| 18 | ONOS GUI -- Topology Layout Module. |
| 19 | Module that contains the d3.force.layout logic |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 25 | // Injected Services |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 26 | var ps; |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 27 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 28 | var panel = { |
| 29 | initialize: function (id, options) { |
| 30 | this.id = id; |
| 31 | this.el = ps.createPanel(id, options); |
| 32 | this.setup(); |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 33 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 34 | if (options.show) { |
| 35 | this.el.show(); |
| 36 | } |
| 37 | }, |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 38 | setup: function () { |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 39 | this.el.empty(); |
| 40 | this.header = this.el.append('div').classed('header', true); |
| 41 | this.body = this.el.append('div').classed('body', true); |
| 42 | this.footer = this.el.append('div').classed('footer', true); |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 43 | }, |
| 44 | appendToHeader: function (x) { |
| 45 | return this.header.append(x); |
| 46 | }, |
| 47 | appendToBody: function (x) { |
| 48 | return this.body.append(x); |
| 49 | }, |
| 50 | appendToFooter: function (x) { |
| 51 | return this.footer.append(x); |
| 52 | }, |
| 53 | emptyRegions: function () { |
| 54 | this.header.selectAll("*").remove(); |
| 55 | this.body.selectAll("*").remove(); |
| 56 | this.footer.selectAll("*").remove(); |
| 57 | }, |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame] | 58 | destroy: function () { |
| 59 | ps.destroyPanel(this.id); |
Steven Burrows | c0efbf0 | 2016-11-16 11:30:47 -0600 | [diff] [blame] | 60 | }, |
| 61 | isVisible: function () { |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 62 | return this.el.isVisible(); |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 63 | } |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 64 | }; |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 65 | |
| 66 | angular.module('ovTopo2') |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 67 | .factory('Topo2PanelService', [ |
| 68 | 'Topo2UIView', 'PanelService', |
| 69 | function (View, _ps_) { |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 70 | |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 71 | ps = _ps_; |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 72 | |
| 73 | return View.extend(panel); |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 74 | } |
| 75 | ]); |
| 76 | |
| 77 | })(); |