2016-08-29 21:12:31 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2016-08-24 12:58:40 +00:00
|
|
|
import { Http, Response } from '@angular/http';
|
|
|
|
import { Observable } from 'rxjs/Rx';
|
|
|
|
import { HTTP_PROVIDERS } from '@angular/http';
|
2016-08-29 21:12:31 +00:00
|
|
|
import { XtermTerminalComponent } from './xterm-terminal/xterm-terminal.component';
|
2016-08-24 12:58:40 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-app',
|
|
|
|
templateUrl: 'app/app.component.html',
|
|
|
|
styleUrls: ['app/app.component.css'],
|
|
|
|
providers: [ HTTP_PROVIDERS ],
|
2016-08-29 21:12:31 +00:00
|
|
|
directives: [ XtermTerminalComponent ]
|
2016-08-24 12:58:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
export class AppComponent implements OnInit {
|
|
|
|
instructions: any;
|
|
|
|
instructionsArray: any;
|
|
|
|
responsesArray: any;
|
2016-08-29 21:12:31 +00:00
|
|
|
counter: number;
|
2016-08-24 12:58:40 +00:00
|
|
|
|
|
|
|
constructor(private http: Http) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.getInstructions();
|
|
|
|
this.getResponses();
|
|
|
|
}
|
|
|
|
|
2016-08-29 21:12:31 +00:00
|
|
|
updateInstructions(step) {
|
|
|
|
if (step < 0) {
|
|
|
|
step = 0
|
|
|
|
}
|
|
|
|
this.counter = step;
|
|
|
|
this.instructions = this.instructionsArray[step]['_body'];
|
2016-08-24 12:58:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getInstructions() {
|
|
|
|
Observable.forkJoin(
|
|
|
|
this.http.get('/app/instructions/step0.txt'),
|
|
|
|
this.http.get('/app/instructions/step1.txt'),
|
|
|
|
this.http.get('/app/instructions/step2.txt')
|
|
|
|
).subscribe(
|
|
|
|
data => {
|
|
|
|
this.instructionsArray = data;
|
2016-08-29 21:12:31 +00:00
|
|
|
this.updateInstructions(0);
|
2016-08-24 12:58:40 +00:00
|
|
|
},
|
|
|
|
err => console.error(err)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getResponses() {
|
|
|
|
Observable.forkJoin(
|
|
|
|
this.http.get('/app/responses/help.txt'), // 0
|
|
|
|
this.http.get('/app/responses/ls.txt'), // 1
|
|
|
|
this.http.get('/app/responses/pwd.txt'), // 2
|
|
|
|
this.http.get('/app/responses/inspec_exec.txt'), // 3
|
|
|
|
this.http.get('/app/responses/inspec_version.txt') // 4
|
|
|
|
).subscribe(
|
|
|
|
data => {
|
|
|
|
this.responsesArray = data;
|
|
|
|
},
|
|
|
|
err => console.error(err)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|