Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [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 | */ |
| 16 | import { Component, OnInit, OnDestroy } from '@angular/core'; |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 17 | import { |
| 18 | FnService, |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 19 | LogService, |
| 20 | WebSocketService, |
| 21 | SortDir, TableBaseImpl, TableResponse |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame^] | 22 | } from '../../../../../../../../gui2-fw-lib/public_api'; |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Model of the response from WebSocket |
| 26 | */ |
| 27 | interface TunnelTableResponse extends TableResponse { |
| 28 | tunnels: Tunnel[]; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Model of the tunnels returned from the WebSocket |
| 33 | */ |
| 34 | interface Tunnel { |
| 35 | id: string; |
| 36 | name: string; |
| 37 | port1: string; |
| 38 | port2: string; |
| 39 | type: string; |
| 40 | groupId: string; |
| 41 | bandwidth: string; |
| 42 | path: string; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * ONOS GUI -- Tunnel View Component |
| 47 | */ |
| 48 | @Component({ |
| 49 | selector: 'onos-tunnel', |
| 50 | templateUrl: './tunnel.component.html', |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame^] | 51 | styleUrls: ['./tunnel.component.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.theme.css'] |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 52 | }) |
| 53 | export class TunnelComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 54 | |
| 55 | constructor( |
| 56 | protected fs: FnService, |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 57 | protected log: LogService, |
| 58 | protected wss: WebSocketService, |
| 59 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 60 | super(fs, log, wss, 'tunnel'); |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 61 | this.responseCallback = this.tunnelResponseCb; |
| 62 | this.sortParams = { |
| 63 | firstCol: 'id', |
| 64 | firstDir: SortDir.desc, |
| 65 | secondCol: 'name', |
| 66 | secondDir: SortDir.asc, |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | ngOnInit() { |
| 71 | this.init(); |
| 72 | this.log.debug('TunnelComponent initialized'); |
| 73 | } |
| 74 | |
| 75 | ngOnDestroy() { |
| 76 | this.destroy(); |
| 77 | this.log.debug('TunnelComponent destroyed'); |
| 78 | } |
| 79 | |
| 80 | tunnelResponseCb(data: TunnelTableResponse) { |
| 81 | this.log.debug('Tunnel response received for ', data.tunnels.length, 'tunnels'); |
| 82 | } |
| 83 | |
| 84 | } |