Sean Condon | afe47c2 | 2019-12-19 14:28:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-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 | |
| 17 | import { |
| 18 | Component, Input, |
| 19 | OnChanges, |
| 20 | OnDestroy, |
| 21 | OnInit, |
| 22 | SimpleChanges |
| 23 | } from '@angular/core'; |
| 24 | import { |
| 25 | DetailsPanelBaseImpl, |
| 26 | FnService, |
| 27 | IconService, |
| 28 | LogService, WebSocketService |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame^] | 29 | } from 'gui2-fw-lib/public_api'; |
Sean Condon | afe47c2 | 2019-12-19 14:28:06 +0000 | [diff] [blame] | 30 | import {PipeconfAction, PipeconfTable} from '../pipeconf/pipeconf.component'; |
| 31 | import {animate, state, style, transition, trigger} from '@angular/animations'; |
| 32 | |
| 33 | /** |
| 34 | * ONOS GUI -- Pipeconf Detail View Component |
| 35 | */ |
| 36 | @Component({ |
| 37 | selector: 'onos-pipeconfdetails', |
| 38 | templateUrl: './pipeconfdetails.component.html', |
| 39 | styleUrls: ['./pipeconfdetails.component.css', |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 40 | '../../../../../../../../gui2-fw-lib/lib/widget/panel.css', '../../../../../../../../gui2-fw-lib/lib/widget/panel-theme.css'], |
Sean Condon | afe47c2 | 2019-12-19 14:28:06 +0000 | [diff] [blame] | 41 | animations: [ |
| 42 | trigger('pipeconfDetailsState', [ |
| 43 | state('true', style({ |
| 44 | transform: 'translateX(-100%)', |
| 45 | opacity: '100' |
| 46 | })), |
| 47 | state('false', style({ |
| 48 | transform: 'translateX(0%)', |
| 49 | opacity: '0' |
| 50 | })), |
| 51 | transition('0 => 1', animate('100ms ease-in')), |
| 52 | transition('1 => 0', animate('100ms ease-out')) |
| 53 | ]) |
| 54 | ] |
| 55 | }) |
| 56 | export class PipeconfDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges { |
| 57 | @Input() id: string; |
| 58 | @Input() pipeconfTable: PipeconfTable; |
| 59 | @Input() actions: PipeconfAction[] = []; |
| 60 | |
| 61 | constructor(protected fs: FnService, |
| 62 | protected log: LogService, |
| 63 | protected is: IconService, |
| 64 | protected wss: WebSocketService |
| 65 | ) { |
| 66 | super(fs, log, wss, 'device'); |
| 67 | } |
| 68 | |
| 69 | ngOnInit() { |
| 70 | this.init(); |
| 71 | this.log.debug('Pipeconf 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('Pipeconf 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 is empty, no request is made |
| 86 | */ |
| 87 | ngOnChanges(changes: SimpleChanges) { |
| 88 | if (this.id === undefined || this.id === '') { |
| 89 | this.closed = false; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | actionDetails(name: string): PipeconfAction { |
| 94 | for (const action of this.actions) { |
| 95 | if (action.name === name) { |
| 96 | return action; |
| 97 | } |
| 98 | } |
| 99 | this.log.debug('Action not found', name); |
| 100 | } |
| 101 | |
| 102 | } |