blob: b93d95018ea7fe8e592e24083b019d8abe8e16d5 [file] [log] [blame]
Sean Condonfd6d11b2018-06-02 20:29:49 +01001/*
Sean Condon5ca00262018-09-06 17:55:25 +01002 * Copyright 2018-present Open Networking Foundation
Sean Condonfd6d11b2018-06-02 20:29:49 +01003 *
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 */
16import { Component, OnInit } from '@angular/core';
17import { FnService } from '../../util/fn.service';
18import { GlyphService } from '../../svg/glyph.service';
Sean Condon5ca00262018-09-06 17:55:25 +010019import { LogService } from '../../log.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010020import { SvgUtilService } from '../../svg/svgutil.service';
21import { WebSocketService } from '../../remote/websocket.service';
22
23const BIRD = 'bird';
24
25/**
26 * ONOS GUI -- Layer -- Veil Component
27 *
28 * Provides a mechanism to display an overlaying div with information.
29 * Used mainly for web socket connection interruption.
30 *
31 * It can be added to an component's template as follows:
32 * <onos-veil #veil></onos-veil>
33 * <p (click)="veil.show(['t1','t2','t3'])">Test Veil</p>
34 */
35@Component({
36 selector: 'onos-veil',
37 templateUrl: './veil.component.html',
38 styleUrls: ['./veil.component.css', './veil.component.theme.css']
39})
40export class VeilComponent implements OnInit {
41 ww: number;
42 wh: number;
43 birdSvg: string;
44 birdDim: number;
45 enabled: boolean = false;
46 trans: string;
47 messages: string[] = [];
48 veilStyle: string;
49
50 constructor(
Sean Condon5ca00262018-09-06 17:55:25 +010051 public fs: FnService,
Sean Condonfd6d11b2018-06-02 20:29:49 +010052 private gs: GlyphService,
Sean Condonfd6d11b2018-06-02 20:29:49 +010053 private log: LogService,
54 private sus: SvgUtilService,
55 private wss: WebSocketService
56 ) {
57 const wSize = this.fs.windowSize();
58 this.ww = wSize.width;
59 this.wh = wSize.height;
60 const shrink = this.wh * 0.3;
61 this.birdDim = this.wh - shrink;
62 const birdCenter = (this.ww - this.birdDim) / 2;
63 this.trans = this.sus.translate([birdCenter, shrink / 2]);
64
65 this.log.debug('VeilComponent with ' + BIRD + ' constructed');
66 }
67
68 ngOnInit() {
69 }
70
71 // msg should be an array of strings
72 show(msgs: string[]): void {
73 this.messages = msgs;
74 this.enabled = true;
75// this.ks.enableKeys(false);
76 }
77
78 hide(): void {
79 this.veilStyle = 'display: none';
80// this.ks.enableKeys(true);
81 }
82
83
84}