Sean Condon | ff85fbe | 2019-03-16 14:28:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-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 | */ |
| 16 | import {AfterViewInit, Component, OnDestroy} from '@angular/core'; |
| 17 | import { |
| 18 | GlyphService, |
| 19 | KeysService, |
| 20 | LionService, |
| 21 | LogService, |
| 22 | ThemeService, |
| 23 | WebSocketService, |
| 24 | WsOptions |
| 25 | } from 'gui2-fw-lib'; |
| 26 | import * as d3 from 'd3'; |
| 27 | |
| 28 | @Component({ |
| 29 | selector: 'app-root', |
| 30 | templateUrl: './app.component.html', |
| 31 | styleUrls: ['./app.component.css'] |
| 32 | }) |
| 33 | export class AppComponent implements AfterViewInit, OnDestroy { |
| 34 | title = 'gui2-topo-tester'; |
| 35 | |
| 36 | constructor ( |
| 37 | private lion: LionService, |
| 38 | private ts: ThemeService, |
| 39 | private gs: GlyphService, |
| 40 | private ks: KeysService, |
| 41 | public wss: WebSocketService, |
| 42 | private log: LogService, |
| 43 | ) { |
| 44 | // Testing of debugging |
| 45 | log.debug('OnosComponent: testing logger.debug()'); |
| 46 | log.info('OnosComponent: testing logger.info()'); |
| 47 | log.warn('OnosComponent: testing logger.warn()'); |
| 48 | log.error('OnosComponent: testing logger.error()'); |
| 49 | |
| 50 | this.wss.createWebSocket(<WsOptions>{ wsport: 8181}); |
| 51 | |
| 52 | log.debug('OnosComponent constructed'); |
| 53 | } |
| 54 | |
| 55 | ngAfterViewInit(): void { |
| 56 | this.ks.installOn(d3.select('body')); |
| 57 | this.log.debug('AppComponent after view initialized'); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | ngOnDestroy() { |
| 62 | if (this.wss.isConnected()) { |
| 63 | this.log.debug('Stopping Web Socket connection'); |
| 64 | this.wss.closeWebSocket(); |
| 65 | } |
| 66 | |
| 67 | this.log.debug('AppComponent destroyed'); |
| 68 | } |
| 69 | } |