1 import { Component, OnInit, OnDestroy, Input } from '@angular/core'
2 import { Subscription } from 'rxjs'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { HotkeysService, Hotkey } from 'angular2-hotkeys'
7 selector : 'my-hotkeys-cheatsheet',
8 templateUrl : './hotkeys.component.html',
9 styleUrls: [ './hotkeys.component.scss' ]
11 export class CheatSheetComponent implements OnInit, OnDestroy {
12 @Input() title = this.i18n('Keyboard Shortcuts:')
14 subscription: Subscription
19 private hotkeysService: HotkeysService,
23 public ngOnInit (): void {
24 this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => {
25 if (isOpen !== false) {
26 this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description)
29 if (isOpen === false) {
30 this.helpVisible = false
32 this.toggleCheatSheet()
37 public ngOnDestroy (): void {
38 if (this.subscription) {
39 this.subscription.unsubscribe()
43 public toggleCheatSheet (): void {
44 this.helpVisible = !this.helpVisible