import { Component , Input , AfterContentChecked , OnDestroy , ChangeDetectorRef , AfterContentInit , HostBinding , ChangeDetectionStrategy , } from '@angular/core' ; import { AOutputRenderComponent , IOutputRenderInputs , } from '../../../../interfaces/interface.output.render' ; import { IComponentDesc } from 'chipmunk-client-material' ; import { EParent } from '../../../../services/standalone/service.output.redirections' ; import { Subject } from 'rxjs' ; import { ControllerRowAPI } from '../../../../controller/session/dependencies/row/controller.row.api' ; import TabsSessionsService from '../../../../services/service.sessions.tabs' ; import OutputParsersService from '../../../../services/standalone/service.output.parsers' ; @ Component ( { selector : 'app-views-output-row-external' , templateUrl : './template.html' , styleUrls : [ './styles.less' ] , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class ViewOutputRowExternalComponent extends AOutputRenderComponent implements AfterContentInit , AfterContentChecked , OnDestroy { @ Input ( ) public str : string | undefined ; @ Input ( ) public sessionId : string | undefined ; @ Input ( ) public position : number | undefined ; @ Input ( ) public pluginId : number | undefined ; @ Input ( ) public source : string | undefined ; @ Input ( ) public component : IComponentDesc | undefined ; @ Input ( ) public parent ! : EParent ; @ Input ( ) public api ! : ControllerRowAPI ; public _ng_component : IComponentDesc | undefined ; private _subjects : { update : Subject < { [ key ] : any ; } > ; } = { update : new Subject < { [ key ] : any ; } > ( ) , } ; constructor ( private _cdRef ) { super ( ) ; } @ HostBinding ( 'class' ) classes = 'row noreset' ; @ HostBinding ( 'style.background' ) background = '' ; @ HostBinding ( 'style.color' ) color = '' ; public ngOnDestroy ( ) { } public ngAfterContentInit ( ) { this . _setComponent ( ) ; } public ngAfterContentChecked ( ) { } public update ( inputs ) { if ( this . str === undefined ) { return ; } Object . keys ( inputs ) . forEach ( ( key ) => { ( this as any ) [ key ] = ( inputs as any ) [ key ] ; } ) ; this . _subjects . update . next ( { str : this . str , html : this . _getHTML ( this . str ) , } ) ; } private _setComponent ( ) { if ( this . pluginId === - 1 ) { return ; } if ( this . component === undefined || this . str === undefined ) { return ; } if ( TabsSessionsService . getActive ( ) === undefined ) { return ; } this . _ng_component = { factory : this . component . factory , resolved : this . component . resolved , inputs : Object . assign ( { } , this . component . inputs ) , } ; this . _ng_component . inputs = Object . assign ( this . _ng_component . inputs , { str : this . str , html : this . _getHTML ( this . str ) , api : TabsSessionsService . getPluginAPI ( this . pluginId ) , update : this . _subjects . update , } ) ; this . _cdRef . markForCheck ( ) ; } private _getHTML ( str ) { if ( this . sessionId === undefined ) { return OutputParsersService . serialize ( str ) ; } const highlight = OutputParsersService . highlight ( this . sessionId , str , this . parent ) ; str = OutputParsersService . serialize ( str ) ; this . color = highlight . color === undefined ? '' : highlight . color ; this . background = highlight . background === undefined ? '' : highlight . background ; str = OutputParsersService . row ( { str : str , pluginId : this . pluginId , source : this . source , position : this . position , hasOwnStyles : highlight . color !== undefined || highlight . background !== undefined , } , this . parent ) ; return str ; } }