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 | a3ad779 | 2020-01-04 19:26:34 +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 LinkTableResponse extends TableResponse { |
| 28 | links: Link[]; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Model of the links returned from the WebSocket |
| 33 | */ |
| 34 | interface Link { |
| 35 | one: string; |
| 36 | two: string; |
| 37 | type: string; |
| 38 | direction: string; |
| 39 | durable: string; |
| 40 | _iconid_state: string; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * ONOS GUI -- Link View Component |
| 45 | */ |
| 46 | @Component({ |
| 47 | selector: 'onos-link', |
| 48 | templateUrl: './link.component.html', |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 49 | styleUrls: ['./link.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] | 50 | }) |
| 51 | export class LinkComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 52 | |
| 53 | constructor( |
| 54 | protected fs: FnService, |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 55 | protected log: LogService, |
| 56 | protected wss: WebSocketService, |
| 57 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 58 | super(fs, log, wss, 'link'); |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 59 | this.responseCallback = this.linkResponseCb; |
| 60 | this.sortParams = { |
| 61 | firstCol: 'one', |
| 62 | firstDir: SortDir.desc, |
| 63 | secondCol: 'two', |
| 64 | secondDir: SortDir.asc, |
| 65 | }; |
| 66 | } |
| 67 | |
| 68 | ngOnInit() { |
| 69 | this.init(); |
| 70 | this.log.debug('LinkComponent initialized'); |
| 71 | } |
| 72 | |
| 73 | ngOnDestroy() { |
| 74 | this.destroy(); |
| 75 | this.log.debug('LinkComponent destroyed'); |
| 76 | } |
| 77 | |
| 78 | linkResponseCb(data: LinkTableResponse) { |
| 79 | this.log.debug('Link response received for ', data.links.length, 'links'); |
| 80 | } |
| 81 | } |