Sean Condon | b2c483c | 2019-01-16 20:28:55 +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 | import {Component} from '@angular/core'; |
| 17 | import {animate, state, style, transition, trigger} from '@angular/animations'; |
| 18 | import {LogService} from '../../log.service'; |
| 19 | import {FnService} from '../../util/fn.service'; |
| 20 | import {KeysService} from '../../util/keys.service'; |
| 21 | import {LionService} from '../../util/lion.service'; |
| 22 | |
| 23 | |
| 24 | @Component({ |
| 25 | selector: 'onos-quickhelp', |
| 26 | templateUrl: './quickhelp.component.html', |
| 27 | styleUrls: ['./quickhelp.component.css'], |
| 28 | animations: [ |
| 29 | trigger('quickHelpState', [ |
| 30 | state('true', style({ |
| 31 | opacity: '1.0', |
| 32 | })), |
| 33 | state('false', style({ |
| 34 | opacity: '0.0', |
| 35 | })), |
| 36 | transition('0 => 1', animate('500ms ease-in')), |
| 37 | transition('1 => 0', animate('500ms ease-out')) |
| 38 | ]) |
| 39 | ] |
| 40 | }) |
| 41 | export class QuickhelpComponent { |
| 42 | lionFn; // Function |
| 43 | |
| 44 | constructor( |
| 45 | private log: LogService, |
| 46 | private fs: FnService, |
| 47 | public ks: KeysService, |
| 48 | private lion: LionService |
| 49 | ) { |
| 50 | if (this.lion.ubercache.length === 0) { |
| 51 | this.lionFn = this.dummyLion; |
| 52 | this.lion.loadCbs.set('quickhelp', () => this.doLion()); |
| 53 | } else { |
| 54 | this.doLion(); |
| 55 | } |
| 56 | |
| 57 | this.log.debug('Quickhelp component constructed'); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Read the LION bundle for Toolbar and set up the lionFn |
| 62 | */ |
| 63 | doLion() { |
| 64 | this.lionFn = this.lion.bundle('core.fw.QuickHelp'); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * A dummy implementation of the lionFn until the response is received and the LION |
| 69 | * bundle is received from the WebSocket |
| 70 | */ |
| 71 | dummyLion(key: string): string { |
| 72 | return '%' + key + '%'; |
| 73 | } |
| 74 | } |