Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | */ |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 16 | import { |
| 17 | AfterContentInit, |
| 18 | Component, |
| 19 | HostListener, |
| 20 | Inject, |
| 21 | Input, |
| 22 | OnInit |
| 23 | } from '@angular/core'; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 24 | import { ViewControllerImpl } from '../viewcontroller'; |
| 25 | import { |
| 26 | FnService, |
| 27 | LogService, |
| 28 | PrefsService, |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 29 | SvgUtilService, LionService, ZoomUtils, TopoZoomPrefs |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 30 | } from 'gui2-fw-lib/public_api'; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * ONOS GUI -- Topology No Connected Devices View. |
| 34 | * View that contains the 'No Connected Devices' message |
| 35 | * |
| 36 | * This component is an SVG snippet that expects to be in an SVG element with a view box of 1000x1000 |
| 37 | * |
| 38 | * It should be added to a template with a tag like <svg:g onos-nodeviceconnected /> |
| 39 | */ |
| 40 | @Component({ |
| 41 | selector: '[onos-nodeviceconnected]', |
| 42 | templateUrl: './nodeviceconnectedsvg.component.html', |
| 43 | styleUrls: ['./nodeviceconnectedsvg.component.css'] |
| 44 | }) |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 45 | export class NoDeviceConnectedSvgComponent extends ViewControllerImpl implements AfterContentInit, OnInit { |
| 46 | @Input() bannerHeight: number = 48; |
Sean Condon | 9148182 | 2019-01-01 13:56:14 +0000 | [diff] [blame] | 47 | lionFn; // Function |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 48 | zoomExtents: TopoZoomPrefs = <TopoZoomPrefs>{ |
| 49 | sc: 1.0, tx: 0, ty: 0 |
| 50 | }; |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 51 | |
| 52 | constructor( |
| 53 | protected fs: FnService, |
| 54 | protected log: LogService, |
| 55 | protected ps: PrefsService, |
Sean Condon | 9148182 | 2019-01-01 13:56:14 +0000 | [diff] [blame] | 56 | protected sus: SvgUtilService, |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 57 | private lion: LionService, |
| 58 | @Inject('Window') public window: any, |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 59 | ) { |
| 60 | super(fs, log, ps); |
Sean Condon | 9148182 | 2019-01-01 13:56:14 +0000 | [diff] [blame] | 61 | |
| 62 | if (this.lion.ubercache.length === 0) { |
| 63 | this.lionFn = this.dummyLion; |
| 64 | this.lion.loadCbs.set('topo-nodevices', () => this.doLion()); |
| 65 | } else { |
| 66 | this.doLion(); |
| 67 | } |
| 68 | |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 69 | this.log.debug('NoDeviceConnectedSvgComponent constructed'); |
| 70 | } |
| 71 | |
| 72 | ngOnInit() { |
| 73 | this.log.debug('NoDeviceConnectedSvgComponent initialized'); |
| 74 | } |
| 75 | |
Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 76 | ngAfterContentInit(): void { |
| 77 | this.zoomExtents = ZoomUtils.zoomToWindowSize( |
| 78 | this.bannerHeight, this.window.innerWidth, this.window.innerHeight); |
| 79 | } |
| 80 | |
| 81 | @HostListener('window:resize', ['$event']) |
| 82 | onResize(event) { |
| 83 | this.zoomExtents = ZoomUtils.zoomToWindowSize( |
| 84 | this.bannerHeight, event.target.innerWidth, event.target.innerHeight); |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Sean Condon | 9148182 | 2019-01-01 13:56:14 +0000 | [diff] [blame] | 87 | /** |
| 88 | * Read the LION bundle for Details panel and set up the lionFn |
| 89 | */ |
| 90 | doLion() { |
| 91 | this.lionFn = this.lion.bundle('core.view.Topo'); |
| 92 | |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * A dummy implementation of the lionFn until the response is received and the LION |
| 97 | * bundle is received from the WebSocket |
| 98 | */ |
| 99 | dummyLion(key: string): string { |
| 100 | return '%' + key + '%'; |
| 101 | } |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 102 | } |