Angular web app for entering Techblox commands
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
846B

  1. import { Component } from '@angular/core';
  2. import { HttpClient } from '@angular/common/http';
  3. import { FormControl } from '@angular/forms';
  4. @Component({
  5. selector: 'app-root',
  6. templateUrl: './app.component.html',
  7. styleUrls: ['./app.component.scss']
  8. })
  9. export class AppComponent {
  10. title = 'TBConsoleClient';
  11. logMessages = '';
  12. commandControl: FormControl = new FormControl('');
  13. constructor(private http: HttpClient) {
  14. }
  15. async sendCommand() {
  16. try {
  17. const res = await this.http.post('http://localhost:8019/', this.commandControl.value, {responseType: 'text'}).toPromise();
  18. this.logMessages += res + "\n";
  19. } catch (e) {
  20. if (e.status == 0)
  21. this.logMessages += "Failed to contact mod! Make sure it is running and listening.\n";
  22. else
  23. this.logMessages += e.message + "\n";
  24. }
  25. }
  26. }