Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 1 | /* |
| 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 | import { Component, Input, OnInit, OnDestroy, OnChanges } from '@angular/core'; |
| 17 | import { trigger, state, style, animate, transition } from '@angular/animations'; |
| 18 | import { |
| 19 | FnService, |
| 20 | IconService, |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 21 | LogService, |
| 22 | DetailsPanelBaseImpl, |
| 23 | WebSocketService, |
Sean Condon | 3dd062f | 2020-04-14 09:25:00 +0100 | [diff] [blame] | 24 | } from 'org_onosproject_onos/web/gui2-fw-lib/public_api'; |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 25 | |
| 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 Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 43 | '../../../../../web/gui2-fw-lib/lib/widget/panel.css', |
| 44 | '../../../../../web/gui2-fw-lib/lib/widget/panel-theme.css' |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 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 | }) |
| 61 | export class AlarmDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges { |
| 62 | @Input() id: string; |
| 63 | |
| 64 | constructor( |
| 65 | protected fs: FnService, |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 66 | protected log: LogService, |
| 67 | protected is: IconService, |
| 68 | protected wss: WebSocketService |
| 69 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 70 | super(fs, log, wss, 'alarmTable'); |
Sean Condon | 87b7850 | 2018-09-17 20:53:24 +0100 | [diff] [blame] | 71 | } |
| 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 | } |