Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { Component, OnInit, OnDestroy } from '@angular/core'; |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 17 | import { |
| 18 | FnService, |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 19 | LogService, |
| 20 | WebSocketService, |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 21 | SortDir, TableBaseImpl, TableResponse |
Sean Condon | 3dd062f | 2020-04-14 09:25:00 +0100 | [diff] [blame] | 22 | } from 'org_onosproject_onos/web/gui2-fw-lib/public_api'; |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 23 | import { ActivatedRoute } from '@angular/router'; |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Model of the response from WebSocket |
| 27 | */ |
| 28 | interface GroupTableResponse extends TableResponse { |
| 29 | groups: Group[]; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Model of the flows returned from the WebSocket |
| 34 | */ |
| 35 | interface 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 Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 50 | styleUrls: ['./group.component.css', './group.theme.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.theme.css'] |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 51 | }) |
| 52 | export 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, |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 68 | protected wss: WebSocketService, |
| 69 | protected ar: ActivatedRoute, |
| 70 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 71 | super(fs, log, wss, 'group'); |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 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 | } |