blob: fbb58ba58786387772cf35a1b961d19a53e310d0 [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,
Sean Condon5ca00262018-09-06 17:55:25 +010021 SortDir, TableBaseImpl, TableResponse
Sean Condon98b6ddb2019-12-24 08:07:40 +000022} from '../../../../../../../../gui2-fw-lib/public_api';
Bhavesh72ead492018-07-19 16:29:18 +053023import { ActivatedRoute } from '@angular/router';
Bhavesh72ead492018-07-19 16:29:18 +053024
25/**
26 * Model of the response from WebSocket
27 */
28interface GroupTableResponse extends TableResponse {
29 groups: Group[];
30}
31
32/**
33 * Model of the flows returned from the WebSocket
34 */
35interface Group {
36 id: string;
37 app_id: string;
38 state: string;
39 type: string;
40 packets: string;
41 bytes: string;
42}
43
44/**
45 * ONOS GUI -- Group View Component
46 */
47@Component({
48 selector: 'onos-group',
49 templateUrl: './group.component.html',
Sean Condon98b6ddb2019-12-24 08:07:40 +000050 styleUrls: ['./group.component.css', './group.theme.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.theme.css']
Bhavesh72ead492018-07-19 16:29:18 +053051})
52export class GroupComponent extends TableBaseImpl implements OnInit, OnDestroy {
53 id: string;
54 brief: boolean;
55
56 // TODO: Update for LION
57 deviceTip = 'Show device table';
58 detailTip = 'Switch to detailed view';
59 briefTip = 'Switch to brief view';
60 flowTip = 'Show flow view for selected device';
61 portTip = 'Show port view for selected device';
62 meterTip = 'Show meter view for selected device';
63 pipeconfTip = 'Show pipeconf view for selected device';
64
65 constructor(
66 protected log: LogService,
67 protected fs: FnService,
Bhavesh72ead492018-07-19 16:29:18 +053068 protected wss: WebSocketService,
69 protected ar: ActivatedRoute,
70 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010071 super(fs, log, wss, 'group');
Bhavesh72ead492018-07-19 16:29:18 +053072 this.ar.queryParams.subscribe(params => {
73 this.id = params['devId'];
74 });
75 this.brief = true;
76
77 this.payloadParams = {
78 devId: this.id
79 };
80
81 this.responseCallback = this.groupResponseCb;
82
83 this.sortParams = {
84 firstCol: 'id',
85 firstDir: SortDir.desc,
86 secondCol: 'app_id',
87 secondDir: SortDir.asc,
88 };
89 }
90
91 ngOnInit() {
92 this.init();
93 this.log.info('GroupComponent initialized');
94 }
95
96 ngOnDestroy() {
97 this.destroy();
98 this.log.info('GroupComponent destroyed');
99 }
100
101 groupResponseCb(data: GroupTableResponse) {
102 this.log.debug('Group response received for ', data.groups.length, 'group');
103 }
104
105 briefToggle() {
106 this.brief = !this.brief;
107 }
108
109}