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