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