1 | import {Component, OnInit} from '@angular/core';
|
---|
2 | import {ControlsService} from "../../../services/controls/controls.service";
|
---|
3 | import {ControlsResponse} from "../../../model/responses/ControlsResponse";
|
---|
4 | import {Router, RouterLink} from "@angular/router";
|
---|
5 | import {MatButton} from "@angular/material/button";
|
---|
6 | import {MatFormField, MatLabel} from "@angular/material/form-field";
|
---|
7 | import {MatOption} from "@angular/material/core";
|
---|
8 | import {MatSelect, MatSelectChange} from "@angular/material/select";
|
---|
9 | import {RouteInstanceService} from "../../../services/route-instance/route-instance.service";
|
---|
10 | import {RouteInstanceResponse} from "../../../model/responses/RouteInstanceResponse";
|
---|
11 |
|
---|
12 | @Component({
|
---|
13 | selector: 'app-controls',
|
---|
14 | standalone: true,
|
---|
15 | imports: [
|
---|
16 | RouterLink,
|
---|
17 | MatButton,
|
---|
18 | MatFormField,
|
---|
19 | MatLabel,
|
---|
20 | MatOption,
|
---|
21 | MatSelect
|
---|
22 | ],
|
---|
23 | templateUrl: './controls.component.html',
|
---|
24 | styleUrl: './controls.component.css'
|
---|
25 | })
|
---|
26 | export class ControlsComponent implements OnInit {
|
---|
27 | controls: ControlsResponse[] = []
|
---|
28 | instances: RouteInstanceResponse[] = []
|
---|
29 |
|
---|
30 | instanceId: number | undefined;
|
---|
31 |
|
---|
32 | constructor(private _controlsService: ControlsService,
|
---|
33 | private _routeInstanceService: RouteInstanceService,
|
---|
34 | private router: Router) {
|
---|
35 | }
|
---|
36 |
|
---|
37 | ngOnInit() {
|
---|
38 | this._controlsService.getControls().subscribe(controls => {
|
---|
39 | this.controls = controls
|
---|
40 | })
|
---|
41 |
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | onClick() {
|
---|
46 | this._routeInstanceService.getAll().subscribe(instances => this.instances = instances)
|
---|
47 | }
|
---|
48 |
|
---|
49 | onInstancePick(event: MatSelectChange) {
|
---|
50 | this.instanceId = event.value
|
---|
51 | }
|
---|
52 |
|
---|
53 | onStart() {
|
---|
54 | if (this.instanceId) {
|
---|
55 | this._controlsService.start(this.instanceId).subscribe(response => {
|
---|
56 | console.log(response);
|
---|
57 | this.router.navigate(['/controls', response.id])
|
---|
58 | })
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|