Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [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 View Module. |
| 19 | Module that displays the details panel for selected nodes |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 25 | // 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 Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 33 | // Injected Services |
| 34 | var Panel; |
| 35 | |
| 36 | // Internal State |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 37 | var detailsPanel, summaryPanel; |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 38 | |
| 39 | // configuration |
| 40 | var id = 'topo2-p-detail', |
Simon Hunt | 95f4b42 | 2017-03-03 13:49:05 -0800 | [diff] [blame] | 41 | className = 'topo2-p', |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 42 | transTime = 750, |
| 43 | panelPadding = 64, |
| 44 | panelSpacing = 20, |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 45 | panelOpts = { |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 46 | width: 260 // summary and detail panel width |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 47 | }; |
| 48 | |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 49 | function getInstance(_summaryPanel_) { |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 50 | if (detailsPanel) { |
| 51 | return detailsPanel; |
| 52 | } |
| 53 | |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 54 | summaryPanel = _summaryPanel_; |
| 55 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 56 | var options = angular.extend({}, panelOpts, { |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 57 | class: className |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 58 | }); |
| 59 | |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 60 | 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(); |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 87 | } |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 88 | }); |
| 89 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 90 | detailsPanel = new Panel(id, options); |
| 91 | detailsPanel.el.classed(className, true); |
| 92 | |
| 93 | return detailsPanel; |
| 94 | } |
| 95 | |
Steven Burrows | c59481f | 2017-04-13 10:01:15 -0700 | [diff] [blame] | 96 | |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 97 | |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 98 | angular.module('ovTopo2') |
Steven Burrows | af96a21 | 2016-12-28 12:57:02 +0000 | [diff] [blame] | 99 | .factory('Topo2DetailsPanelService', [ |
| 100 | 'Topo2PanelService', |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 101 | function (_ps_) { |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 102 | Panel = _ps_; |
| 103 | |
| 104 | return getInstance; |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 105 | } |
Steven Burrows | 86af435 | 2016-11-16 18:19:12 -0600 | [diff] [blame] | 106 | ]); |
| 107 | })(); |