blob: 91eb7e6cad82b53e1318ce40e81b8405633be5c7 [file] [log] [blame]
Bhavesh72ead492018-07-19 16:29:18 +05301/*
2 * Copyright 2018-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';
Sean Condon5ca00262018-09-06 17:55:25 +010017import {
18 FnService,
Sean Condon5ca00262018-09-06 17:55:25 +010019 LogService,
20 WebSocketService,
21 SortDir, TableBaseImpl, TableResponse
22} from 'gui2-fw-lib';
Bhavesh72ead492018-07-19 16:29:18 +053023
24/**
25 * Model of the response from WebSocket
26 */
27interface TunnelTableResponse extends TableResponse {
28 tunnels: Tunnel[];
29}
30
31/**
32 * Model of the tunnels returned from the WebSocket
33 */
34interface Tunnel {
35 id: string;
36 name: string;
37 port1: string;
38 port2: string;
39 type: string;
40 groupId: string;
41 bandwidth: string;
42 path: string;
43}
44
45/**
46 * ONOS GUI -- Tunnel View Component
47 */
48@Component({
49 selector: 'onos-tunnel',
50 templateUrl: './tunnel.component.html',
51 styleUrls: ['./tunnel.component.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
52})
53export class TunnelComponent extends TableBaseImpl implements OnInit, OnDestroy {
54
55 constructor(
56 protected fs: FnService,
Bhavesh72ead492018-07-19 16:29:18 +053057 protected log: LogService,
58 protected wss: WebSocketService,
59 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010060 super(fs, log, wss, 'tunnel');
Bhavesh72ead492018-07-19 16:29:18 +053061 this.responseCallback = this.tunnelResponseCb;
62 this.sortParams = {
63 firstCol: 'id',
64 firstDir: SortDir.desc,
65 secondCol: 'name',
66 secondDir: SortDir.asc,
67 };
68 }
69
70 ngOnInit() {
71 this.init();
72 this.log.debug('TunnelComponent initialized');
73 }
74
75 ngOnDestroy() {
76 this.destroy();
77 this.log.debug('TunnelComponent destroyed');
78 }
79
80 tunnelResponseCb(data: TunnelTableResponse) {
81 this.log.debug('Tunnel response received for ', data.tunnels.length, 'tunnels');
82 }
83
84}