blob: 9429064f46a49e15db572b925daad35b39edff9b [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
Sean Condon3dd062f2020-04-14 09:25:00 +010022} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Bhavesh72ead492018-07-19 16:29:18 +053023
24/**
25 * Model of the response from WebSocket
26 */
27interface LinkTableResponse extends TableResponse {
28 links: Link[];
29}
30
31/**
32 * Model of the links returned from the WebSocket
33 */
34interface Link {
35 one: string;
36 two: string;
37 type: string;
38 direction: string;
39 durable: string;
40 _iconid_state: string;
41}
42
43/**
44 * ONOS GUI -- Link View Component
45 */
46@Component({
47 selector: 'onos-link',
48 templateUrl: './link.component.html',
Sean Condon98b6ddb2019-12-24 08:07:40 +000049 styleUrls: ['./link.component.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.theme.css']
Bhavesh72ead492018-07-19 16:29:18 +053050})
51export class LinkComponent extends TableBaseImpl implements OnInit, OnDestroy {
52
53 constructor(
54 protected fs: FnService,
Bhavesh72ead492018-07-19 16:29:18 +053055 protected log: LogService,
56 protected wss: WebSocketService,
57 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010058 super(fs, log, wss, 'link');
Bhavesh72ead492018-07-19 16:29:18 +053059 this.responseCallback = this.linkResponseCb;
60 this.sortParams = {
61 firstCol: 'one',
62 firstDir: SortDir.desc,
63 secondCol: 'two',
64 secondDir: SortDir.asc,
65 };
66 }
67
68 ngOnInit() {
69 this.init();
70 this.log.debug('LinkComponent initialized');
71 }
72
73 ngOnDestroy() {
74 this.destroy();
75 this.log.debug('LinkComponent destroyed');
76 }
77
78 linkResponseCb(data: LinkTableResponse) {
79 this.log.debug('Link response received for ', data.links.length, 'links');
80 }
81}