Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 -- Layer -- Veil Service |
| 19 | |
| 20 | Provides a mechanism to display an overlaying div with information. |
| 21 | Used mainly for web socket connection interruption. |
| 22 | */ |
| 23 | (function () { |
| 24 | 'use strict'; |
| 25 | |
| 26 | // injected references |
| 27 | var $log, fs; |
| 28 | |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 29 | var veil, pdiv, svg; |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 30 | |
| 31 | function show(msg) { |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 32 | pdiv.selectAll('p').remove(); |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 33 | |
| 34 | msg.forEach(function (line) { |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 35 | pdiv.append('p').text(line); |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 36 | }); |
| 37 | |
| 38 | veil.style('display', 'block'); |
| 39 | |
| 40 | // TODO: disable key bindings |
| 41 | } |
| 42 | |
| 43 | function hide() { |
| 44 | veil.style('display', 'none'); |
| 45 | // TODO: re-enable key bindings |
| 46 | } |
| 47 | |
| 48 | angular.module('onosLayer') |
| 49 | .factory('VeilService', ['$log', 'FnService', 'GlyphService', |
| 50 | function (_$log_, _fs_, gs) { |
| 51 | $log = _$log_; |
| 52 | fs = _fs_; |
| 53 | |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 54 | var wSize = fs.windowSize(), |
| 55 | ww = wSize.width, |
| 56 | wh = wSize.height, |
| 57 | shrinkConst = wh-(wh * 0.7), |
| 58 | birdDim = wh-shrinkConst, |
| 59 | birdCenter = (ww / 2) - (birdDim / 2); |
| 60 | |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 61 | veil = d3.select('#veil'); |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 62 | pdiv = veil.append('div').classed('msg', true); |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 63 | |
| 64 | svg = veil.append('svg').attr({ |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 65 | width: (ww + 'px'), |
| 66 | height: (wh + 'px'), |
| 67 | viewBox: '0 0 ' + ww + ' ' + wh |
| 68 | }).style('opacity', 0.2); |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 69 | |
Bri Prebilic Cole | 5e940e2 | 2015-02-06 11:34:08 -0800 | [diff] [blame] | 70 | gs.addGlyph(svg, 'bird', (birdDim + 'px'), |
| 71 | false, [birdCenter, shrinkConst/2]); |
Bri Prebilic Cole | 47bb780 | 2015-02-05 17:25:15 -0800 | [diff] [blame] | 72 | |
| 73 | return { |
| 74 | show: show, |
| 75 | hide: hide |
| 76 | }; |
| 77 | }]); |
| 78 | |
| 79 | }()); |