Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 1 | /* |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 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 | import { Component, OnInit } from '@angular/core'; |
| 17 | import { FnService } from '../../util/fn.service'; |
| 18 | import { GlyphService } from '../../svg/glyph.service'; |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 19 | import { LogService } from '../../log.service'; |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 20 | import { SvgUtilService } from '../../svg/svgutil.service'; |
| 21 | import { WebSocketService } from '../../remote/websocket.service'; |
| 22 | |
| 23 | const 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 | }) |
| 40 | export 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 Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 51 | public fs: FnService, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 52 | private gs: GlyphService, |
Sean Condon | fd6d11b | 2018-06-02 20:29:49 +0100 | [diff] [blame] | 53 | 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 | } |