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'; |
| 17 | import { FnService } from '../../../fw/util/fn.service'; |
| 18 | import { LoadingService } from '../../../fw/layer/loading.service'; |
| 19 | import { LogService } from '../../../log.service'; |
| 20 | import { TableBaseImpl, TableResponse, SortDir } from '../../../fw/widget/table.base'; |
| 21 | import { WebSocketService } from '../../../fw/remote/websocket.service'; |
| 22 | |
| 23 | interface HostTableResponse extends TableResponse { |
| 24 | hosts: Host[]; |
| 25 | } |
| 26 | |
| 27 | interface Host { |
| 28 | name: boolean; |
| 29 | id: string; |
| 30 | hw: string; |
| 31 | vlanId: string; |
| 32 | configured: string; |
| 33 | address: string; |
| 34 | location: string; |
| 35 | _iconid_type: string; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * ONOS GUI -- Host View Component |
| 40 | */ |
| 41 | @Component({ |
| 42 | selector: 'onos-host', |
| 43 | templateUrl: './host.component.html', |
| 44 | styleUrls: ['./host.component.css', |
| 45 | '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css'] |
| 46 | }) |
| 47 | export class HostComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 48 | |
| 49 | constructor( |
| 50 | protected fs: FnService, |
| 51 | protected ls: LoadingService, |
| 52 | protected log: LogService, |
| 53 | protected wss: WebSocketService, |
| 54 | ) { |
| 55 | super(fs, ls, log, wss, 'host'); |
| 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 | } |