Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-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 | */ |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame^] | 16 | import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 17 | import { DetailsPanelService } from '../../fw/layer/detailspanel.service'; |
| 18 | import { FnService } from '../../fw/util/fn.service'; |
| 19 | import { IconService } from '../../fw/svg/icon.service'; |
| 20 | import { KeyService } from '../../fw/util/key.service'; |
| 21 | import { LoadingService } from '../../fw/layer/loading.service'; |
| 22 | import { LogService } from '../../log.service'; |
| 23 | import { MastService } from '../../fw/mast/mast.service'; |
| 24 | import { NavService } from '../../fw/nav/nav.service'; |
| 25 | import { PanelService } from '../../fw/layer/panel.service'; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 26 | import { TableBaseImpl, TableResponse } from '../../fw/widget/tablebase'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 27 | import { TableDetailService } from '../../fw/widget/tabledetail.service'; |
| 28 | import { WebSocketService } from '../../fw/remote/websocket.service'; |
| 29 | |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 30 | interface DeviceTableResponse extends TableResponse { |
| 31 | devices: Device[]; |
| 32 | } |
| 33 | |
| 34 | interface Device { |
| 35 | available: boolean; |
| 36 | chassisid: string; |
| 37 | hw: string; |
| 38 | id: string; |
| 39 | masterid: string; |
| 40 | mfr: string; |
| 41 | name: string; |
| 42 | num_ports: number; |
| 43 | protocol: string; |
| 44 | serial: string; |
| 45 | sw: string; |
| 46 | _iconid_available: string; |
| 47 | _iconid_type: string; |
| 48 | } |
| 49 | |
| 50 | |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 51 | /** |
| 52 | * ONOS GUI -- Device View Component |
| 53 | */ |
| 54 | @Component({ |
| 55 | selector: 'onos-device', |
| 56 | templateUrl: './device.component.html', |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 57 | styleUrls: ['./device.component.css', './device.theme.css', '../../fw/widget/table.css', '../../fw/widget/table-theme.css'] |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 58 | }) |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 59 | export class DeviceComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 60 | |
| 61 | // TODO: Update for LION |
| 62 | flowTip = 'Show flow view for selected device'; |
| 63 | portTip = 'Show port view for selected device'; |
| 64 | groupTip = 'Show group view for selected device'; |
| 65 | meterTip = 'Show meter view for selected device'; |
| 66 | pipeconfTip = 'Show pipeconf view for selected device'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 67 | |
| 68 | constructor( |
| 69 | private dps: DetailsPanelService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 70 | protected fs: FnService, |
| 71 | protected ls: LoadingService, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 72 | private is: IconService, |
| 73 | private ks: KeyService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 74 | protected log: LogService, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 75 | private mast: MastService, |
| 76 | private nav: NavService, |
| 77 | private ps: PanelService, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 78 | private tds: TableDetailService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 79 | protected wss: WebSocketService, |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame^] | 80 | @Inject('Window') private window: Window, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 81 | ) { |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 82 | super(fs, ls, log, wss, 'device'); |
| 83 | this.responseCallback = this.deviceResponseCb; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | ngOnInit() { |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 87 | this.init(); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 88 | this.log.debug('DeviceComponent initialized'); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | ngOnDestroy() { |
| 92 | this.destroy(); |
| 93 | this.log.debug('DeviceComponent destroyed'); |
| 94 | } |
| 95 | |
| 96 | deviceResponseCb(data: DeviceTableResponse) { |
| 97 | this.log.debug('Device response received for ', data.devices.length, 'devices'); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | } |