blob: 99564d0ac603512f20292756c482fe95bb107bd7 [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 { DetailsPanelService } from '../../fw/layer/detailspanel.service';
18import { FnService } from '../../fw/util/fn.service';
19import { IconService } from '../../fw/svg/icon.service';
20import { KeyService } from '../../fw/util/key.service';
21import { LoadingService } from '../../fw/layer/loading.service';
22import { LogService } from '../../log.service';
23import { MastService } from '../../fw/mast/mast.service';
24import { NavService } from '../../fw/nav/nav.service';
25import { PanelService } from '../../fw/layer/panel.service';
Sean Condon2bd11b72018-06-15 08:00:48 +010026import { TableBaseImpl, TableResponse } from '../../fw/widget/tablebase';
Sean Condon83fc39f2018-04-19 18:56:13 +010027import { TableDetailService } from '../../fw/widget/tabledetail.service';
28import { WebSocketService } from '../../fw/remote/websocket.service';
29
Sean Condon2bd11b72018-06-15 08:00:48 +010030interface DeviceTableResponse extends TableResponse {
31 devices: Device[];
32}
33
34interface 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 Condon83fc39f2018-04-19 18:56:13 +010051/**
52 * ONOS GUI -- Device View Component
53 */
54@Component({
55 selector: 'onos-device',
56 templateUrl: './device.component.html',
Sean Condon2bd11b72018-06-15 08:00:48 +010057 styleUrls: ['./device.component.css', './device.theme.css', '../../fw/widget/table.css', '../../fw/widget/table-theme.css']
Sean Condon83fc39f2018-04-19 18:56:13 +010058})
Sean Condon2bd11b72018-06-15 08:00:48 +010059export 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 Condon83fc39f2018-04-19 18:56:13 +010067
68 constructor(
69 private dps: DetailsPanelService,
Sean Condon2bd11b72018-06-15 08:00:48 +010070 protected fs: FnService,
71 protected ls: LoadingService,
Sean Condon83fc39f2018-04-19 18:56:13 +010072 private is: IconService,
73 private ks: KeyService,
Sean Condon2bd11b72018-06-15 08:00:48 +010074 protected log: LogService,
Sean Condon83fc39f2018-04-19 18:56:13 +010075 private mast: MastService,
76 private nav: NavService,
77 private ps: PanelService,
Sean Condon83fc39f2018-04-19 18:56:13 +010078 private tds: TableDetailService,
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}