blob: ecccc348aed182808dfd391a047f98519a4dcd59 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
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 Condona00bf382018-06-23 07:54:01 +010016import { Component, OnInit, OnDestroy, Inject } from '@angular/core';
Sean Condon83fc39f2018-04-19 18:56:13 +010017import { FnService } from '../../fw/util/fn.service';
18import { IconService } from '../../fw/svg/icon.service';
19import { KeyService } from '../../fw/util/key.service';
20import { LoadingService } from '../../fw/layer/loading.service';
21import { LogService } from '../../log.service';
22import { MastService } from '../../fw/mast/mast.service';
23import { NavService } from '../../fw/nav/nav.service';
Sean Condon28ecc5f2018-06-25 12:50:16 +010024import { TableBaseImpl, TableResponse } from '../../fw/widget/table.base';
Sean Condon83fc39f2018-04-19 18:56:13 +010025import { WebSocketService } from '../../fw/remote/websocket.service';
26
Sean Condon28ecc5f2018-06-25 12:50:16 +010027/**
28 * Model of the response from WebSocket
29 */
Sean Condon2bd11b72018-06-15 08:00:48 +010030interface DeviceTableResponse extends TableResponse {
31 devices: Device[];
32}
33
Sean Condon28ecc5f2018-06-25 12:50:16 +010034/**
35 * Model of the devices returned from the WebSocket
36 */
Sean Condon2bd11b72018-06-15 08:00:48 +010037interface Device {
38 available: boolean;
39 chassisid: string;
40 hw: string;
41 id: string;
42 masterid: string;
43 mfr: string;
44 name: string;
45 num_ports: number;
46 protocol: string;
47 serial: string;
48 sw: string;
49 _iconid_available: string;
50 _iconid_type: string;
51}
52
53
Sean Condon83fc39f2018-04-19 18:56:13 +010054/**
55 * ONOS GUI -- Device View Component
56 */
57@Component({
58 selector: 'onos-device',
59 templateUrl: './device.component.html',
Sean Condon28ecc5f2018-06-25 12:50:16 +010060 styleUrls: ['./device.component.css', './device.theme.css', '../../fw/widget/table.css', '../../fw/widget/table.theme.css']
Sean Condon83fc39f2018-04-19 18:56:13 +010061})
Sean Condon2bd11b72018-06-15 08:00:48 +010062export class DeviceComponent extends TableBaseImpl implements OnInit, OnDestroy {
63
64 // TODO: Update for LION
65 flowTip = 'Show flow view for selected device';
66 portTip = 'Show port view for selected device';
67 groupTip = 'Show group view for selected device';
68 meterTip = 'Show meter view for selected device';
69 pipeconfTip = 'Show pipeconf view for selected device';
Sean Condon83fc39f2018-04-19 18:56:13 +010070
71 constructor(
Sean Condon2bd11b72018-06-15 08:00:48 +010072 protected fs: FnService,
73 protected ls: LoadingService,
Sean Condon83fc39f2018-04-19 18:56:13 +010074 private is: IconService,
75 private ks: KeyService,
Sean Condon2bd11b72018-06-15 08:00:48 +010076 protected log: LogService,
Sean Condon83fc39f2018-04-19 18:56:13 +010077 private mast: MastService,
78 private nav: NavService,
Sean Condon2bd11b72018-06-15 08:00:48 +010079 protected wss: WebSocketService,
Sean Condona00bf382018-06-23 07:54:01 +010080 @Inject('Window') private window: Window,
Sean Condon83fc39f2018-04-19 18:56:13 +010081 ) {
Sean Condon2bd11b72018-06-15 08:00:48 +010082 super(fs, ls, log, wss, 'device');
83 this.responseCallback = this.deviceResponseCb;
Sean Condon83fc39f2018-04-19 18:56:13 +010084 }
85
86 ngOnInit() {
Sean Condon2bd11b72018-06-15 08:00:48 +010087 this.init();
Sean Condon83fc39f2018-04-19 18:56:13 +010088 this.log.debug('DeviceComponent initialized');
Sean Condon2bd11b72018-06-15 08:00:48 +010089 }
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 Condon83fc39f2018-04-19 18:56:13 +010098 }
99
100}