blob: b2444adedf571b37b9a6f983d4c657f01f6975d4 [file] [log] [blame]
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +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';
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';
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053023
24/**
25 * Model of the data returned through the Web Socket about settings.
26 */
27interface SettingsTableResponse extends TableResponse {
28 settings: Settings[];
29}
30
31/**
32 * Model of the data returned through Web Socket for a single settings
33 */
34export 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
53export class SettingsComponent extends TableBaseImpl implements OnInit, OnDestroy {
54
55 settingsDetails: Settings;
56
57 constructor(
58 protected fs: FnService,
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053059 protected log: LogService,
60 protected wss: WebSocketService
61 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010062 super(fs, log, wss, 'setting');
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053063 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}