blob: 6789e14b06b43d44c97a8dc97e7fa6686dc1d7e4 [file] [log] [blame]
Sean Condonb2c483c2019-01-16 20:28:55 +00001/*
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 */
16import {Component} from '@angular/core';
17import {animate, state, style, transition, trigger} from '@angular/animations';
18import {LogService} from '../../log.service';
19import {FnService} from '../../util/fn.service';
20import {KeysService} from '../../util/keys.service';
21import {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})
41export 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}