source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/components/controls/controls/controls.component.ts@ baf4cc4

Last change on this file since baf4cc4 was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 5 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import {Component, OnInit} from '@angular/core';
2import {ControlsService} from "../../../services/controls/controls.service";
3import {ControlsResponse} from "../../../model/responses/ControlsResponse";
4import {Router, RouterLink} from "@angular/router";
5import {MatButton} from "@angular/material/button";
6import {MatFormField, MatLabel} from "@angular/material/form-field";
7import {MatOption} from "@angular/material/core";
8import {MatSelect, MatSelectChange} from "@angular/material/select";
9import {RouteInstanceService} from "../../../services/route-instance/route-instance.service";
10import {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})
26export 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}
Note: See TracBrowser for help on using the repository browser.