blob: 13c939fa1b0828804ff36820c93caaa16914a471 [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, Input, OnDestroy, OnChanges } from '@angular/core';
Sean Condon5ca00262018-09-06 17:55:25 +010017import {
18 FnService,
Sean Condon5ca00262018-09-06 17:55:25 +010019 LogService,
20 DetailsPanelBaseImpl,
21 WebSocketService
Sean Condon3dd062f2020-04-14 09:25:00 +010022} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053023import { trigger, state, style, transition, animate } from '@angular/animations';
24import { Settings } from '../settings/settings.component';
25
26/**
27 * The details view when a host row is clicked from the Settings view
28 *
29 * This is expected to be passed an 'id' and it makes a call
30 * to the WebSocket with an hostDetailsRequest, and gets back an
31 * hostDetailsResponse.
32 *
33 * The animated fly-in is controlled by the animation below
34 * The hostDetailsState is attached to host-details-panel
35 * and is false (flies out) when id='' and true (flies in) when
36 * id has a value
37 */
38@Component({
39 selector: 'onos-settingsdetails',
40 templateUrl: './settingsdetails.component.html',
Sean Condon98b6ddb2019-12-24 08:07:40 +000041 styleUrls: ['./settingsdetails.component.css', '../../../../../../../../gui2-fw-lib/lib/widget/panel.css', '../../../../../../../../gui2-fw-lib/lib/widget/panel-theme.css'],
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053042 animations: [
43 trigger('settingsDetailsState', [
44 state('true', style({
45 transform: 'translateX(-100%)',
46 opacity: '100'
47 })),
48 state('false', style({
49 transform: 'translateX(0%)',
50 opacity: '0'
51 })),
52 transition('0 => 1', animate('100ms ease-in')),
53 transition('1 => 0', animate('100ms ease-out'))
54 ])
55 ]
56})
57export class SettingsDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
58
59 @Input() id: string;
60 @Input() settingsDetails: Settings;
61
62 constructor(
63 protected fs: FnService,
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053064 protected log: LogService,
65 protected wss: WebSocketService
66 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010067 super(fs, log, wss, 'setting');
Bhavesh Kumard0b8bae2018-07-31 16:56:43 +053068 }
69
70 ngOnInit() {
71 this.init();
72 this.log.debug('Settings Details Component initialized:', this.id);
73 }
74
75 ngOnDestroy() {
76 this.destroy();
77 this.log.debug('Settings Details Component destroyed');
78 }
79
80 /**
81 * Details Panel Data Request on row selection changes
82 * Should be called whenever id changes
83 * If id is empty, no request is made
84 */
85 ngOnChanges() {
86 if (this.id === '') {
87 return '';
88 } else {
89 const query = {
90 'id': this.id
91 };
92 this.requestDetailsPanelData(query);
93 }
94 }
95
96}