import { PortalResources } from 'app/shared/models/portal-resources' ; import { PortalService } from './../shared/services/portal.service' ; import { TranslateService } from '@ngx-translate/core' ; import { BroadcastService } from './../shared/services/broadcast.service' ; import { FunctionAppService } from 'app/shared/services/function-app.service' ; import { Component , Input , Output } from '@angular/core' ; import { RuntimeExtension } from '../shared/models/binding' ; import { BehaviorSubject } from 'rxjs/BehaviorSubject' ; import { BaseExtensionInstallComponent } from 'app/extension-install/base-extension-install-component' ; import { AiService } from '../shared/services/ai.service' ; import { FunctionAppContext } from 'app/shared/function-app-context' ; import { errorIds } from 'app/shared/models/error-ids' ; import { FunctionService } from 'app/shared/services/function.service' ; @ Component ( { selector : 'extension-install' , templateUrl : './extension-install.component.html' , styleUrls : [ './extension-install.component.scss' ] , } ) export class ExtensionInstallComponent extends BaseExtensionInstallComponent { @ Input ( ) integrateText ; @ Input ( ) loading = false ; @ Input ( ) installing = false ; @ Output ( ) installed : BehaviorSubject < boolean > = new BehaviorSubject ( false ) ; constructor ( broadcastService , translateService , public aiService , portalService , functionService , _functionAppService ) { super ( 'extension-install' , _functionAppService , broadcastService , aiService , translateService , portalService , functionService ) ; } @ Input ( ) set requiredExtensions ( inputExtensions ) { this . runtimeExtensions = inputExtensions ; if ( this . runtimeExtensions && this . runtimeExtensions . length > 0 ) { this . loading = true ; this . getNeededExtensions ( this . runtimeExtensions ) . subscribe ( extensions => { this . loading = false ; this . neededExtensions = extensions ; this . installed . next ( this . neededExtensions . length === 0 ) ; } ) ; } else { this . installed . next ( true ) ; this . neededExtensions = [ ] ; } } showInstallFailed ( context , id ) { this . installFailed = true ; this . showComponentError ( { message : this . translateService . instant ( PortalResources . failedToInstallFunctionRuntimeExtensionForId , { installationId : id } ) , errorId : errorIds . timeoutInstallingFunctionRuntimeExtension , resourceId : context . site . id , } ) ; this . aiService . trackEvent ( errorIds . timeoutInstallingFunctionRuntimeExtension , { content : this . translateService . instant ( PortalResources . failedToInstallFunctionRuntimeExtension ) , } ) ; } }