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 |
| 22 | } from 'gui2-fw-lib'; |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 23 | |
| 24 | interface HostTableResponse extends TableResponse { |
| 25 | hosts: Host[]; |
| 26 | } |
| 27 | |
| 28 | interface Host { |
| 29 | name: boolean; |
| 30 | id: string; |
| 31 | hw: string; |
| 32 | vlanId: string; |
| 33 | configured: string; |
| 34 | address: string; |
| 35 | location: string; |
| 36 | _iconid_type: string; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * ONOS GUI -- Host View Component |
| 41 | */ |
| 42 | @Component({ |
| 43 | selector: 'onos-host', |
| 44 | templateUrl: './host.component.html', |
| 45 | styleUrls: ['./host.component.css', |
| 46 | '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css'] |
| 47 | }) |
| 48 | export class HostComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 49 | |
| 50 | constructor( |
| 51 | protected fs: FnService, |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 52 | protected log: LogService, |
| 53 | protected wss: WebSocketService, |
| 54 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame^] | 55 | super(fs, log, wss, 'host'); |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 56 | this.responseCallback = this.hostResponseCb; |
| 57 | this.sortParams = { |
| 58 | firstCol: 'name', |
| 59 | firstDir: SortDir.desc, |
| 60 | secondCol: 'id', |
| 61 | secondDir: SortDir.asc, |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | ngOnInit() { |
| 66 | this.init(); |
| 67 | this.log.debug('HostComponent initialized'); |
| 68 | } |
| 69 | |
| 70 | ngOnDestroy() { |
| 71 | this.destroy(); |
| 72 | this.log.debug('HostComponent destroyed'); |
| 73 | } |
| 74 | |
| 75 | hostResponseCb(data: HostTableResponse) { |
| 76 | this.log.debug('Host response received for ', data.hosts.length, 'host'); |
| 77 | } |
| 78 | |
| 79 | } |