blob: f616332fb3e66d1ffcce9abe4d8f94613557c709 [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
Sean Condon3dd062f2020-04-14 09:25:00 +010023} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Boyuan Yan6b23b382019-06-04 11:59:35 -070024
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',
Sean Condon98b6ddb2019-12-24 08:07:40 +000061 styleUrls: ['./roadm.component.css', './roadm.theme.css',
62 '../../../../../../web/gui2-fw-lib/lib/widget/table.css',
63 '../../../../../../web/gui2-fw-lib/lib/widget/table.theme.css'
64 ]
Boyuan Yan6b23b382019-06-04 11:59:35 -070065})
66export class RoadmDeviceComponent extends TableBaseImpl implements OnInit, OnDestroy {
67
68 // TODO: Update for LION
69 flowTip = 'Show flow view for selected device';
70 portTip = 'Show port view for selected device';
71 groupTip = 'Show group view for selected device';
72 meterTip = 'Show meter view for selected device';
73 pipeconfTip = 'Show pipeconf view for selected device';
74
75 constructor(
76 protected fs: FnService,
77 protected log: LogService,
78 protected as: ActivatedRoute,
79 protected router: Router,
80 protected wss: WebSocketService,
81 ) {
82 super(fs, log, wss, 'roadm');
83 this.responseCallback = this.deviceResponseCb;
84
85 this.as.queryParams.subscribe(params => {
86 this.selId = params['devId'];
87
88 });
89
90 this.payloadParams = {
91 devId: this.selId
92 };
93
94 this.sortParams = {
95 firstCol: 'name',
96 firstDir: SortDir.asc,
97 secondCol: 'id',
98 secondDir: SortDir.desc,
99 };
100 }
101
102 ngOnInit() {
103 this.init();
104 this.log.debug('RoadmDeviceComponent initialized');
105 }
106
107 ngOnDestroy() {
108 this.destroy();
109 this.log.debug('RoadmDeviceComponent destroyed');
110 }
111
112 deviceResponseCb(data: RoadmDeviceTableResponse) {
113 this.log.debug('Device response received for ', data.roadms.length, 'roadm devices');
114 }
115
116 navto(path) {
117 this.log.debug('navigate');
118 if (this.selId) {
119 this.router.navigate([path], { queryParams: { devId: this.selId } });
120 }
121 }
122
123}