blob: bc74b6a5d2348a8abe208919cdbd8cb551b291f0 [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';
17import { TableBaseImpl, TableResponse, SortDir } from '../../../fw/widget/table.base';
18import { FnService } from '../../../fw/util/fn.service';
19import { LoadingService } from '../../../fw/layer/loading.service';
20import { LogService } from '../../../log.service';
21import { WebSocketService } from '../../../fw/remote/websocket.service';
22
23/**
24 * Model of the data returned through the Web Socket about settings.
25 */
26interface SettingsTableResponse extends TableResponse {
27 settings: Settings[];
28}
29
30/**
31 * Model of the data returned through Web Socket for a single settings
32 */
33export interface Settings {
34 fqComponent: string;
35 component: string;
36 prop: string;
37 type: string;
38 value: number;
39 defValue: number;
40 desc: string;
41}
42
43/**
44 * ONOS GUI -- Settings View Component
45 */
46@Component({
47 selector: 'onos-settings',
48 templateUrl: './settings.component.html',
49 styleUrls: ['./settings.component.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
50})
51
52export class SettingsComponent extends TableBaseImpl implements OnInit, OnDestroy {
53
54 settingsDetails: Settings;
55
56 constructor(
57 protected fs: FnService,
58 protected ls: LoadingService,
59 protected log: LogService,
60 protected wss: WebSocketService
61 ) {
62 super(fs, ls, log, wss, 'setting');
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}