blob: fc6e9bd5da93748fa2e6838931f1ce8ba35733ea [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';
17import { LogService } from '../../../log.service';
18import { FnService } from '../../../fw/util/fn.service';
19import { LoadingService } from '../../../fw/layer/loading.service';
20import { WebSocketService } from '../../../fw/remote/websocket.service';
21import { ActivatedRoute } from '@angular/router';
22import { TableResponse, TableBaseImpl, SortDir } from '../../../fw/widget/table.base';
23
24/**
25 * Model of the response from WebSocket
26 */
27interface GroupTableResponse extends TableResponse {
28 groups: Group[];
29}
30
31/**
32 * Model of the flows returned from the WebSocket
33 */
34interface Group {
35 id: string;
36 app_id: string;
37 state: string;
38 type: string;
39 packets: string;
40 bytes: string;
41}
42
43/**
44 * ONOS GUI -- Group View Component
45 */
46@Component({
47 selector: 'onos-group',
48 templateUrl: './group.component.html',
49 styleUrls: ['./group.component.css', './group.theme.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
50})
51export class GroupComponent extends TableBaseImpl implements OnInit, OnDestroy {
52 id: string;
53 brief: boolean;
54
55 // TODO: Update for LION
56 deviceTip = 'Show device table';
57 detailTip = 'Switch to detailed view';
58 briefTip = 'Switch to brief view';
59 flowTip = 'Show flow view for selected device';
60 portTip = 'Show port view for selected device';
61 meterTip = 'Show meter view for selected device';
62 pipeconfTip = 'Show pipeconf view for selected device';
63
64 constructor(
65 protected log: LogService,
66 protected fs: FnService,
67 protected ls: LoadingService,
68 protected wss: WebSocketService,
69 protected ar: ActivatedRoute,
70 ) {
71 super(fs, ls, log, wss, 'group');
72 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}