import { Component , OnInit } from '@angular/core' ; import { EventPageComponent } from '../event-page/event-page.component' ; import { DefinitionService } from '../core/definition/definition.service' ; import { ConfigurationService } from '../core/configuration/configuration.service' ; import openOptionsPage = chrome . runtime . openOptionsPage ; import { ConfigModel } from '../models/config.model' ; import { LookupSource } from '../models/lookup-source.enum' ; @ Component ( { selector : 'app-popup' , templateUrl : './popup.component.html' , styleUrls : [ './popup.component.css' ] } ) export class PopupComponent implements OnInit { config : ConfigModel ; extensionVersion = '' ; searchTerm = '' ; previousSearchTerm = '' ; searchResults = null ; isLoading = false ; constructor ( private definitionService , private configurationService ) { } ngOnInit ( ) { this . populateConfiguration ( ) ; this . populateExtensionVersion ( ) ; } get isBackendOnline ( ) { return ConfigurationService . isBackendOnline ; } /**
     * Populates the configuration
     */ populateConfiguration ( ) { this . configurationService . getConfiguration ( ) . subscribe ( ( config ) => { this . config = config ; } ) ; } /**
     * Populates the extension version
     */ populateExtensionVersion ( ) { this . configurationService . getExtensionVersion ( ) . subscribe ( version => { this . extensionVersion = version ; } ) ; } /**
     * Calls the lookup api and displays the results
     */ lookupTerm ( ) { this . isLoading = true ; this . previousSearchTerm = this . searchTerm . toUpperCase ( ) ; this . definitionService . lookupTerm ( this . searchTerm , LookupSource . popup ) . subscribe ( ( res ) => { this . isLoading = false ; this . searchResults = res ; } ) ; } param email openDefaultEmail ( email ) { EventPageComponent . openDefaultEmail ( email ) ; } /**
     * Open your Extension's options page, if possible.
     */ openOptionsPage ( ) { openOptionsPage ( ) ; } }