blob: fd55a08814954ecc9a3597dce544b18b558158b9 [file] [log] [blame]
Steven Burrows86af4352016-11-16 18:19:12 -06001/*
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 View Module.
19 Module that displays the details panel for selected nodes
20 */
21
22(function () {
23 'use strict';
24
Steven Burrowsc59481f2017-04-13 10:01:15 -070025 // TODO: Topo2Panel - A view that draws the container for Summary and Details Panels
26 // TODO: as well as the show/hide/toggle methods.
27
28 // TODO: Topo2DetailsPanel should extend Topo2Panel and add methods to controller position
29 // TODO: based on the visibility of Topo2Summary
30
31 // TODO: Topo2<Device|Link|Host>Panel should only be concerned with the content displayed
32
Steven Burrows86af4352016-11-16 18:19:12 -060033 // Injected Services
34 var Panel;
35
36 // Internal State
Steven Burrowsc59481f2017-04-13 10:01:15 -070037 var detailsPanel, summaryPanel;
Steven Burrows86af4352016-11-16 18:19:12 -060038
39 // configuration
40 var id = 'topo2-p-detail',
Simon Hunt95f4b422017-03-03 13:49:05 -080041 className = 'topo2-p',
Steven Burrowsc59481f2017-04-13 10:01:15 -070042 transTime = 750,
43 panelPadding = 64,
44 panelSpacing = 20,
Steven Burrows86af4352016-11-16 18:19:12 -060045 panelOpts = {
46 width: 260 // summary and detail panel width
47 };
48
Steven Burrowsc59481f2017-04-13 10:01:15 -070049 function getInstance(_summaryPanel_) {
Steven Burrows86af4352016-11-16 18:19:12 -060050 if (detailsPanel) {
51 return detailsPanel;
52 }
53
Steven Burrowsc59481f2017-04-13 10:01:15 -070054 summaryPanel = _summaryPanel_;
55
Steven Burrows86af4352016-11-16 18:19:12 -060056 var options = angular.extend({}, panelOpts, {
57 class: className
58 });
59
Steven Burrowsc59481f2017-04-13 10:01:15 -070060 Panel = Panel.extend({
61 up: function () {
62 detailsPanel.el.el()
63 .transition()
64 .duration(transTime)
65 .style('top', panelPadding + 'px');
66 },
67 down: function (position, callback) {
68 detailsPanel.el.el()
69 .transition()
70 .duration(transTime)
71 .style('top', position + (panelPadding + panelSpacing) + 'px')
72 .each('end', callback);
73 },
74 show: function () {
75
76 var summaryInstance = summaryPanel.getInstance(),
77 position = 0;
78
79 if (summaryInstance.isVisible()) {
80 position = summaryInstance.el.bbox().height;
81 position = position + panelSpacing;
82 }
83
84 detailsPanel.el.el()
85 .style('top', panelPadding + position + 'px');
86 detailsPanel.el.show();
87 }
88 });
89
Steven Burrows86af4352016-11-16 18:19:12 -060090 detailsPanel = new Panel(id, options);
91 detailsPanel.el.classed(className, true);
92
93 return detailsPanel;
94 }
95
Steven Burrowsc59481f2017-04-13 10:01:15 -070096
97
Steven Burrows86af4352016-11-16 18:19:12 -060098 angular.module('ovTopo2')
Steven Burrowsaf96a212016-12-28 12:57:02 +000099 .factory('Topo2DetailsPanelService', [
100 'Topo2PanelService',
Steven Burrows86af4352016-11-16 18:19:12 -0600101 function (_ps_) {
Steven Burrows86af4352016-11-16 18:19:12 -0600102 Panel = _ps_;
103
104 return getInstance;
105 }
106 ]);
107})();