Bhavesh Kumar | d0b8bae | 2018-07-31 16:56:43 +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, |
| 21 | SortDir, TableBaseImpl, TableResponse |
| 22 | } from 'gui2-fw-lib'; |
Bhavesh Kumar | d0b8bae | 2018-07-31 16:56:43 +0530 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Model of the data returned through the Web Socket about settings. |
| 26 | */ |
| 27 | interface SettingsTableResponse extends TableResponse { |
| 28 | settings: Settings[]; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Model of the data returned through Web Socket for a single settings |
| 33 | */ |
| 34 | export interface Settings { |
| 35 | fqComponent: string; |
| 36 | component: string; |
| 37 | prop: string; |
| 38 | type: string; |
| 39 | value: number; |
| 40 | defValue: number; |
| 41 | desc: string; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * ONOS GUI -- Settings View Component |
| 46 | */ |
| 47 | @Component({ |
| 48 | selector: 'onos-settings', |
| 49 | templateUrl: './settings.component.html', |
| 50 | styleUrls: ['./settings.component.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css'] |
| 51 | }) |
| 52 | |
| 53 | export class SettingsComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 54 | |
| 55 | settingsDetails: Settings; |
| 56 | |
| 57 | constructor( |
| 58 | protected fs: FnService, |
Bhavesh Kumar | d0b8bae | 2018-07-31 16:56:43 +0530 | [diff] [blame] | 59 | protected log: LogService, |
| 60 | protected wss: WebSocketService |
| 61 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 62 | super(fs, log, wss, 'setting'); |
Bhavesh Kumar | d0b8bae | 2018-07-31 16:56:43 +0530 | [diff] [blame] | 63 | this.responseCallback = this.settingsResponseCb; |
| 64 | this.parentSelCb = this.rowSelection; |
| 65 | |
| 66 | this.sortParams = { |
| 67 | firstCol: 'component', |
| 68 | firstDir: SortDir.desc, |
| 69 | secondCol: 'prop', |
| 70 | secondDir: SortDir.asc, |
| 71 | }; |
| 72 | } |
| 73 | |
| 74 | ngOnInit() { |
| 75 | this.init(); |
| 76 | this.log.debug('SettingsComponent initialized'); |
| 77 | } |
| 78 | |
| 79 | ngOnDestroy() { |
| 80 | this.destroy(); |
| 81 | this.log.debug('SettingsComponent destroyed'); |
| 82 | } |
| 83 | |
| 84 | settingsResponseCb(data: SettingsTableResponse) { |
| 85 | this.log.debug('Settings response received for ', data.settings.length, 'settings'); |
| 86 | } |
| 87 | |
| 88 | rowSelection(event: any, row: any) { |
| 89 | this.settingsDetails = row; |
| 90 | } |
| 91 | } |