blob: b534c0a225112862b68dda538fdcf2a2d0191319 [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, OnDestroy, OnInit } 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 +053024import { ActivatedRoute } from '@angular/router';
25
26/**
27* Model of the response from WebSocket
28*/
29interface MeterTableResponse extends TableResponse {
30 meters: Meter[];
31}
32
33/**
34* Model of the meter returned from the WebSocket
35*/
36interface Meter {
37 id: string;
38 appId: string;
39 state: string;
40 packets: string;
41 bytes: string;
42}
43
44/**
45 * ONOS GUI -- Meter View Component
46 */
47@Component({
48 selector: 'onos-meter',
49 templateUrl: './meter.component.html',
50 styleUrls: ['./meter.component.css', './meter.theme.css',
51 '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
52})
53export class MeterComponent extends TableBaseImpl implements OnInit, OnDestroy {
54
55 id: string;
56 brief: boolean = true;
57
58 // TODO: Update for LION
59 deviceTip = 'Show device table';
60 detailTip = 'Switch to detail view';
61 flowTip = 'Show flow view for selected device';
62 portTip = 'Show port view for selected device';
63 groupTip = 'Show group view for selected device';
64 pipeconfTip = 'Show pipeconf view for selected device';
65
66 constructor(
67 protected fs: FnService,
68 protected log: LogService,
69 protected ls: LoadingService,
70 protected as: ActivatedRoute,
71 protected wss: WebSocketService,
72 ) {
73 super(fs, ls, log, wss, 'meter');
74 this.as.queryParams.subscribe(params => {
75 this.id = params['devId'];
76 });
77
78 this.payloadParams = {
79 devId: this.id
80 };
81
82 this.responseCallback = this.meterResponseCb;
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.debug('MeterComponent initialized');
94 }
95
96 ngOnDestroy() {
97 this.destroy();
98 this.log.debug('MeterComponent destroyed');
99 }
100
101 meterResponseCb(data: MeterTableResponse) {
102 this.log.debug('Meter response received for ', data.meters.length, 'meter');
103 }
104
105 briefToggle() {
106 this.brief = !this.brief;
107 }
108
109}