{"version":3,"sources":["../../src/app/components/terminal/terminalservice.ts","../../src/app/components/terminal/terminal.ts"],"names":["TerminalService","this","commandSource","Subject","responseSource","commandHandler","asObservable","responseHandler","prototype","sendCommand","command","next","sendResponse","response","Injectable","Terminal","el","terminalService","cd","_this","commands","subscription","subscribe","length","commandProcessed","ngAfterViewInit","container","DomHandler","find","nativeElement","ngAfterViewChecked","scrollTop","scrollHeight","Object","defineProperty","value","handleCommand","event","keyCode","push","text","focus","element","ngOnDestroy","unsubscribe","Component","args","selector","template","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","ChangeDetectorRef","Input","NgModule","imports","CommonModule","FormsModule","exports","declarations"],"mappings":"mjBAGA,SAAAA,IAGYC,KAAAC,cAAgB,IAAIC,EAAAA,QACpBF,KAAAG,eAAiB,IAAID,EAAAA,QAE7BF,KAAAI,eAAiBJ,KAAKC,cAAcI,eACpCL,KAAAM,gBAAkBN,KAAKG,eAAeE,sBAEtCN,EAAAQ,UAAAC,YAAA,SAAYC,GACJA,GACAT,KAAKC,cAAcS,KAAKD,IAIhCV,EAAAQ,UAAAI,aAAA,SAAaC,GACLA,GACAZ,KAAKG,eAAeO,KAAKE,6BAjBpCC,EAAAA,8BC8CG,SAAAC,EAAmBC,EAAuBC,EAAyCC,GAAnF,IAAAC,EAAAlB,KAAmBA,KAAAe,GAAAA,EAAuBf,KAAAgB,gBAAAA,EAAyChB,KAAAiB,GAAAA,EAVnFjB,KAAAmB,SAAkB,GAWdnB,KAAKoB,aAAeJ,EAAgBV,gBAAgBe,WAAU,SAAAT,GAC1DM,EAAKC,SAASD,EAAKC,SAASG,OAAS,GAAGV,SAAWA,EACnDM,EAAKK,kBAAmB,YAIhCT,EAAAP,UAAAiB,gBAAA,WACIxB,KAAKyB,UAAYC,EAAAA,WAAWC,KAAK3B,KAAKe,GAAGa,cAAe,eAAe,IAG3Ed,EAAAP,UAAAsB,mBAAA,WACQ7B,KAAKuB,mBACLvB,KAAKyB,UAAUK,UAAY9B,KAAKyB,UAAUM,aAC1C/B,KAAKuB,kBAAmB,IAIhCS,OAAAC,eACInB,EAAAP,UAAA,WAAQ,KADZ,SACa2B,GACLA,IACAlC,KAAKmB,SAASnB,KAAKmB,SAASG,OAAS,GAAGV,SAAWsB,EACnDlC,KAAKuB,kBAAmB,oCAIhCT,EAAAP,UAAA4B,cAAA,SAAcC,GACW,IAAjBA,EAAMC,UACNrC,KAAKmB,SAASmB,KAAK,CAACC,KAAMvC,KAAKS,UAC/BT,KAAKgB,gBAAgBR,YAAYR,KAAKS,SACtCT,KAAKS,QAAU,KAIvBK,EAAAP,UAAAiC,MAAA,SAAMC,GACFA,EAAQD,SAGZ1B,EAAAP,UAAAmC,YAAA,WACQ1C,KAAKoB,cACLpB,KAAKoB,aAAauB,wCAlF7BC,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,aACVC,SAAU,i3BAgBVC,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,yTA1BqCC,EAAAA,kBAIlEvD,SAJyHwD,EAAAA,6DA+B5HC,EAAAA,sBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,wBA8BAA,EAAAA,eAiCL,iCALCC,EAAAA,SAAQZ,KAAA,CAAC,CACNa,QAAS,CAACC,EAAAA,aAAaC,EAAAA,aACvBC,QAAS,CAAC/C,GACVgD,aAAc,CAAChD","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable()\nexport class TerminalService {\n \n private commandSource = new Subject();\n private responseSource = new Subject();\n \n commandHandler = this.commandSource.asObservable();\n responseHandler = this.responseSource.asObservable();\n \n sendCommand(command: string) {\n if (command) {\n this.commandSource.next(command);\n }\n }\n \n sendResponse(response: string) {\n if (response) {\n this.responseSource.next(response);\n }\n }\n}","import {NgModule,Component,AfterViewInit,AfterViewChecked,OnDestroy,Input,ElementRef,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\nimport {TerminalService} from './terminalservice';\nimport {Subscription} from 'rxjs';\n\n@Component({\n selector: 'p-terminal',\n template: `\n
\n
{{welcomeMessage}}
\n
\n
\n {{prompt}}\n {{command.text}}\n
{{command.response}}
\n
\n
\n
\n {{prompt}}\n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./terminal.css']\n})\nexport class Terminal implements AfterViewInit,AfterViewChecked,OnDestroy {\n\n @Input() welcomeMessage: string;\n\n @Input() prompt: string;\n \n @Input() style: any;\n \n @Input() styleClass: string;\n \n commands: any[] = [];\n \n command: string;\n \n container: Element;\n \n commandProcessed: boolean;\n \n subscription: Subscription;\n \n constructor(public el: ElementRef, public terminalService: TerminalService, public cd: ChangeDetectorRef) {\n this.subscription = terminalService.responseHandler.subscribe(response => {\n this.commands[this.commands.length - 1].response = response;\n this.commandProcessed = true;\n });\n }\n \n ngAfterViewInit() {\n this.container = DomHandler.find(this.el.nativeElement, '.p-terminal')[0];\n }\n \n ngAfterViewChecked() {\n if (this.commandProcessed) {\n this.container.scrollTop = this.container.scrollHeight;\n this.commandProcessed = false;\n }\n }\n \n @Input()\n set response(value: string) {\n if (value) {\n this.commands[this.commands.length - 1].response = value;\n this.commandProcessed = true;\n }\n }\n \n handleCommand(event: KeyboardEvent) {\n if (event.keyCode == 13) {\n this.commands.push({text: this.command});\n this.terminalService.sendCommand(this.command);\n this.command = '';\n }\n }\n \n focus(element: HTMLElement) {\n element.focus();\n }\n \n ngOnDestroy() {\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n \n}\n\n@NgModule({\n imports: [CommonModule,FormsModule],\n exports: [Terminal],\n declarations: [Terminal]\n})\nexport class TerminalModule { }"]}