blob: 88ba6787d79da948083b145f600c1ae26354b030 [file] [log] [blame]
Steven Burrows5570d1b2016-09-28 14:21:00 -07001/*
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 Burrows86af4352016-11-16 18:19:12 -060025 // Injected Services
Steven Burrowsaf96a212016-12-28 12:57:02 +000026 var ps;
Steven Burrows5570d1b2016-09-28 14:21:00 -070027
Steven Burrows86af4352016-11-16 18:19:12 -060028 var panel = {
29 initialize: function (id, options) {
30 this.id = id;
31 this.el = ps.createPanel(id, options);
32 this.setup();
Steven Burrows5570d1b2016-09-28 14:21:00 -070033
Steven Burrows86af4352016-11-16 18:19:12 -060034 if (options.show) {
35 this.el.show();
36 }
37 },
Steven Burrows5570d1b2016-09-28 14:21:00 -070038 setup: function () {
Steven Burrows86af4352016-11-16 18:19:12 -060039 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 Burrows5570d1b2016-09-28 14:21:00 -070043 },
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 Burrows1c5c8612016-10-05 13:45:13 -050058 destroy: function () {
59 ps.destroyPanel(this.id);
Steven Burrowsc0efbf02016-11-16 11:30:47 -060060 },
61 isVisible: function () {
Steven Burrows86af4352016-11-16 18:19:12 -060062 return this.el.isVisible();
Steven Burrows5570d1b2016-09-28 14:21:00 -070063 }
Steven Burrowsaf96a212016-12-28 12:57:02 +000064 };
Steven Burrows5570d1b2016-09-28 14:21:00 -070065
66 angular.module('ovTopo2')
Steven Burrowsaf96a212016-12-28 12:57:02 +000067 .factory('Topo2PanelService', [
68 'Topo2UIView', 'PanelService',
69 function (View, _ps_) {
Steven Burrows86af4352016-11-16 18:19:12 -060070
Steven Burrows5570d1b2016-09-28 14:21:00 -070071 ps = _ps_;
Steven Burrows86af4352016-11-16 18:19:12 -060072
73 return View.extend(panel);
Steven Burrows5570d1b2016-09-28 14:21:00 -070074 }
75 ]);
76
77})();