blob: 5efe0a8c9a4b89e2acf7624c9b7431c157f7aaa1 [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,
Sean Condon87b78502018-09-17 20:53:24 +010021 LogService,
22 DetailsPanelBaseImpl,
23 WebSocketService,
Sean Condon3dd062f2020-04-14 09:25:00 +010024} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condon87b78502018-09-17 20:53:24 +010025
26/**
27 * ONOS GUI -- Alarm Details Component extends TableBaseImpl
28 * The details view when an alarm row is clicked from the Alarm view
29 *
30 * This is expected to be passed an 'id' and it makes a call
31 * to the WebSocket with an alarmDetailsRequest, and gets back an
32 * alarmDetailsResponse.
33 *
34 * The animated fly-in is controlled by the animation below
35 * The alarmDetailsState is attached to alarm-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-alarmdetails',
41 templateUrl: './alarmdetails.component.html',
42 styleUrls: ['./alarmdetails.component.css',
Sean Condon98b6ddb2019-12-24 08:07:40 +000043 '../../../../../web/gui2-fw-lib/lib/widget/panel.css',
44 '../../../../../web/gui2-fw-lib/lib/widget/panel-theme.css'
Sean Condon87b78502018-09-17 20:53:24 +010045 ],
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,
Sean Condon87b78502018-09-17 20:53:24 +010066 protected log: LogService,
67 protected is: IconService,
68 protected wss: WebSocketService
69 ) {
Sean Condon95fb5742019-04-02 12:16:55 +010070 super(fs, log, wss, 'alarmTable');
Sean Condon87b78502018-09-17 20:53:24 +010071 }
72
73 ngOnInit() {
74 this.init();
75 this.log.debug('Alarm Table Details Component initialized:', this.id);
76 }
77
78 /**
79 * Stop listening to alarmTableDetailsResponse on WebSocket
80 */
81 ngOnDestroy() {
82 this.destroy();
83 this.log.debug('Alarm Table Details Component destroyed');
84 }
85
86 /**
87 * Details Panel Data Request on row selection changes
88 * Should be called whenever id changes
89 * If id is empty, no request is made
90 */
91 ngOnChanges() {
92 if (this.id === '') {
93 return '';
94 } else {
95 const query = {
96 'id': this.id
97 };
98 this.requestDetailsPanelData(query);
99 }
100 }
101}