blob: 592be6bf29ae185d1b1c9b09ce749fdfa6e26c36 [file] [log] [blame]
Boyuan Yan6b23b382019-06-04 11:59:35 -07001/*
2 * Copyright 2019-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 */
16import { Component, OnInit, OnDestroy} from '@angular/core';
17
18import {
19 FnService,
20 LogService,
21 WebSocketService,
22 SortDir, TableBaseImpl, TableResponse
23} from 'gui2-fw-lib';
24
25import { ActivatedRoute, Router } from '@angular/router';
26
27/**
28 * Model of the response from WebSocket
29 */
30interface RoadmDeviceTableResponse extends TableResponse {
31 roadms: RoadmDevice[];
32}
33
34/**
35 * Model of the ROADM devices returned from the WebSocket
36 */
37interface RoadmDevice {
38 available: boolean;
39 chassisid: string;
40 hwVersion: string;
41 id: string;
42 master: string;
43 Vendor: string;
44 name: string;
45 ports: number;
46 protocol: string;
47 serial: string;
48 swVersion: string;
49 type: string;
50 _iconid_available: string;
51 _iconid_type: string;
52}
53
54
55/**
56 * ONOS GUI -- Roadm Device View Component
57 */
58@Component({
59 selector: 'roadm-device',
60 templateUrl: './roadm.component.html',
61 styleUrls: ['./roadm.component.css', './roadm.theme.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
62})
63export class RoadmDeviceComponent extends TableBaseImpl implements OnInit, OnDestroy {
64
65 // TODO: Update for LION
66 flowTip = 'Show flow view for selected device';
67 portTip = 'Show port view for selected device';
68 groupTip = 'Show group view for selected device';
69 meterTip = 'Show meter view for selected device';
70 pipeconfTip = 'Show pipeconf view for selected device';
71
72 constructor(
73 protected fs: FnService,
74 protected log: LogService,
75 protected as: ActivatedRoute,
76 protected router: Router,
77 protected wss: WebSocketService,
78 ) {
79 super(fs, log, wss, 'roadm');
80 this.responseCallback = this.deviceResponseCb;
81
82 this.as.queryParams.subscribe(params => {
83 this.selId = params['devId'];
84
85 });
86
87 this.payloadParams = {
88 devId: this.selId
89 };
90
91 this.sortParams = {
92 firstCol: 'name',
93 firstDir: SortDir.asc,
94 secondCol: 'id',
95 secondDir: SortDir.desc,
96 };
97 }
98
99 ngOnInit() {
100 this.init();
101 this.log.debug('RoadmDeviceComponent initialized');
102 }
103
104 ngOnDestroy() {
105 this.destroy();
106 this.log.debug('RoadmDeviceComponent destroyed');
107 }
108
109 deviceResponseCb(data: RoadmDeviceTableResponse) {
110 this.log.debug('Device response received for ', data.roadms.length, 'roadm devices');
111 }
112
113 navto(path) {
114 this.log.debug('navigate');
115 if (this.selId) {
116 this.router.navigate([path], { queryParams: { devId: this.selId } });
117 }
118 }
119
120}