blob: 76b628e0e8a1f6e10dab7af723fe60af43320719 [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 */
16import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
17import { animate, state, style, transition, trigger } from '@angular/animations';
Sean Condon5ca00262018-09-06 17:55:25 +010018import {
19 FnService,
20 IconService,
Sean Condon5ca00262018-09-06 17:55:25 +010021 LogService,
22 DetailsPanelBaseImpl,
23 WebSocketService
24} from 'gui2-fw-lib';
Bhavesh72ead492018-07-19 16:29:18 +053025
26/**
27 * The details view when a port row is clicked from the Port view
28 *
29 * This is expected to be passed an 'id' and it makes a call
30 * to the WebSocket with an portDetailsRequest, and gets back an
31 * portDetailsResponse.
32 *
33 * The animated fly-in is controlled by the animation below
34 * The portDetailsState is attached to port-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-portdetails',
40 templateUrl: './portdetails.component.html',
41 styleUrls: ['./portdetails.component.css', '../../../fw/widget/panel.css', '../../../fw/widget/panel-theme.css'],
42 animations: [
43 trigger('portDetailsState', [
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 PortDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
58 @Input() id: string;
59 @Input() devId: string;
60
61 constructor(protected fs: FnService,
Bhavesh72ead492018-07-19 16:29:18 +053062 protected log: LogService,
63 protected is: IconService,
64 protected wss: WebSocketService
65 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010066 super(fs, log, wss, 'port');
Bhavesh72ead492018-07-19 16:29:18 +053067 }
68
69 ngOnInit() {
70 this.init();
71 this.log.debug('App Details Component initialized:', this.id);
72 }
73
74 /**
75 * Stop listening to appDetailsResponse on WebSocket
76 */
77 ngOnDestroy() {
78 this.destroy();
79 this.log.debug('App 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 or devId is empty, no request is made
86 */
87 ngOnChanges() {
88 if (this.id === '' || this.devId === '') {
89 return '';
90 } else {
91 const query = {
92 'id': this.id,
93 'devId': this.devId
94 };
95 this.requestDetailsPanelData(query);
96 }
97 }
98
99}