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