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