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 | |
| 25 | var ps; |
| 26 | |
| 27 | var Panel = function (id, options) { |
| 28 | this.id = id; |
| 29 | this.p = ps.createPanel(this.id, options); |
| 30 | this.setup(); |
| 31 | |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame^] | 32 | if (options.show) { |
| 33 | this.p.show(); |
| 34 | } |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | Panel.prototype = { |
| 38 | setup: function () { |
| 39 | var panel = this.p; |
| 40 | panel.empty(); |
| 41 | |
| 42 | panel.append('div').classed('header', true); |
| 43 | panel.append('div').classed('body', true); |
| 44 | panel.append('div').classed('footer', true); |
| 45 | |
| 46 | this.header = panel.el().select('.header'); |
| 47 | this.body = panel.el().select('.body'); |
| 48 | this.footer = panel.el().select('.body'); |
| 49 | }, |
| 50 | appendToHeader: function (x) { |
| 51 | return this.header.append(x); |
| 52 | }, |
| 53 | appendToBody: function (x) { |
| 54 | return this.body.append(x); |
| 55 | }, |
| 56 | appendToFooter: function (x) { |
| 57 | return this.footer.append(x); |
| 58 | }, |
| 59 | emptyRegions: function () { |
| 60 | this.header.selectAll("*").remove(); |
| 61 | this.body.selectAll("*").remove(); |
| 62 | this.footer.selectAll("*").remove(); |
| 63 | }, |
Steven Burrows | 1c5c861 | 2016-10-05 13:45:13 -0500 | [diff] [blame^] | 64 | destroy: function () { |
| 65 | ps.destroyPanel(this.id); |
Steven Burrows | 5570d1b | 2016-09-28 14:21:00 -0700 | [diff] [blame] | 66 | } |
| 67 | }; |
| 68 | |
| 69 | angular.module('ovTopo2') |
| 70 | .factory('Topo2PanelService', ['PanelService', |
| 71 | function (_ps_) { |
| 72 | ps = _ps_; |
| 73 | return Panel; |
| 74 | } |
| 75 | ]); |
| 76 | |
| 77 | })(); |