blob: fe3fafdcb24e405bb588bf9044e420ba69124d92 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
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 Condonff85fbe2019-03-16 14:28:46 +000016import {
17 AfterContentInit,
18 Component,
19 HostListener,
20 Inject,
21 Input,
22 OnInit
23} from '@angular/core';
Sean Condonf4f54a12018-10-10 23:25:46 +010024import { ViewControllerImpl } from '../viewcontroller';
25import {
26 FnService,
27 LogService,
28 PrefsService,
Sean Condonff85fbe2019-03-16 14:28:46 +000029 SvgUtilService, LionService, ZoomUtils, TopoZoomPrefs
Sean Condon3dd062f2020-04-14 09:25:00 +010030} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condonf4f54a12018-10-10 23:25:46 +010031
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 Condonff85fbe2019-03-16 14:28:46 +000045export class NoDeviceConnectedSvgComponent extends ViewControllerImpl implements AfterContentInit, OnInit {
46 @Input() bannerHeight: number = 48;
Sean Condon91481822019-01-01 13:56:14 +000047 lionFn; // Function
Sean Condonff85fbe2019-03-16 14:28:46 +000048 zoomExtents: TopoZoomPrefs = <TopoZoomPrefs>{
49 sc: 1.0, tx: 0, ty: 0
50 };
Sean Condonf4f54a12018-10-10 23:25:46 +010051
52 constructor(
53 protected fs: FnService,
54 protected log: LogService,
55 protected ps: PrefsService,
Sean Condon91481822019-01-01 13:56:14 +000056 protected sus: SvgUtilService,
Sean Condonff85fbe2019-03-16 14:28:46 +000057 private lion: LionService,
58 @Inject('Window') public window: any,
Sean Condonf4f54a12018-10-10 23:25:46 +010059 ) {
60 super(fs, log, ps);
Sean Condon91481822019-01-01 13:56:14 +000061
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 Condonf4f54a12018-10-10 23:25:46 +010069 this.log.debug('NoDeviceConnectedSvgComponent constructed');
70 }
71
72 ngOnInit() {
73 this.log.debug('NoDeviceConnectedSvgComponent initialized');
74 }
75
Sean Condonff85fbe2019-03-16 14:28:46 +000076 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 Condonf4f54a12018-10-10 23:25:46 +010085 }
86
Sean Condon91481822019-01-01 13:56:14 +000087 /**
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 Condonf4f54a12018-10-10 23:25:46 +0100102}