blob: 80c223d3577763ba90b2f44eb9389ec13b852f6f [file] [log] [blame]
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -08001/*
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 Cole5e940e22015-02-06 11:34:08 -080029 var veil, pdiv, svg;
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080030
31 function show(msg) {
Bri Prebilic Cole5e940e22015-02-06 11:34:08 -080032 pdiv.selectAll('p').remove();
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080033
34 msg.forEach(function (line) {
Bri Prebilic Cole5e940e22015-02-06 11:34:08 -080035 pdiv.append('p').text(line);
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080036 });
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 Cole5e940e22015-02-06 11:34:08 -080054 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 Cole47bb7802015-02-05 17:25:15 -080061 veil = d3.select('#veil');
Bri Prebilic Cole5e940e22015-02-06 11:34:08 -080062 pdiv = veil.append('div').classed('msg', true);
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080063
64 svg = veil.append('svg').attr({
Bri Prebilic Cole5e940e22015-02-06 11:34:08 -080065 width: (ww + 'px'),
66 height: (wh + 'px'),
67 viewBox: '0 0 ' + ww + ' ' + wh
68 }).style('opacity', 0.2);
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080069
Bri Prebilic Cole5e940e22015-02-06 11:34:08 -080070 gs.addGlyph(svg, 'bird', (birdDim + 'px'),
71 false, [birdCenter, shrinkConst/2]);
Bri Prebilic Cole47bb7802015-02-05 17:25:15 -080072
73 return {
74 show: show,
75 hide: hide
76 };
77 }]);
78
79}());