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