This commit is contained in:
2023-05-01 15:59:17 +02:00
parent 2a3aec6c95
commit 5ce7e17c8b

View File

@@ -6,7 +6,6 @@ import {ActivatedRoute} from "@angular/router";
import {LocationService} from "../../service/http/location.service"; import {LocationService} from "../../service/http/location.service";
import {UserService} from "../../service/http/user.service"; import {UserService} from "../../service/http/user.service";
import {WaypointService} from "../../service/http/waypoint.service"; import {WaypointService} from "../../service/http/waypoint.service";
import {toNumbers} from "@angular/compiler-cli/src/version_helpers";
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -20,13 +19,13 @@ export class ManagementComponent implements OnInit {
showWaypointForm: boolean = false; showWaypointForm: boolean = false;
newUser: UserEntity = {name: "", password: "", username: ""}; newUser: UserEntity = {name: "", password: "", username: ""};
newLocation: LocationEntity = {lat: 0, location: "", lon: 0, region: ""}; newLocation: LocationEntity = {location: "", lat: 0, lon: 0, region: ""};
newWaypoint: WaypointsEntity = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""}; newWaypoint: WaypointsEntity = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""};
locations: LocationEntity[] | undefined; locations: LocationEntity[] | undefined;
waypoints: WaypointsEntity[] | undefined; waypoints: WaypointsEntity[] | undefined;
users: UserEntity[] | undefined; users: UserEntity[] | undefined;
protected readonly String = String;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@@ -49,7 +48,7 @@ export class ManagementComponent implements OnInit {
} }
addUser(name: string, username: string, password: string) { addUser(name: string, username: string, password: string) {
this.newUser = { name: name, username: username, password: password}; this.newUser = {name: name, username: username, password: password};
this.userService.createUser(this.newUser).subscribe(user => { this.userService.createUser(this.newUser).subscribe(user => {
this.users?.push(user); this.users?.push(user);
}); });
@@ -58,6 +57,8 @@ export class ManagementComponent implements OnInit {
addLocation(name: string, region: string, lat: number, lon: number) { addLocation(name: string, region: string, lat: number, lon: number) {
this.newLocation = {location: name, region: region, lat: lat, lon: lon}; this.newLocation = {location: name, region: region, lat: lat, lon: lon};
console.log("newLocation")
console.log(this.newLocation);
this.locationService.createLocation(this.newLocation).subscribe(location => { this.locationService.createLocation(this.newLocation).subscribe(location => {
this.locations?.push(location); this.locations?.push(location);
}); });
@@ -65,7 +66,14 @@ export class ManagementComponent implements OnInit {
} }
addWaypoint(name: string, lat: number, lon: number, description: string, image: string, locationName: string) { addWaypoint(name: string, lat: number, lon: number, description: string, image: string, locationName: string) {
this.newWaypoint = {description: description, img: image, lat: lat, locationName: locationName, lon: lon, name: name} this.newWaypoint = {
description: description,
img: image,
lat: lat,
locationName: locationName,
lon: lon,
name: name
}
this.waypointService.createWaypoint(this.newWaypoint).subscribe(waypoint => { this.waypointService.createWaypoint(this.newWaypoint).subscribe(waypoint => {
this.waypoints?.push(waypoint); this.waypoints?.push(waypoint);
}); });
@@ -95,6 +103,4 @@ export class ManagementComponent implements OnInit {
closeWaypointForm() { closeWaypointForm() {
this.showWaypointForm = false; this.showWaypointForm = false;
} }
protected readonly String = String;
} }