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