blob: a7de1397a5c33af5b1791e5202c261e743754a8d [file] [log] [blame]
Sean Condond6f95bf2020-01-21 10:10:23 +00001/*
2 * Copyright 2020-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 {
18 Component,
19 Input,
20 OnInit,
21 OnDestroy,
22 OnChanges,
23 SimpleChanges
24} from '@angular/core';
25import {trigger, state, style, animate, transition} from '@angular/animations';
26import {
27 FnService,
28 IconService,
29 LogService,
30 DetailsPanelBaseImpl,
31 WebSocketService,
32} from 'gui2-fw-lib/public_api';
33
34@Component({
35 selector: 'onos-yangdetails',
36 templateUrl: './yangdetails.component.html',
37 styleUrls: [
38 './yangdetails.component.scss', './yangdetails.theme.scss',
39 '../../../../../web/gui2-fw-lib/lib/widget/panel.css',
40 '../../../../../web/gui2-fw-lib/lib/widget/panel-theme.css'
41 ],
42 animations: [
43 trigger('yangDetailsState', [
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 YangDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
58 @Input() id: string;
59 @Input() modelId: string;
60 @Input() revision: string;
61
62 constructor(
63 protected fs: FnService,
64 protected log: LogService,
65 protected is: IconService,
66 protected wss: WebSocketService
67 ) {
68 super(fs, log, wss, 'yangModel');
69 }
70
71 ngOnInit() {
72 this.init();
73 this.log.debug('Yang Table Details Component initialized:', this.id);
74 }
75
76 /**
77 * Stop listening to alarmTableDetailsResponse on WebSocket
78 */
79 ngOnDestroy() {
80 this.destroy();
81 this.log.debug('Yang Table Details Component destroyed');
82 }
83
84 /**
85 * Details Panel Data Request on row selection changes
86 * Should be called whenever id changes
87 * If id is empty, no request is made
88 */
89 ngOnChanges(changes: SimpleChanges) {
90 console.log('Change happened', changes);
91 if (changes['id']) {
92 if (this.id === '') {
93 this.modelId = '';
94 this.revision = '';
95 return '';
96 } else {
97 const query = {
98 'id': this.id,
99 'modelId': this.modelId,
100 'revision': this.revision
101 };
102 this.requestDetailsPanelData(query);
103 }
104 }
105 }
106}